Fmt { public void format() throws IOException { format(in.lines(), out); } Fmt(BufferedReader inFile, PrintWriter outFile);  Fmt(PrintWriter out);  Fmt(BufferedReader file);  Fmt(String fname);  Fmt(InputStream file); static void main(String[] av); void format(); static void format(Stream<String> s, PrintWriter out); static final int COLWIDTH; }
@Test public void testEmpty() throws Exception { construct(""); fmt.format(); String[] string = outToStrings(outBytes.toString()); assertEquals(1, string.length); }
@Test public void testSmall() throws Exception { construct("Once\nupon\na\ntime\n..."); fmt.format(); String[] expected = { "Once upon a time ... " }; compareStringArrays(expected, outToStrings(outBytes.toString())); }
@Test public void testBlanks() throws Exception { construct("Once\n\ntwice"); fmt.format(); String[] expected = { "Once ", "", "twice " }; String[] actual = outToStrings(outBytes.toString()); compareStringArrays(expected, actual); }
@Test public void testLonger() throws Exception { construct(longInput); fmt.format(); String[] outStrings = outToStrings(outBytes.toString()); compareStringArrays(longExpected, outStrings); }
@Test public void testStream() throws Exception { String[] input = { "Hello,", "World" }; Fmt.format(Stream.of(input), out); compareStringArrays(new String[]{"Hello, World "}, outToStrings(outBytes.toString())); }