use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedInt32.
public void testSetAndGetRepeatedInt32() throws Exception {
List<Integer> list = new ArrayList<Integer>();
list.add(34);
list.add(56);
TypicalData data = TypicalData.newBuilder().addRepeatedInt32(12).addAllRepeatedInt32(list).setRepeatedInt32(2, 67).build();
assertEquals(3, data.getRepeatedInt32Count());
assertEquals(12, data.getRepeatedInt32(0));
byte[] bytes = data.toByteArray();
TypicalData other = TypicalData.parseFrom(bytes);
assertEquals(12, other.getRepeatedInt32(0));
// compareTo will fail in objc if the returned type is not JavaLangInteger.
assertEquals(0, other.getRepeatedInt32List().get(1).compareTo(34));
assertEquals(67, other.getRepeatedInt32(2));
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testMergeFromLargeProto.
public void testMergeFromLargeProto() throws Exception {
TypicalData.Builder builder1 = TypicalData.newBuilder();
TypicalData.Builder builder2 = TypicalData.newBuilder();
TypicalData.Builder builder3 = TypicalData.newBuilder();
InputStream in = getTestData("largeproto");
try {
assertTrue(builder1.mergeDelimitedFrom(in));
assertTrue(builder2.mergeDelimitedFrom(in));
assertTrue(builder3.mergeDelimitedFrom(in));
} finally {
in.close();
}
TypicalData data1 = builder1.build();
TypicalData data2 = builder2.build();
TypicalData data3 = builder3.build();
assertEquals(0, data1.getRepeatedInt32(0));
assertEquals(999, data1.getRepeatedInt32(999));
assertEquals(1000, data2.getRepeatedInt32(0));
assertEquals(1999, data2.getRepeatedInt32(999));
assertEquals(2000, data3.getRepeatedInt32(0));
assertEquals(2999, data3.getRepeatedInt32(999));
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedString.
public void testSetAndGetRepeatedString() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedString("coin").build();
assertEquals(1, data.getRepeatedStringCount());
assertEquals("coin", data.getRepeatedString(0));
List<String> list = data.getRepeatedStringList();
assertEquals(1, list.size());
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedUint64.
public void testSetAndGetRepeatedUint64() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedUint64(123).build();
assertEquals(1, data.getRepeatedUint64Count());
assertEquals(123, data.getRepeatedUint64(0));
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetByteString.
public void testSetAndGetByteString() throws Exception {
ByteString bstr = ByteString.copyFrom("foo".getBytes());
TypicalData data = TypicalData.newBuilder().setMyBytes(bstr).build();
assertEquals("foo", new String(data.getMyBytes().toByteArray()));
}
Aggregations