use of com.google.protobuf.GeneratedMessage in project j2objc by google.
the class CompatibilityTest method testGetAllFields.
public void testGetAllFields() throws Exception {
GeneratedMessage data = TypicalData.newBuilder().setMyInt(1).addRepeatedInt32(2).setExtension(Typical.myExtension, TypicalDataMessage.getDefaultInstance()).setExtension(Typical.myPrimitiveExtension, 3).build();
Map<FieldDescriptor, Object> allFields = data.getAllFields();
assertEquals(4, allFields.size());
assertNotNull(allFields.get(Typical.myExtension.getDescriptor()));
assertEquals(4, data.toBuilder().getAllFields().size());
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor intField = descriptor.findFieldByNumber(1);
assertEquals(1, allFields.get(intField));
assertEquals(3, allFields.get(Typical.myPrimitiveExtension.getDescriptor()));
}
use of com.google.protobuf.GeneratedMessage in project j2objc by google.
the class CompatibilityTest method testGetSerializedSize.
public void testGetSerializedSize() throws Exception {
GeneratedMessage data = TypicalData.newBuilder().setMyInt(1).build();
assertEquals(2, data.getSerializedSize());
}
Aggregations