aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/test/java/com/google/protobuf/NanoTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/test/java/com/google/protobuf/NanoTest.java')
-rw-r--r--java/src/test/java/com/google/protobuf/NanoTest.java12
1 files changed, 12 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 9987cac..5f28647 100644
--- a/java/src/test/java/com/google/protobuf/NanoTest.java
+++ b/java/src/test/java/com/google/protobuf/NanoTest.java
@@ -105,6 +105,12 @@ public class NanoTest extends TestCase {
assertEquals(456, newMsg.d);
assertEquals(2, msg.nestedMsg.bb);
assertEquals(SimpleMessageNano.BAR, msg.defaultNestedEnum);
+
+ msg.nestedMsg = null;
+ assertTrue(msgSerializedSize != msg.getSerializedSize());
+
+ msg.clear();
+ assertEquals(0, msg.getSerializedSize());
}
public void testRecursiveMessageNano() throws Exception {
@@ -143,6 +149,12 @@ public class NanoTest extends TestCase {
assertEquals(3, newMsg.repeatedRecursiveMessageNano[0].id);
}
+ public void testMessageNoFields() {
+ SingleMessageNano msg = new SingleMessageNano();
+ assertEquals(0, msg.getSerializedSize());
+ assertEquals(0, MessageNano.toByteArray(msg).length);
+ }
+
public void testNanoRequiredInt32() throws Exception {
TestAllTypesNano msg = new TestAllTypesNano();
msg.id = 123;