aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/test/java/com/google/protobuf/NanoTest.java
diff options
context:
space:
mode:
authorUlas Kirazci <ulas@google.com>2013-07-31 23:11:08 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-07-31 23:11:08 +0000
commit87c8e31b8c0baa78f979863a9ed10654a1cdca1f (patch)
tree779734f1949ccb91200511e602ba953c48bddd90 /java/src/test/java/com/google/protobuf/NanoTest.java
parentbe47f55e2f93df84abb55759e49cf381d2745cc5 (diff)
parent14dd1f02ac95f61087e311bf61c85047fb218a29 (diff)
downloadexternal_protobuf-87c8e31b8c0baa78f979863a9ed10654a1cdca1f.zip
external_protobuf-87c8e31b8c0baa78f979863a9ed10654a1cdca1f.tar.gz
external_protobuf-87c8e31b8c0baa78f979863a9ed10654a1cdca1f.tar.bz2
Merge "Fixed packed repeated serialization."
Diffstat (limited to 'java/src/test/java/com/google/protobuf/NanoTest.java')
-rw-r--r--java/src/test/java/com/google/protobuf/NanoTest.java19
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 80f091b..23768b7 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 };