diff options
Diffstat (limited to 'java/src/test/java/com/google/protobuf/TextFormatTest.java')
-rw-r--r-- | java/src/test/java/com/google/protobuf/TextFormatTest.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/java/src/test/java/com/google/protobuf/TextFormatTest.java b/java/src/test/java/com/google/protobuf/TextFormatTest.java index 1d73165e..3ea7b2cf 100644 --- a/java/src/test/java/com/google/protobuf/TextFormatTest.java +++ b/java/src/test/java/com/google/protobuf/TextFormatTest.java @@ -68,7 +68,7 @@ public class TextFormatTest extends TestCase { private static String allExtensionsSetText = TestUtil.readTextFromFile( "text_format_unittest_extensions_data.txt"); - private String exoticText = + private static String exoticText = "repeated_int32: -1\n" + "repeated_int32: -2147483648\n" + "repeated_int64: -1\n" + @@ -80,7 +80,13 @@ public class TextFormatTest extends TestCase { "repeated_double: 123.0\n" + "repeated_double: 123.5\n" + "repeated_double: 0.125\n" + + "repeated_double: .125\n" + + "repeated_double: -.125\n" + "repeated_double: 1.23E17\n" + + "repeated_double: 1.23E+17\n" + + "repeated_double: -1.23e-17\n" + + "repeated_double: .23e+17\n" + + "repeated_double: -.23E17\n" + "repeated_double: 1.235E22\n" + "repeated_double: 1.235E-18\n" + "repeated_double: 123.456789\n" + @@ -91,6 +97,10 @@ public class TextFormatTest extends TestCase { "\\341\\210\\264\"\n" + "repeated_bytes: \"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\\376\"\n"; + private static String canonicalExoticText = + exoticText.replace(": .", ": 0.").replace(": -.", ": -0.") // short-form double + .replace("23e", "23E").replace("E+", "E").replace("0.23E17", "2.3E16"); + private String messageSetText = "[protobuf_unittest.TestMessageSetExtension1] {\n" + " i: 123\n" + @@ -231,7 +241,13 @@ public class TextFormatTest extends TestCase { .addRepeatedDouble(123) .addRepeatedDouble(123.5) .addRepeatedDouble(0.125) + .addRepeatedDouble(.125) + .addRepeatedDouble(-.125) + .addRepeatedDouble(123e15) .addRepeatedDouble(123e15) + .addRepeatedDouble(-1.23e-17) + .addRepeatedDouble(.23e17) + .addRepeatedDouble(-23e15) .addRepeatedDouble(123.5e20) .addRepeatedDouble(123.5e-20) .addRepeatedDouble(123.456789) @@ -244,7 +260,7 @@ public class TextFormatTest extends TestCase { .addRepeatedBytes(bytes("\0\001\007\b\f\n\r\t\013\\\'\"\u00fe")) .build(); - assertEquals(exoticText, message.toString()); + assertEquals(canonicalExoticText, message.toString()); } public void testPrintMessageSet() throws Exception { @@ -319,7 +335,7 @@ public class TextFormatTest extends TestCase { // Too lazy to check things individually. Don't try to debug this // if testPrintExotic() is failing. - assertEquals(exoticText, builder.build().toString()); + assertEquals(canonicalExoticText, builder.build().toString()); } public void testParseMessageSet() throws Exception { |