package com.fasterxml.jackson.core.json;

import java.io.*;

import com.fasterxml.jackson.core.*;

public class TestRootValues
    extends com.fasterxml.jackson.core.BaseTest
{
    private final JsonFactory JSON_F = new JsonFactory();

    public void testSimpleNumbers() throws Exception
    {
        _testSimpleNumbers(false);
        _testSimpleNumbers(true);
    }

    private void _testSimpleNumbers(boolean useStream) throws Exception
    {
        final String DOC = "1 2\t3\r4\n5\r\n6\r\n   7";
        JsonParser jp = useStream ?
                createParserUsingStream(JSON_F, DOC, "UTF-8")
                : createParserUsingReader(JSON_F, DOC);
        for (int i = 1; i <= 7; ++i) {
            assertToken(JsonToken.VALUE_NUMBER_INT, jp.nextToken());
            assertEquals(i, jp.getIntValue());
        }
        assertNull(jp.nextToken());
        jp.close();
    }

    public void testSimpleBooleans() throws Exception
    {
        _testSimpleBooleans(false);
        _testSimpleBooleans(true);
    }

    private void _testSimpleBooleans(boolean useStream) throws Exception
    {
        final String DOC = "true false\ttrue\rfalse\ntrue\r\nfalse\r\n   true";
        JsonParser jp = useStream ?
                createParserUsingStream(JSON_F, DOC, "UTF-8")
                : createParserUsingReader(JSON_F, DOC);
        boolean exp = true;
        for (int i = 1; i <= 7; ++i) {
            assertToken(exp ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE, jp.nextToken());
            exp = !exp;
        }
        assertNull(jp.nextToken());
        jp.close();
    }

    public void testSimpleWrites() throws Exception
    {
        _testSimpleWrites(false);
        _testSimpleWrites(true);
    }

    public void _testSimpleWrites(boolean useStream) throws Exception
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        StringWriter w = new StringWriter();
        JsonGenerator gen;

        if (useStream) {
            gen = JSON_F.createGenerator(out, JsonEncoding.UTF8);
        } else {
            gen = JSON_F.createGenerator(w);
        }
        gen.writeNumber(123);
        gen.writeString("abc");
        gen.writeBoolean(true);
        
        gen.close();
        out.close();
        w.close();

        // and verify
        String json = useStream ? out.toString("UTF-8") : w.toString();
        assertEquals("123 \"abc\" true", json);
    }
}

@@ -872,32 +872,751 @@
 close();%0A    %7D%0A%0A
+    public void testBrokeanNumber() throws Exception%0A    %7B%0A    %09_testBrokeanNumber(false);%0A    %09_testBrokeanNumber(true);%0A    %7D%0A%0A    private void _testBrokeanNumber(boolean useStream) throws Exception%0A    %7B%0A    %09JsonFactory f = new JsonFactory();%0A        final String DOC = %2214:89:FD:D3:E7:8C%22;%0A        JsonParser p = useStream ?%0A                createParserUsingStream(f, DOC, %22UTF-8%22)%0A                : createParserUsingReader(f, DOC);%0A        // Should fail, right away%0A        try %7B%0A        %09p.nextToken();%0A        %09fail(%22Ought to fail! Instead, got token: %22+p.getCurrentToken());%0A        %7D catch (JsonParseException e) %7B%0A        %09verifyException(e, %22unexpected character%22);%0A        %7D%0A        p.close();%0A    %7D%0A    %0A
     public void 

add a unit test for root-level value testing