static void checkAscii(CharSequence str) throws Exception
    {
        byte[] builtin = str.toString().getBytes("UTF-8");

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        LinkedBuffer lb = new LinkedBuffer(BUF_SIZE);
        WriteSession session = new WriteSession(lb, out);

        StreamedStringSerializer.writeAscii(str, session, lb);
        LinkedBuffer.writeTo(out, lb);

        assertTrue(builtin.length == session.size);

        byte[] buffered = out.toByteArray();

        assertTrue(builtin.length == buffered.length);

        String strBuiltin = new String(builtin, "ASCII");
        String strBuffered = new String(buffered, "ASCII");

        assertEquals(strBuiltin, strBuffered);
        print(strBuiltin);
        print("len: " + builtin.length);
    }
Tests for streaming UTF-8 Encoding

@author David Yu
@created Sep 18, 2010
protostuff-api/src/test/java/io/protostuff/StreamedStringSerializerTest.java