package com.puppycrawl.tools.checkstyle;

import junit.framework.TestCase;

import java.io.IOException;

public class StringArrayReaderTest
    extends TestCase
{
    public StringArrayReaderTest(String name)
    {
        super(name);
    }

    public void testClose()
    {
        final StringArrayReader o = new StringArrayReader(new String[] {""});
        assertNotNull(o);
        o.close();
        try {
            o.read();
            fail();
        }
        catch (IOException e) {
        }
    }

    public void testLineBreakSingleChar()
    {
        final StringArrayReader o = new StringArrayReader(new String[] {"a", "bc"});
        try {
            int a = o.read();
            assertEquals('a', a);
            int nl1 = o.read();
            assertEquals('\n', nl1);
            int b = o.read();
            assertEquals('b', b);
            int c = o.read();
            assertEquals('c', c);
            int nl2 = o.read();
            assertEquals('\n', nl2);
            int eof = o.read();
            assertEquals(-1, eof);
        }
        catch (IOException ex) {
        }
    }
}

@@ -583,32 +583,44 @@
 gArrayReader o =
+%0A           
  new StringArray
@@ -1122,11 +1122,712 @@
  %7D%0A    %7D
+%0A%0A    public void testLineBreakCharArray()%0A    %7B%0A        final StringArrayReader o =%0A            new StringArrayReader(new String%5B%5D %7B%22a%22, %22bc%22%7D);%0A        try %7B%0A            char%5B%5D a = new char%5B1%5D;%0A            int count = o.read(a, 0, 1);%0A            assertEquals(1, count);%0A            assertEquals('a', a%5B0%5D);%0A            int nl1 = o.read();%0A            assertEquals('%5Cn', nl1);%0A            int b = o.read();%0A            assertEquals('b', b);%0A            int c = o.read();%0A            assertEquals('c', c);%0A            int nl2 = o.read();%0A            assertEquals('%5Cn', nl2);%0A            int eof = o.read();%0A            assertEquals(-1, eof);%0A        %7D%0A        catch (IOException ex) %7B%0A        %7D%0A    %7D
 %0A%7D%0A

improve test coverage of StringArrayReader