use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetInt.
public void testSetAndGetInt() throws Exception {
TypicalData data = TypicalData.newBuilder().setMyInt(42).build();
assertEquals(42, data.getMyInt());
}
use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testGetPrimitiveFields.
private static void testGetPrimitiveFields() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllPrimitiveFields(builder);
TypicalData data = builder.build();
for (int i = 0; i < 100000; i++) {
data.getMyInt();
data.getMyBool();
data.getMyFloat();
data.getMyDouble();
data.getMyUint();
data.getMyLong();
data.getMyUlong();
}
}
use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testWriteTo.
private static void testWriteTo() throws Exception {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllPrimitiveFields(builder);
setAllRepeatedFields(builder, 5);
setMessageField(builder);
TypicalData data = builder.build();
for (int i = 0; i < 10000; i++) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
data.writeTo(out);
}
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testProtocolMessageEnum.
public void testProtocolMessageEnum() throws Exception {
TypicalData data = TypicalData.newBuilder().setMyEnumType(TypicalData.EnumType.VALUE1).build();
ProtocolMessageEnum type = data.getMyEnumType();
assertEquals(1, type.getNumber());
// Test casting to ProtocolMessageEnum.
Object value = TypicalData.EnumType.VALUE2;
type = (ProtocolMessageEnum) value;
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testGetUnsetField.
public void testGetUnsetField() throws Exception {
TypicalData data = TypicalData.newBuilder().build();
Descriptor descriptor = TypicalData.getDescriptor();
assertEquals(0, data.getField(descriptor.findFieldByNumber(1)));
Object result = data.getField(descriptor.findFieldByNumber(3));
assertTrue(result instanceof EnumValueDescriptor);
assertEquals(TypicalData.EnumType.VALUE1.getValueDescriptor().getNumber(), ((EnumValueDescriptor) result).getNumber());
assertTrue(data.getField(descriptor.findFieldByNumber(11)) instanceof TypicalDataMessage);
}
Aggregations