assertEquals(123, newMsg.getRepeatedFixed64(0));
assertEquals(456, newMsg.getRepeatedFixed64(1));
}
public void testMicroRepeatedSfixed32() throws Exception {
TestAllTypesMicro msg = new TestAllTypesMicro();
assertEquals(0, msg.getRepeatedSfixed32Count());
msg.addRepeatedSfixed32(123);
assertEquals(1, msg.getRepeatedSfixed32Count());
assertEquals(123, msg.getRepeatedSfixed32(0));
msg.addRepeatedSfixed32(456);
assertEquals(2, msg.getRepeatedSfixed32Count());
assertEquals(123, msg.getRepeatedSfixed32(0));
assertEquals(456, msg.getRepeatedSfixed32(1));
msg.setRepeatedSfixed32(0, 789);
assertEquals(2, msg.getRepeatedSfixed32Count());
assertEquals(789, msg.getRepeatedSfixed32(0));
assertEquals(456, msg.getRepeatedSfixed32(1));
msg.clearRepeatedSfixed32();
assertEquals(0, msg.getRepeatedSfixed32Count());
msg.clearRepeatedSfixed32()
.addRepeatedSfixed32(456);
assertEquals(1, msg.getRepeatedSfixed32Count());
assertEquals(456, msg.getRepeatedSfixed32(0));
msg.clear();
assertEquals(0, msg.getRepeatedSfixed32Count());
// Test 1 entry
msg.clear()
.addRepeatedSfixed32(123);
assertEquals(1, msg.getRepeatedSfixed32Count());
byte [] result = msg.toByteArray();
int msgSerializedSize = msg.getSerializedSize();
//System.out.printf("mss=%d result.length=%d\n", msgSerializedSize, result.length);
assertTrue(msgSerializedSize == 6);
assertEquals(result.length, msgSerializedSize);
TestAllTypesMicro newMsg = TestAllTypesMicro.parseFrom(result);
assertEquals(1, newMsg.getRepeatedSfixed32Count());
assertEquals(123, newMsg.getRepeatedSfixed32(0));
// Test 2 entries
msg.clear()
.addRepeatedSfixed32(123)
.addRepeatedSfixed32(456);
assertEquals(2, msg.getRepeatedSfixed32Count());
result = msg.toByteArray();
msgSerializedSize = msg.getSerializedSize();
//System.out.printf("mss=%d result.length=%d\n", msgSerializedSize, result.length);
assertTrue(msgSerializedSize == 12);
assertEquals(result.length, msgSerializedSize);
newMsg = TestAllTypesMicro.parseFrom(result);
assertEquals(2, newMsg.getRepeatedSfixed32Count());
assertEquals(123, newMsg.getRepeatedSfixed32(0));
assertEquals(456, newMsg.getRepeatedSfixed32(1));
}