Code example for JSONTokener

Methods: next, toString

0
    /** 
     * Tests the next method using line increments on carriage return and new line. 
     */ 
    public void testNext_LineIncrementsOnCarriageReturnAndNewLine() 
    { 
        jsontokener = new JSONTokener("abc\r\n123");
        try 
        { 
            jsontokener.next();//a
            jsontokener.next();//b
            jsontokener.next();//c
            assertEquals(" at 3 [character 4 line 1]",jsontokener.toString());
            jsontokener.next();//\r
            jsontokener.next();//\n
            assertEquals(" at 5 [character 0 line 2]",jsontokener.toString());
        } catch (JSONException e)
        { 
            fail(e.toString());
        } 
    }