@Test
public void writeText() throws IOException {

    test(new CB() {
        public void run(boolean close) throws IOException {
            SW writer = new SW();
            StreamUtil.writeText(chars, writer, close);
            assertEquals(chars, writer.toString());
            writer.assertClosed(close);
            BAOS stream = new BAOS();
            StreamUtil.writeText(chars, stream, "GBK", close);
            assertArrayEquals(bytes, stream.toByteArray());
            stream.assertClosed(close);
        }
    });
}