@@ -0,0 +1,2250 @@
+package hdm.pk070.jscheme.reader;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.io.ByteArrayInputStream;%0Aimport java.util.Objects;%0A%0Aimport static org.hamcrest.Matchers.*;%0Aimport static org.junit.Assert.*;%0A%0A/**%0A * @author patrick.kleindienst%0A */%0Apublic class SchemeCharacterReaderTest %7B%0A%0A    private SchemeCharacterReader schemeCharacterReader;%0A%0A    private String testInput = %22foobar%22;%0A    private String inputWithSpace = %22 Leading space character%22;%0A    private String inputWithTab = %22%5CtLeading tab character%22;%0A    private String inputWithNewLine = %22%5CnLeading new line character%22;%0A    private String inputWithCarriageReturn = %22%5CrLeading carriage return character%22;%0A%0A%0A    @Test%0A    public void testCreateInstance() %7B%0A        schemeCharacterReader = SchemeCharacterReader.withInputStream(new ByteArrayInputStream%0A                (testInput.getBytes()));%0A%0A        assertThat(schemeCharacterReader, notNullValue());%0A    %7D%0A%0A    @Test(expected = NullPointerException.class)%0A    public void testThrowExceptionOnNullStream() %7B%0A        SchemeCharacterReader.withInputStream(null);%0A    %7D%0A%0A    @Test%0A    public void testNextCharIs() %7B%0A        schemeCharacterReader = SchemeCharacterReader.withInputStream(new ByteArrayInputStream(testInput.getBytes()));%0A        boolean isRightChar = schemeCharacterReader.nextCharIs(testInput.charAt(0));%0A%0A        assertThat(isRightChar, equalTo(true));%0A    %7D%0A%0A    @Test%0A    public void testNextNonWhitespaceChar() %7B%0A        assertWhitespaceIsSkipped(inputWithSpace);%0A        assertWhitespaceIsSkipped(inputWithTab);%0A        assertWhitespaceIsSkipped(inputWithNewLine);%0A        assertWhitespaceIsSkipped(inputWithCarriageReturn);%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A        if (Objects.nonNull(schemeCharacterReader)) %7B%0A            schemeCharacterReader.shutdown();%0A        %7D%0A    %7D%0A%0A    private void assertWhitespaceIsSkipped(String whitespaceString) %7B%0A        schemeCharacterReader = SchemeCharacterReader.withInputStream(new ByteArrayInputStream(whitespaceString%0A                .getBytes()));%0A        char nextNonWhitespaceChar = schemeCharacterReader.nextNonWhitespaceChar();%0A%0A        assertThat(nextNonWhitespaceChar, equalTo(whitespaceString.trim().charAt(0)));%0A    %7D%0A%7D%0A

Test cases for SchemeCharacterReader