Package com.alibaba.json.bvt.parser

Source Code of com.alibaba.json.bvt.parser.JSONReaderTest_array_array

package com.alibaba.json.bvt.parser;

import java.io.StringReader;

import junit.framework.TestCase;

import org.junit.Assert;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.parser.JSONScanner;

public class JSONReaderTest_array_array extends TestCase {

    String text = "[[],[],[],[],[], [],[],[],[],[]]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            Object item = reader.readObject();
            Assert.assertEquals(JSONArray.class, item.getClass());
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();
    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            Object item = reader.readObject();
            Assert.assertEquals(JSONArray.class, item.getClass());
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();
    }
}
TOP

Related Classes of com.alibaba.json.bvt.parser.JSONReaderTest_array_array

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.