package com.wizzardo.tools.json;

import org.junit.Assert;
import org.junit.Test;

/**
 * Created by wizzardo on 14.09.15.
 */
public class JsonParseBytesTest {
    static class TestBinder implements JsonBinder {
        Object value;

        @Override
        public void add(Object value) {
            this.value = value;
        }

        @Override
        public void add(JsonItem value) {
            this.value = value;
        }

        @Override
        public Object getObject() {
            return null;
        }

        @Override
        public JsonBinder getObjectBinder() {
            return null;
        }

        @Override
        public JsonBinder getArrayBinder() {
            return null;
        }

        @Override
        public void setTemporaryKey(String key) {

        }

        @Override
        public JsonFieldSetter getFieldSetter() {
            return null;
        }
    }

    @Test
    public void parse_number_1() {
        byte[] data = "123,".getBytes();

        TestBinder binder = new TestBinder();
        JsonUtils.parseNumber(binder, data, 0, data.length, new NumberParsingContext());

        Assert.assertEquals(123l, binder.value);
    }
}

@@ -1189,11 +1189,923 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void parse_number_2() %7B%0A        byte%5B%5D data = %22123.1,%22.getBytes();%0A%0A        TestBinder binder = new TestBinder();%0A        JsonUtils.parseNumber(binder, data, 0, data.length, new NumberParsingContext());%0A%0A        Assert.assertEquals(123.1, binder.value);%0A    %7D%0A%0A    @Test%0A    public void parse_number_3() %7B%0A        byte%5B%5D data = %22123,%22.getBytes();%0A%0A        TestBinder binder = new TestBinder();%0A        JsonUtils.parseNumber(binder, data, 0, data.length, new NumberParsingContext());%0A        Assert.assertEquals(123l, binder.value);%0A%0A        data = %221234%7D%22.getBytes();%0A        JsonUtils.parseNumber(binder, data, 0, data.length, new NumberParsingContext());%0A        Assert.assertEquals(1234l, binder.value);%0A%0A        data = %2212345%5D%22.getBytes();%0A        JsonUtils.parseNumber(binder, data, 0, data.length, new NumberParsingContext());%0A        Assert.assertEquals(12345l, binder.value);%0A    %7D
 %0A%7D%0A

add tests