diff options
author | Viktor Szathmáry <phraktle@gmail.com> | 2014-09-09 16:31:51 +0200 |
---|---|---|
committer | Tamir Duberstein <tamird@gmail.com> | 2015-04-02 14:48:43 -0700 |
commit | e84893f6768f136cc86e2db69fc1d40ff2be7e3b (patch) | |
tree | c36057efe7fc3c3bf50381c96bae16cf73234fa5 /java/src/test/java/com/google/protobuf/BoundedByteStringTest.java | |
parent | 7139d1eff739682a088ea2c2dbdfef2f108321f8 (diff) | |
download | protobuf-e84893f6768f136cc86e2db69fc1d40ff2be7e3b.tar.gz protobuf-e84893f6768f136cc86e2db69fc1d40ff2be7e3b.tar.bz2 protobuf-e84893f6768f136cc86e2db69fc1d40ff2be7e3b.zip |
perf: String#getBytes(Charset) vs getBytes(String)
Diffstat (limited to 'java/src/test/java/com/google/protobuf/BoundedByteStringTest.java')
-rw-r--r-- | java/src/test/java/com/google/protobuf/BoundedByteStringTest.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java b/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java index 6c9596ca..a11bef2e 100644 --- a/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java +++ b/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java @@ -72,6 +72,19 @@ public class BoundedByteStringTest extends LiteralByteStringTest { testString.substring(2, testString.length() - 6), roundTripString); } + @Override + public void testCharsetToString() throws UnsupportedEncodingException { + String testString = "I love unicode \u1234\u5678 characters"; + LiteralByteString unicode = new LiteralByteString(testString.getBytes(ByteString.UTF_8)); + ByteString chopped = unicode.substring(2, unicode.size() - 6); + assertEquals(classUnderTest + ".substring() must have the expected type", + classUnderTest, getActualClassName(chopped)); + + String roundTripString = chopped.toString(ByteString.UTF_8); + assertEquals(classUnderTest + " unicode bytes must match", + testString.substring(2, testString.length() - 6), roundTripString); + } + public void testJavaSerialization() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); |