public void testParseInt() throws Exception
    {
        assertTrue(0 == NumberParser.parseInt(new byte[] { '0' }, 0, 1, 10));
        assertTrue(1 == NumberParser.parseInt(new byte[] { '1' }, 0, 1, 10));
        assertTrue(-1 == NumberParser.parseInt(new byte[] { '-', '1' }, 0, 2, 10));

        final LinkedBuffer lb = LinkedBuffer.allocate(256);
        final WriteSession session = new WriteSession(lb);

        assertTrue(lb == StringSerializer.writeInt(
                Integer.MAX_VALUE, session, session.tail));

        assertTrue(Integer.MAX_VALUE == NumberParser.parseInt(
                session.toByteArray(), 0, session.size, 10));

        session.clear();

        assertTrue(lb == StringSerializer.writeInt(
                Integer.MAX_VALUE - 1, session, session.tail));

        assertTrue(Integer.MAX_VALUE - 1 == NumberParser.parseInt(
                session.toByteArray(), 0, session.size, 10));

        session.clear();

        assertTrue(lb == StringSerializer.writeInt(
                Integer.MIN_VALUE, session, session.tail));

        assertTrue(Integer.MIN_VALUE == NumberParser.parseInt(
                session.toByteArray(), 0, session.size, 10));

        session.clear();

        assertTrue(lb == StringSerializer.writeInt(
                Integer.MIN_VALUE + 1, session, session.tail));

        assertTrue(Integer.MIN_VALUE + 1 == NumberParser.parseInt(
                session.toByteArray(), 0, session.size, 10));

    }
Test for parsing numbers from raw ascii buffers.

@author David Yu
@created Dec 4, 2010
protostuff-api/src/test/java/io/protostuff/NumberParserTest.java