Search in sources :

Example 51 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_int method test_error_0.

public void test_error_0() {
    Exception error = null;
    try {
        JSONScanner lexer = new JSONScanner("--");
        lexer.scanNumber();
        lexer.intValue();
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 52 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_int method test_error_1.

public void test_error_1() {
    Exception error = null;
    try {
        String text = Integer.MAX_VALUE + "1234";
        JSONScanner lexer = new JSONScanner(text);
        lexer.scanNumber();
        lexer.intValue();
    } catch (Exception ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 53 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_isEOF method test_2.

public void test_2() throws Exception {
    JSONScanner lexer = new JSONScanner("1  ");
    lexer.nextToken();
    lexer.nextToken();
    Assert.assertTrue(lexer.token() == JSONToken.EOF);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 54 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_isEOF method test_1.

public void test_1() throws Exception {
    JSONScanner lexer = new JSONScanner("  ");
    lexer.nextToken();
    Assert.assertTrue(lexer.token() == JSONToken.EOF);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Example 55 with JSONScanner

use of com.alibaba.fastjson.parser.JSONScanner in project fastjson by alibaba.

the class JSONScannerTest_long method ftest_parse_long_1.

public void ftest_parse_long_1() throws Exception {
    System.out.println(System.currentTimeMillis());
    JSONScanner lexer = new JSONScanner(Long.toString(Long.MAX_VALUE));
    lexer.scanNumber();
    Assert.assertEquals(new Long(Long.MAX_VALUE), (Long) lexer.integerValue());
    Assert.assertEquals(Long.MAX_VALUE, lexer.longValue());
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner)

Aggregations

JSONScanner (com.alibaba.fastjson.parser.JSONScanner)179 JSONException (com.alibaba.fastjson.JSONException)37 SymbolTable (com.alibaba.fastjson.parser.SymbolTable)15 JSONReader (com.alibaba.fastjson.JSONReader)11 ParseException (java.text.ParseException)5 BigInteger (java.math.BigInteger)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Date (java.util.Date)3 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AccessibleObject (java.lang.reflect.AccessibleObject)1 BigDecimal (java.math.BigDecimal)1 AccessControlException (java.security.AccessControlException)1 Calendar (java.util.Calendar)1