/** * Test for {@link IOStreams#fromObjects(java.io.ObjectInput)} * * @throws IOException */ @Test public void testReadObjects() throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream objectOutput = new ObjectOutputStream(out); objectOutput.writeObject(Range.from(10, 90)); objectOutput.writeObject(Range.from(8, 40)); objectOutput.writeObject(Range.from(9, 10)); objectOutput.writeObject(Range.from(9, 12)); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); assertEquals( "[Range(10, 90), Range(8, 40), Range(9, 10), Range(9, 12)]", IOStreams.<Range<Integer>>fromObjects(new ObjectInputStream(in)).printString()); }
@Test public void testReadWords() { assertEquals( "this|is|line|1|this|is|line|2|this|is|line|three", IOStreams.fromWords(readable).joinStrings("|")); }
@Test public void testReadLines() { assertEquals( "this is line 1| this is line 2 | this is line three", IOStreams.fromLines(readable).joinStrings("|")); }