Code example for JSONTokener

Methods: next, toString

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