| Index: third_party/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java
|
| ===================================================================
|
| --- third_party/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java (revision 216642)
|
| +++ third_party/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java (working copy)
|
| @@ -50,6 +50,19 @@
|
| 114, 4, -1, 0, -1, 0, -30, 2, 4, -1,
|
| 0, -1, 0, -30, 2, 4, -1, 0, -1, 0, });
|
|
|
| + private ByteString encodedTestAllTypes;
|
| +
|
| + @Override
|
| + protected void setUp() throws Exception {
|
| + super.setUp();
|
| + this.encodedTestAllTypes = UnittestProto.TestAllTypes.newBuilder()
|
| + .setOptionalString("foo")
|
| + .addRepeatedString("bar")
|
| + .addRepeatedString("baz")
|
| + .build()
|
| + .toByteString();
|
| + }
|
| +
|
| /**
|
| * Tests that an invalid UTF8 string will roundtrip through a parse
|
| * and serialization.
|
| @@ -112,4 +125,19 @@
|
| assertSame(bPrime, proto.getRepeatedString(0));
|
| assertSame(cPrime, proto.getRepeatedString(1));
|
| }
|
| +
|
| + public void testNoStringCachingIfOnlyBytesAccessed() throws Exception {
|
| + UnittestProto.TestAllTypes proto =
|
| + UnittestProto.TestAllTypes.parseFrom(encodedTestAllTypes);
|
| + ByteString optional = proto.getOptionalStringBytes();
|
| + assertSame(optional, proto.getOptionalStringBytes());
|
| + assertSame(optional, proto.toBuilder().getOptionalStringBytes());
|
| +
|
| + ByteString repeated0 = proto.getRepeatedStringBytes(0);
|
| + ByteString repeated1 = proto.getRepeatedStringBytes(1);
|
| + assertSame(repeated0, proto.getRepeatedStringBytes(0));
|
| + assertSame(repeated1, proto.getRepeatedStringBytes(1));
|
| + assertSame(repeated0, proto.toBuilder().getRepeatedStringBytes(0));
|
| + assertSame(repeated1, proto.toBuilder().getRepeatedStringBytes(1));
|
| + }
|
| }
|
|
|