mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-28 19:24:15 +00:00
Added test cases for iterating over empty TOML and key containing empty
list
This commit is contained in:
parent
1b2aa582d9
commit
0cea9ae187
1 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue