diff options
author | Ulas Kirazci <ulas@google.com> | 2013-07-31 23:11:08 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-07-31 23:11:08 +0000 |
commit | cebd784d19369de465ec21b9f1a38ffa14a06196 (patch) | |
tree | 42b51bce730cf49c6219db70653ae0f2390cee3b /java | |
parent | 064b60c65938dbdb45b1377975cee8a104e6d62b (diff) | |
parent | 1c277f9c68b81b594701d0c5cd90e74170bbab21 (diff) | |
download | protobuf-cebd784d19369de465ec21b9f1a38ffa14a06196.tar.gz protobuf-cebd784d19369de465ec21b9f1a38ffa14a06196.tar.bz2 protobuf-cebd784d19369de465ec21b9f1a38ffa14a06196.zip |
Merge "Fixed packed repeated serialization."
Diffstat (limited to 'java')
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index 80f091bf..23768b78 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -47,6 +47,7 @@ import com.google.protobuf.nano.UnittestImportNano; import junit.framework.TestCase; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -1956,6 +1957,24 @@ public class NanoTest extends TestCase { assertEquals(TestAllTypesNano.BAR, msg.repeatedPackedNestedEnum[1]); } + public void testNanoRepeatedPackedSerializedSize() throws Exception { + TestAllTypesNano msg = new TestAllTypesNano(); + msg.repeatedPackedInt32 = new int[] { 123, 789, 456 }; + int msgSerializedSize = msg.getSerializedSize(); + byte [] result = MessageNano.toByteArray(msg); + //System.out.printf("mss=%d result.length=%d\n", msgSerializedSize, result.length); + assertTrue(msgSerializedSize == 11); + assertEquals(result.length, msgSerializedSize); + TestAllTypesNano msg2 = new TestAllTypesNano(); + msg2.repeatedPackedInt32 = new int[] { 123, 789, 456 }; + byte [] result2 = new byte[msgSerializedSize]; + MessageNano.toByteArray(msg2, result2, 0, msgSerializedSize); + + // Check equal size and content. + assertEquals(msgSerializedSize, msg2.getSerializedSize()); + assertTrue(Arrays.equals(result, result2)); + } + public void testNanoRepeatedInt32ReMerge() throws Exception { TestAllTypesNano msg = new TestAllTypesNano(); msg.repeatedInt32 = new int[] { 234 }; |