diff options
author | Brian Duff <bduff@google.com> | 2013-06-28 17:23:51 -0700 |
---|---|---|
committer | Brian Duff <bduff@google.com> | 2013-07-08 22:29:51 -0700 |
commit | a9c4e082e053b40730e8091da2cc076ba3fadcb6 (patch) | |
tree | 0f917df4a7d4fc5f31d6a428c9f01607e88de0a1 /java/src/test | |
parent | 499f47ffdbc383d134d901419ae2e95e25b254c2 (diff) | |
download | protobuf-a9c4e082e053b40730e8091da2cc076ba3fadcb6.tar.gz protobuf-a9c4e082e053b40730e8091da2cc076ba3fadcb6.tar.bz2 protobuf-a9c4e082e053b40730e8091da2cc076ba3fadcb6.zip |
Make it possible to use MessageNano.mergeFrom without casting.
You can now do:
MyMessage foo = MessageNano.mergeFrom(new MyMessage(), bytes);
without having to cast the message returned from mergeFrom.
Change-Id: Ibb2ad327f75855d45352ad304c7f054f20dd29c9
Diffstat (limited to 'java/src/test')
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 9 |
1 files changed, 9 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 38fafb9e..19f39575 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -2241,6 +2241,15 @@ public class NanoTest extends TestCase { assertEquals(0, MessageNano.toByteArray(deserialized).length); } + public void testMergeFrom() throws Exception { + SimpleMessageNano message = new SimpleMessageNano(); + message.d = 123; + byte[] bytes = MessageNano.toByteArray(message); + + SimpleMessageNano newMessage = MessageNano.mergeFrom(new SimpleMessageNano(), bytes); + assertEquals(message.d, newMessage.d); + } + private <T> List<T> list(T first, T... remaining) { List<T> list = new ArrayList<T>(); list.add(first); |