| 56 | } |
| 57 | |
| 58 | @Test |
| 59 | public void testEscaping() { |
| 60 | String[][] tests = new String[][] { |
| 61 | new String[] { "x", "x" }, // Don't escape |
| 62 | new String[] { "/", "/" }, // Don't escape |
| 63 | new String[] { "\\", "\\\\" }, |
| 64 | new String[] { "\"", "\\\"" }, |
| 65 | new String[] { "\n", "\\n" }, |
| 66 | new String[] { "\r", "\\r" }, |
| 67 | new String[] { "\u000B", "\\u000b" } |
| 68 | }; |
| 69 | |
| 70 | for (String[] test : tests) { |
| 71 | CharSequence result = JsonFormatter.JSONFilter.escape(test[0]); |
| 72 | |
| 73 | Assert.assertEquals(test[1], String.valueOf(result)); |
| 74 | } |
| 75 | } |
| 76 | } |