use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_string3.
public void test_string3() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('"');
for (int i = 0; i < 200; ++i) {
buf.append("abcdefghijklmn012345689ABCDEFG");
}
buf.append('"');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
lexer.stringVal();
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_big_integer_1.
public void test_big_integer_1() throws Exception {
String text = Long.MAX_VALUE + "1234";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken();
Assert.assertEquals(new BigInteger(text), lexer.integerValue());
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_string4.
public void test_string4() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('"');
for (int i = 0; i < 200; ++i) {
buf.append("\\tabcdefghijklmn012345689ABCDEFG");
}
buf.append('"');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
lexer.stringVal();
// Assert.assertEquals("\"\\\\\\/\\b\\f\\n\\r\\t中\"",
// JSON.toJSONString(stringVal));
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_error.
public void test_error() throws Exception {
JSONScanner lexer = new JSONScanner("k");
lexer.nextToken();
Assert.assertEquals(JSONToken.ERROR, lexer.token());
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_string2.
public void test_string2() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('"');
for (int i = 0; i < 200; ++i) {
buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
}
buf.append('"');
String text = buf.toString();
JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
lexer.nextToken();
Assert.assertEquals(0, lexer.pos());
lexer.stringVal();
}
Aggregations