aboutsummaryrefslogtreecommitdiff
path: root/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java')
-rw-r--r--java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java51
1 files changed, 20 insertions, 31 deletions
diff --git a/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java b/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
index 756049b4..2518f20d 100644
--- a/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
+++ b/java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java
@@ -39,45 +39,36 @@ import static com.google.protobuf.IsValidUtf8TestUtil.testBytes;
import com.google.protobuf.IsValidUtf8TestUtil.ByteStringFactory;
import com.google.protobuf.IsValidUtf8TestUtil.Shard;
-
import junit.framework.TestCase;
/**
- * Tests cases for {@link ByteString#isValidUtf8()}. This includes three
- * brute force tests that actually test every permutation of one byte, two byte,
- * and three byte sequences to ensure that the method produces the right result
- * for every possible byte encoding where "right" means it's consistent with
- * java's UTF-8 string encoding/decoding such that the method returns true for
- * any sequence that will round trip when converted to a String and then back to
- * bytes and will return false for any sequence that will not round trip.
- * See also {@link IsValidUtf8FourByteTest}. It also includes some
- * other more targeted tests.
+ * Tests cases for {@link ByteString#isValidUtf8()}. This includes three brute force tests that
+ * actually test every permutation of one byte, two byte, and three byte sequences to ensure that
+ * the method produces the right result for every possible byte encoding where "right" means it's
+ * consistent with java's UTF-8 string encoding/decoding such that the method returns true for any
+ * sequence that will round trip when converted to a String and then back to bytes and will return
+ * false for any sequence that will not round trip. See also {@link IsValidUtf8FourByteTest}. It
+ * also includes some other more targeted tests.
*
* @author jonp@google.com (Jon Perlow)
* @author martinrb@google.com (Martin Buchholz)
*/
public class IsValidUtf8Test extends TestCase {
- /**
- * Tests that round tripping of all two byte permutations work.
- */
+ /** Tests that round tripping of all two byte permutations work. */
public void testIsValidUtf8_1Byte() {
testBytes(LITERAL_FACTORY, 1, EXPECTED_ONE_BYTE_ROUNDTRIPPABLE_COUNT);
testBytes(HEAP_NIO_FACTORY, 1, EXPECTED_ONE_BYTE_ROUNDTRIPPABLE_COUNT);
testBytes(DIRECT_NIO_FACTORY, 1, EXPECTED_ONE_BYTE_ROUNDTRIPPABLE_COUNT);
}
- /**
- * Tests that round tripping of all two byte permutations work.
- */
+ /** Tests that round tripping of all two byte permutations work. */
public void testIsValidUtf8_2Bytes() {
testBytes(LITERAL_FACTORY, 2, IsValidUtf8TestUtil.EXPECTED_TWO_BYTE_ROUNDTRIPPABLE_COUNT);
testBytes(HEAP_NIO_FACTORY, 2, IsValidUtf8TestUtil.EXPECTED_TWO_BYTE_ROUNDTRIPPABLE_COUNT);
testBytes(DIRECT_NIO_FACTORY, 2, IsValidUtf8TestUtil.EXPECTED_TWO_BYTE_ROUNDTRIPPABLE_COUNT);
}
- /**
- * Tests that round tripping of all three byte permutations work.
- */
+ /** Tests that round tripping of all three byte permutations work. */
public void testIsValidUtf8_3Bytes() {
// Travis' OOM killer doesn't like this test
if (System.getenv("TRAVIS") == null) {
@@ -88,10 +79,9 @@ public class IsValidUtf8Test extends TestCase {
}
/**
- * Tests that round tripping of a sample of four byte permutations work.
- * All permutations are prohibitively expensive to test for automated runs;
- * {@link IsValidUtf8FourByteTest} is used for full coverage. This method
- * tests specific four-byte cases.
+ * Tests that round tripping of a sample of four byte permutations work. All permutations are
+ * prohibitively expensive to test for automated runs; {@link IsValidUtf8FourByteTest} is used for
+ * full coverage. This method tests specific four-byte cases.
*/
public void testIsValidUtf8_4BytesSamples() {
// Valid 4 byte.
@@ -106,9 +96,7 @@ public class IsValidUtf8Test extends TestCase {
assertInvalidUtf8(0xF4, 0x90, 0xAD, 0xA2);
}
- /**
- * Tests some hard-coded test cases.
- */
+ /** Tests some hard-coded test cases. */
public void testSomeSequences() {
// Empty
assertTrue(asBytes("").isValidUtf8());
@@ -149,11 +137,12 @@ public class IsValidUtf8Test extends TestCase {
assertTrue(not ^ leaf.isValidUtf8());
assertTrue(not ^ sub.isValidUtf8());
ByteString[] ropes = {
- RopeByteString.newInstanceForTest(ByteString.EMPTY, leaf),
- RopeByteString.newInstanceForTest(ByteString.EMPTY, sub),
- RopeByteString.newInstanceForTest(leaf, ByteString.EMPTY),
- RopeByteString.newInstanceForTest(sub, ByteString.EMPTY),
- RopeByteString.newInstanceForTest(sub, leaf)};
+ RopeByteString.newInstanceForTest(ByteString.EMPTY, leaf),
+ RopeByteString.newInstanceForTest(ByteString.EMPTY, sub),
+ RopeByteString.newInstanceForTest(leaf, ByteString.EMPTY),
+ RopeByteString.newInstanceForTest(sub, ByteString.EMPTY),
+ RopeByteString.newInstanceForTest(sub, leaf)
+ };
for (ByteString rope : ropes) {
assertTrue(not ^ rope.isValidUtf8());
}