@Test
public void testWriteTo() throws IOException {

	UnsyncCharArrayWriter unsyncCharArrayWriter =
		new UnsyncCharArrayWriter();
	unsyncCharArrayWriter.write("abcd");
	CharBuffer charBuffer = CharBuffer.allocate(2);
	int length = unsyncCharArrayWriter.writeTo(charBuffer);
	Assert.assertEquals(2, length);
	Assert.assertEquals(2, charBuffer.position());
	Assert.assertEquals(2, charBuffer.limit());
	charBuffer.position(0);
	Assert.assertEquals("ab", charBuffer.toString());
	charBuffer = CharBuffer.allocate(5);
	length = unsyncCharArrayWriter.writeTo(charBuffer);
	Assert.assertEquals(4, length);
	Assert.assertEquals(4, charBuffer.position());
	Assert.assertEquals(5, charBuffer.limit());
	charBuffer.position(0);
	charBuffer.limit(4);
	Assert.assertEquals("abcd", charBuffer.toString());
	charBuffer = CharBuffer.allocate(0);
	length = unsyncCharArrayWriter.writeTo(charBuffer);
	Assert.assertEquals(0, length);
	Assert.assertEquals(0, charBuffer.position());
	Assert.assertEquals(0, charBuffer.limit());
	charBuffer.position(0);
	Assert.assertEquals("", charBuffer.toString());
	ByteArrayOutputStream byteArrayOutputStream =
		new ByteArrayOutputStream();
	length = unsyncCharArrayWriter.writeTo(
		byteArrayOutputStream, StringPool.UTF8);
	Assert.assertEquals(4, length);
	Assert.assertEquals(4, byteArrayOutputStream.size());
	Assert.assertTrue(
		Arrays.equals(
			"abcd".getBytes(), byteArrayOutputStream.toByteArray()));
	StringWriter stringWriter = new StringWriter();
	length = unsyncCharArrayWriter.writeTo(stringWriter);
	Assert.assertEquals(4, length);
	Assert.assertEquals("abcd", stringWriter.toString());
}