Added test cases for iterating over empty TOML and key containing empty

list
This commit is contained in:
moandji.ezana 2015-06-24 00:49:41 +02:00
parent 1b2aa582d9
commit 0cea9ae187

View file

@ -3,6 +3,7 @@ package com.moandjiezana.toml;
import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
@ -45,6 +46,16 @@ public class IterationTest {
assertThat((List<String>) entry.getValue(), contains("a", "b", "c"));
}
@Test
@SuppressWarnings("unchecked")
public void should_iterate_over_empty_list() throws Exception {
Toml toml = new Toml().parse("list = []");
Map.Entry<String, Object> entry = toml.entrySet().iterator().next();
assertEquals("list", entry.getKey());
assertThat((List<String>) entry.getValue(), empty());
}
@Test
public void should_iterate_over_table() throws Exception {
Toml toml = new Toml().parse(file("table"));
@ -91,6 +102,13 @@ public class IterationTest {
entry.setValue(2L);
}
@Test
public void should_not_iterate_over_empty_toml() throws Exception {
Toml toml = new Toml().parse("");
assertThat(toml.entrySet(), empty());
}
private File file(String name) {
return Utils.file(getClass(), "/IteratorTest/" + name);
}