Java 类com.alibaba.fastjson.parser.deserializer.NumberDeserializer 实例源码

项目:GitHub    文件:DoubleDeserializerTest.java   
public void test_bigdecimal() throws Exception {
    Assert.assertEquals(0, JSON.parseObject("0", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("0.0", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("'0'", Double.class).intValue());
    Assert.assertEquals(0, JSON.parseObject("'0'", double.class).intValue());
    Assert.assertEquals(null, JSON.parseObject("null", Double.class));

    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
    Assert.assertEquals(null, NumberDeserializer.instance.deserialze(parser, null, null));
    Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
}
项目:GitHub    文件:FastMatchCheckTest.java   
public void test_match() throws Exception {
    Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
    Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
    Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
    Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
    Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
    Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
}
项目:GitHub    文件:TestNull.java   
public void test_byte() throws Exception {
    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

    Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
}
项目:GitHub    文件:TestNull.java   
public void test_short() throws Exception {
    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

    Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
}
项目:GitHub    文件:TestNull.java   
public void test_null() throws Exception {
    DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

    Assert.assertNull(new NumberDeserializer().deserialze(parser, null, null));
}