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/LiteralByteStringTest.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/LiteralByteStringTest.java')
-rw-r--r-- | java/src/test/java/com/google/protobuf/LiteralByteStringTest.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java b/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java index f3ad774f..8607040e 100644 --- a/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +++ b/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java @@ -298,6 +298,13 @@ public class LiteralByteStringTest extends TestCase { assertEquals(classUnderTest + " unicode must match", testString, roundTripString); } + public void testCharsetToString() throws UnsupportedEncodingException { + String testString = "I love unicode \u1234\u5678 characters"; + LiteralByteString unicode = new LiteralByteString(testString.getBytes(ByteString.UTF_8)); + String roundTripString = unicode.toString(ByteString.UTF_8); + assertEquals(classUnderTest + " unicode must match", testString, roundTripString); + } + public void testToString_returnsCanonicalEmptyString() throws UnsupportedEncodingException{ assertSame(classUnderTest + " must be the same string references", ByteString.EMPTY.toString(UTF_8), new LiteralByteString(new byte[]{}).toString(UTF_8)); |