mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Added test to confirm that out-of-order table arrays are supported.
cf. https://github.com/toml-lang/toml/issues/252
This commit is contained in:
parent
ccca314649
commit
16c8b409e6
2 changed files with 25 additions and 0 deletions
|
@ -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<Toml> tables = toml.getTables("product");
|
||||
List<Toml> 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 {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
[[product]]
|
||||
price = 9.99
|
||||
|
||||
[[employee]]
|
||||
name = "Marinus van der Lubbe"
|
||||
|
||||
[[product]]
|
||||
type = "ZX80"
|
Loading…
Reference in a new issue