use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedBytes.
public void testSetAndGetRepeatedBytes() throws Exception {
List<ByteString> list = new ArrayList<ByteString>();
list.add(ByteString.copyFrom("def".getBytes()));
list.add(ByteString.copyFrom("ghi".getBytes()));
TypicalData data = TypicalData.newBuilder().addRepeatedBytes(ByteString.copyFrom("abc".getBytes())).addAllRepeatedBytes(list).setRepeatedBytes(2, ByteString.copyFrom("jkl".getBytes())).build();
assertEquals(3, data.getRepeatedBytesCount());
assertEquals("abc", new String(data.getRepeatedBytes(0).toByteArray()));
byte[] bytes = data.toByteArray();
TypicalData other = TypicalData.parseFrom(bytes);
assertEquals("abc", new String(other.getRepeatedBytes(0).toByteArray()));
assertEquals("def", new String(other.getRepeatedBytesList().get(1).toByteArray()));
assertEquals("jkl", new String(other.getRepeatedBytes(2).toByteArray()));
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testMergeFrom.
public void testMergeFrom() throws Exception {
TypicalData input = TypicalData.newBuilder().setMyInt(42).setMyMessage(TypicalDataMessage.newBuilder().setMyMessageInt(43)).build();
TypicalData output = TypicalData.newBuilder().mergeFrom(input.toByteString(), ExtensionRegistry.getEmptyRegistry()).build();
assertEquals(42, output.getMyInt());
assertEquals(43, output.getMyMessage().getMyMessageInt());
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testParseDelimitedFromEmptyStream.
public void testParseDelimitedFromEmptyStream() throws Exception {
TypicalData output = TypicalData.parseDelimitedFrom(new ByteArrayInputStream(new byte[0]));
assertNull(output);
}
use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testGetRepeatedFields.
private static void testGetRepeatedFields() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllRepeatedFields(builder, 25);
TypicalData data = builder.build();
for (int i = 0; i < 3000; i++) {
for (int j = 0; j < 25; j++) {
data.getRepeatedInt32(j);
data.getRepeatedInt64(j);
data.getRepeatedUint32(j);
data.getRepeatedUint64(j);
data.getRepeatedBool(j);
data.getRepeatedFloat(j);
data.getRepeatedDouble(j);
data.getRepeatedString(j);
data.getRepeatedBytes(j);
data.getRepeatedEnum(j);
}
}
}
use of protos.TypicalData in project j2objc by google.
the class PerformanceBenchmarks method testGetPrimitiveFieldsWithDescriptors.
private static void testGetPrimitiveFieldsWithDescriptors() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllPrimitiveFields(builder);
TypicalData data = builder.build();
List<FieldDescriptor> fields = getPrimitiveFieldDescriptors();
for (int i = 0; i < 10000; i++) {
for (FieldDescriptor field : fields) {
data.getField(field);
}
}
}
Aggregations