diff --git a/src/test/java/com/moandjiezana/toml/TableArrayTest.java b/src/test/java/com/moandjiezana/toml/TableArrayTest.java index 095e17c..b41a6ca 100644 --- a/src/test/java/com/moandjiezana/toml/TableArrayTest.java +++ b/src/test/java/com/moandjiezana/toml/TableArrayTest.java @@ -1,7 +1,10 @@ package com.moandjiezana.toml; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; import java.io.File; import java.util.List; @@ -29,6 +32,20 @@ public class TableArrayTest { assertEquals(284758393L, products.get(2).getLong("sku").longValue()); assertEquals("gray", products.get(2).getString("color")); } + + @Test + public void should_parse_table_array_out_of_order() throws Exception { + Toml toml = new Toml().parse(file("should_parse_table_array_out_of_order")); + + List tables = toml.getTables("product"); + List employees = toml.getTables("employee"); + + assertThat(tables, hasSize(2)); + assertThat(tables.get(0).getDouble("price"), equalTo(9.99)); + assertThat(tables.get(1).getString("type"), equalTo("ZX80")); + assertThat(employees, hasSize(1)); + assertThat(employees.get(0).getString("name"), equalTo("Marinus van der Lubbe")); + } @Test public void should_parse_nested_table_arrays() throws Exception { diff --git a/src/test/java/com/moandjiezana/toml/should_parse_table_array_out_of_order.toml b/src/test/java/com/moandjiezana/toml/should_parse_table_array_out_of_order.toml new file mode 100644 index 0000000..7688f6b --- /dev/null +++ b/src/test/java/com/moandjiezana/toml/should_parse_table_array_out_of_order.toml @@ -0,0 +1,8 @@ +[[product]] +price = 9.99 + +[[employee]] +name = "Marinus van der Lubbe" + +[[product]] +type = "ZX80"