use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testGetRepeatedFieldList.
private static void testGetRepeatedFieldList() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllRepeatedFields(builder, 25);
TypicalData data = builder.build();
for (int i = 0; i < 2000; i++) {
data.getRepeatedInt32List();
data.getRepeatedInt64List();
data.getRepeatedUint32List();
data.getRepeatedUint64List();
data.getRepeatedBoolList();
data.getRepeatedFloatList();
data.getRepeatedDoubleList();
data.getRepeatedStringList();
data.getRepeatedBytesList();
data.getRepeatedEnumList();
}
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedDouble.
public void testSetAndGetRepeatedDouble() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedDouble(0.5).build();
assertEquals(1, data.getRepeatedDoubleCount());
assertEquals(0.5, data.getRepeatedDouble(0), 0.0001);
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedEnum.
public void testSetAndGetRepeatedEnum() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedEnum(TypicalData.EnumType.VALUE1).build();
assertEquals(1, data.getRepeatedEnumCount());
assertEquals(TypicalData.EnumType.VALUE1, data.getRepeatedEnum(0));
assertEquals(TypicalData.EnumType.VALUE1, data.getRepeatedEnumList().get(0));
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetExtensions.
public void testSetAndGetExtensions() throws Exception {
TypicalDataMessage extensionMessage = TypicalDataMessage.newBuilder().setMyMessageInt(321).build();
List<Integer> repeatedInts = new ArrayList<Integer>();
repeatedInts.add(1);
repeatedInts.add(2);
List<TypicalDataMessage> repeatedData = new ArrayList<TypicalDataMessage>();
repeatedData.add(TypicalDataMessage.newBuilder().setMyMessageInt(432).build());
repeatedData.add(TypicalDataMessage.newBuilder().setMyMessageInt(543).build());
TypicalData.Builder dataBuilder = TypicalData.newBuilder().setExtension(Typical.myPrimitiveExtension, 123).setExtension(Typical.myExtension, extensionMessage).setExtension(Typical.myRepeatedPrimitiveExtension, repeatedInts).addExtension(Typical.myRepeatedPrimitiveExtension, 3).setExtension(Typical.myRepeatedExtension, repeatedData).setExtension(Typical.myEnumExtension, TypicalData.EnumType.VALUE1).setExtension(Typical.myBytesExtension, ByteString.copyFrom("abc".getBytes())).setExtension(Typical.myBoolExtension, Boolean.TRUE).setExtension(MsgWithNestedExtensions.intExt, 456);
checkGetExtensions(dataBuilder);
checkGetExtensions(dataBuilder.build());
ByteArrayOutputStream out = new ByteArrayOutputStream();
dataBuilder.build().writeTo(out);
byte[] msgBytes = asBytes(new int[] { 0xC2, 0x3E, 0x03, 0x08, 0xC1, 0x02, 0xC8, 0x3E, 0x7B, 0xD0, 0x3E, 0x01, 0xD0, 0x3E, 0x02, 0xD0, 0x3E, 0x03, 0xDA, 0x3E, 0x03, 0x08, 0xB0, 0x03, 0xDA, 0x3E, 0x03, 0x08, 0x9F, 0x04, 0xE0, 0x3E, 0x01, 0xEA, 0x3E, 0x03, 0x61, 0x62, 0x63, 0xF0, 0x3E, 0x01, 0x80, 0x7D, 0xC8, 0x03 });
checkBytes(msgBytes, out.toByteArray());
ExtensionRegistry registry = ExtensionRegistry.newInstance();
Typical.registerAllExtensions(registry);
ByteArrayInputStream in = new ByteArrayInputStream(msgBytes);
TypicalData data = TypicalData.newBuilder().mergeFrom(in, registry).build();
checkGetExtensions(data);
}
use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testGetRepeatedFieldsWithDescriptors.
private static void testGetRepeatedFieldsWithDescriptors() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllRepeatedFields(builder, 25);
TypicalData data = builder.build();
List<FieldDescriptor> fields = getRepeatedFieldDescriptors();
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 25; j++) {
for (FieldDescriptor field : fields) {
data.getRepeatedField(field, j);
}
}
}
}
Aggregations