Esempio n. 1
0
        static void testGetLongValue()
        {
            JSONParse parser = new JSONParse("12");

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