2009-05-14 22:18:45 +02:00
|
|
|
package com.google.gson;
|
|
|
|
|
2009-08-12 23:01:42 +02:00
|
|
|
import java.util.Iterator;
|
|
|
|
|
2009-05-14 22:18:45 +02:00
|
|
|
import junit.framework.TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unit tests for {@link JsonParserAsync}
|
|
|
|
*
|
|
|
|
* @author Inderjeet Singh
|
|
|
|
*/
|
|
|
|
public class JsonParserAsyncTest extends TestCase {
|
|
|
|
|
|
|
|
public void testParseTwoStrings() {
|
|
|
|
JsonParserAsync parser = new JsonParserAsync("'one' 'two'");
|
2009-08-12 23:01:42 +02:00
|
|
|
String actualOne = parser.next().getAsString();
|
2009-05-14 22:18:45 +02:00
|
|
|
assertEquals("one", actualOne);
|
2009-08-12 23:01:42 +02:00
|
|
|
String actualTwo = parser.next().getAsString();
|
2009-05-14 22:18:45 +02:00
|
|
|
assertEquals("two", actualTwo);
|
|
|
|
}
|
2009-08-12 23:01:42 +02:00
|
|
|
|
|
|
|
public void testIterator() {
|
|
|
|
Iterator<JsonElement> parser = new JsonParserAsync("'one' 'two'");
|
|
|
|
assertTrue(parser.hasNext());
|
|
|
|
assertEquals("one", parser.next().getAsString());
|
|
|
|
assertTrue(parser.hasNext());
|
|
|
|
assertEquals("two", parser.next().getAsString());
|
|
|
|
assertFalse(parser.hasNext());
|
|
|
|
}
|
2009-05-14 22:18:45 +02:00
|
|
|
}
|