use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class LexerTest method test_big_integer_2.
public void test_big_integer_2() throws Exception {
String text = Long.MIN_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_error2.
public void test_error2() {
Exception error = null;
try {
JSONScanner lexer = new JSONScanner("--");
lexer.nextToken();
lexer.integerValue();
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class Issue119 method test_for_issue_b.
public void test_for_issue_b() throws Exception {
JSONScanner lexer = new JSONScanner("-10B");
lexer.scanNumber();
Assert.assertEquals(Byte.class, lexer.integerValue().getClass());
Assert.assertEquals(-10, lexer.integerValue().byteValue());
lexer.close();
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONLexerTest_8 method test_ident.
public void test_ident() throws Exception {
JSONScanner lexer = new JSONScanner("123");
lexer.nextIdent();
org.junit.Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
lexer.close();
}
use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.
the class JSONReaderTest_array_array method test_read_1.
public void test_read_1() throws Exception {
JSONReader reader = new JSONReader(new JSONScanner(text));
reader.startArray();
int count = 0;
while (reader.hasNext()) {
Object item = reader.readObject();
Assert.assertEquals(JSONArray.class, item.getClass());
count++;
}
Assert.assertEquals(10, count);
reader.endArray();
reader.close();
}
Aggregations