@@ -0,0 +1,2793 @@
+package com.itranswarp.jsonstream;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.io.Reader;%0Aimport java.io.StringReader;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.junit.Test;%0A%0Apublic class CharReaderTest %7B%0A%0A    String createString(int length) %7B%0A        StringBuilder sb = new StringBuilder(length);%0A        String block = %22abcdefghi.%22;%0A        while (sb.length() %3C length) %7B%0A            sb.append(block);%0A        %7D%0A        return sb.substring(0, length);%0A    %7D%0A%0A    Reader createReader(int length) %7B%0A        return new StringReader(createString(length));%0A    %7D%0A%0A    @Test%0A    public void testHasMore() throws Exception %7B%0A        // only 1 char:%0A        CharReader reader = new CharReader(createReader(1));%0A        assertTrue(reader.hasMore());%0A        // consume 1 char:%0A        assertEquals('a', reader.next());%0A        assertFalse(reader.hasMore());%0A    %7D%0A%0A    @Test%0A    public void testNextAndPeek() throws Exception %7B%0A        // buffer_size * 2 + 1 chars:%0A        String input = createString(CharReader.BUFFER_SIZE * 2 + 1);%0A        CharReader reader = new CharReader(new StringReader(input));%0A        StringBuffer output = new StringBuffer();%0A        assertTrue(reader.hasMore());%0A        // consume buffer_size * 2 chars:%0A        for (int i = 0; i %3C CharReader.BUFFER_SIZE * 2; i++) %7B%0A            char ch = reader.peek();%0A            char nxt = reader.next();%0A            assertEquals(ch, nxt);%0A            output.append(ch);%0A        %7D%0A        assertTrue(reader.hasMore());%0A        // consume last char:%0A        char ch = reader.peek();%0A        char nxt = reader.next();%0A        assertEquals(ch, nxt);%0A        output.append(ch);%0A        assertFalse(reader.hasMore());%0A        // check:%0A        assertEquals(input, output.toString());%0A    %7D%0A%0A    @Test%0A    public void testEOF() throws Exception %7B%0A        List%3CInteger%3E lengths = Arrays.asList(0, 1, CharReader.BUFFER_SIZE - 1,%0A                CharReader.BUFFER_SIZE, CharReader.BUFFER_SIZE + 1,%0A                100 * CharReader.BUFFER_SIZE, 100 * CharReader.BUFFER_SIZE + 1);%0A        for (int length : lengths) %7B%0A            String input = createString(length);%0A            CharReader reader = new CharReader(new StringReader(input));%0A            StringBuilder output = new StringBuilder();%0A            // should consume all:%0A            for (int i = 0; i %3C length; i++) %7B%0A                assertTrue(reader.hasMore());%0A                output.append(reader.next());%0A            %7D%0A            assertFalse(reader.hasMore());%0A            try %7B%0A                reader.next();%0A                fail(%22Not caught ParseException!%22);%0A            %7D%0A            catch (JsonParseException e) %7B%0A                assertEquals(%22EOF%22, e.getMessage());%0A            %7D%0A            assertEquals(input, output.toString());%0A        %7D%0A    %7D%0A%0A%7D%0A

add CharReaderTest