|
|
@ -62,7 +62,7 @@ public class BoundedByteStringTest extends LiteralByteStringTest { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void testToString() throws UnsupportedEncodingException { |
|
|
|
public void testToString() throws UnsupportedEncodingException { |
|
|
|
String testString = "I love unicode \u1234\u5678 characters"; |
|
|
|
String testString = "I love unicode \u1234\u5678 characters"; |
|
|
|
LiteralByteString unicode = new LiteralByteString(testString.getBytes(ByteString.UTF_8)); |
|
|
|
LiteralByteString unicode = new LiteralByteString(testString.getBytes(Internal.UTF_8)); |
|
|
|
ByteString chopped = unicode.substring(2, unicode.size() - 6); |
|
|
|
ByteString chopped = unicode.substring(2, unicode.size() - 6); |
|
|
|
assertEquals(classUnderTest + ".substring() must have the expected type", |
|
|
|
assertEquals(classUnderTest + ".substring() must have the expected type", |
|
|
|
classUnderTest, getActualClassName(chopped)); |
|
|
|
classUnderTest, getActualClassName(chopped)); |
|
|
@ -75,12 +75,12 @@ public class BoundedByteStringTest extends LiteralByteStringTest { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void testCharsetToString() throws UnsupportedEncodingException { |
|
|
|
public void testCharsetToString() throws UnsupportedEncodingException { |
|
|
|
String testString = "I love unicode \u1234\u5678 characters"; |
|
|
|
String testString = "I love unicode \u1234\u5678 characters"; |
|
|
|
LiteralByteString unicode = new LiteralByteString(testString.getBytes(ByteString.UTF_8)); |
|
|
|
LiteralByteString unicode = new LiteralByteString(testString.getBytes(Internal.UTF_8)); |
|
|
|
ByteString chopped = unicode.substring(2, unicode.size() - 6); |
|
|
|
ByteString chopped = unicode.substring(2, unicode.size() - 6); |
|
|
|
assertEquals(classUnderTest + ".substring() must have the expected type", |
|
|
|
assertEquals(classUnderTest + ".substring() must have the expected type", |
|
|
|
classUnderTest, getActualClassName(chopped)); |
|
|
|
classUnderTest, getActualClassName(chopped)); |
|
|
|
|
|
|
|
|
|
|
|
String roundTripString = chopped.toString(ByteString.UTF_8); |
|
|
|
String roundTripString = chopped.toString(Internal.UTF_8); |
|
|
|
assertEquals(classUnderTest + " unicode bytes must match", |
|
|
|
assertEquals(classUnderTest + " unicode bytes must match", |
|
|
|
testString.substring(2, testString.length() - 6), roundTripString); |
|
|
|
testString.substring(2, testString.length() - 6), roundTripString); |
|
|
|
} |
|
|
|
} |
|
|
|