}
public void test_string() throws Exception {
{
JSONScanner lexer = new JSONScanner("\"中国\"");
lexer.nextToken();
Assert.assertEquals("中国", lexer.stringVal());
}
{
JSONScanner lexer = new JSONScanner("\"中国\t\"");
lexer.nextToken();
Assert.assertEquals("中国\t", lexer.stringVal());
}
{
JSONScanner lexer = new JSONScanner("\"中国\tV5\"");
lexer.nextToken();
Assert.assertEquals("中国\tV5", lexer.stringVal());
}
StringBuilder buf = new StringBuilder();
buf.append('"');
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
buf.append('"');
buf.append('\u2001');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
String stringVal = lexer.stringVal();
Assert.assertEquals("\"\\\\/\\b\\f\\n\\r\\t中\"", JSON.toJSONString(stringVal));
}