use of siena.Json in project siena by mandubian.
the class JsonTest method testAddAt.
public void testAddAt() {
Json json = Json.list(1, 3);
json.addAt(1, 2);
assertEquals(3, json.size());
assertEquals(1, json.at(0).asInt());
assertEquals(2, json.at(1).asInt());
assertEquals(3, json.at(2).asInt());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testRemoveAt.
public void testRemoveAt() {
Json json = Json.list(1, 2, 3);
json.removeAt(1);
assertEquals(2, json.size());
assertEquals(1, json.at(0).asInt());
assertEquals(3, json.at(1).asInt());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testBuildEmptyList.
public void testBuildEmptyList() {
Json json = Json.list();
assertTrue(json.isList());
assertTrue(json.isEmpty());
assertFalse(json.isBoolean());
assertFalse(json.isMap());
assertFalse(json.isNumber());
assertFalse(json.isString());
assertEquals(0, json.size());
assertEquals("[]", json.toString());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method sumInteger.
public void sumInteger() {
Json map1 = Json.map().put("a", 1);
map1.sumInteger("a", 2);
assertEquals(3, map1.get("a").asInt());
map1 = Json.map();
map1.sumInteger("a", 2);
assertEquals(2, map1.get("a").asInt());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testSortedMap2.
public void testSortedMap2() {
Json json = Json.sortedMap().put("2009-01", 1).put("2008-10", 400);
Iterator<String> keys = json.keys().iterator();
assertEquals("2008-10", keys.next());
assertEquals("2009-01", keys.next());
}
Aggregations