Exemplo n.º 1
0
        static void testGetDoubleValue()
        {
            JSONParse parser = new JSONParse("12");

            System.assertEquals(12.0m, parser.getDoubleValue());
            parser = new JSONParse("12.5");
            System.assertEquals(12.5m, parser.getDoubleValue());
            parser = new JSONParse("\"12.5\"");
            System.assertEquals(12.5m, parser.getDoubleValue());
            parser = new JSONParse("1538783039073");
            System.assertEquals(1538783039073.0m, parser.getDoubleValue());
            try
            {
                parser = new JSONParse("[1,2,3]");
                parser.getDoubleValue();
                System.assert(false, "Node is not a valid Double, should have seen an exception about that.");
            }
            catch (JSONParse.InvalidConversionException e)
            {
                System.assertEquals("This value cannot be converted to a Double: [ 1, 2, 3 ]", e.getMessage());
            }
        }