Changed key group to table in tests

This commit is contained in:
moandji.ezana 2014-04-06 22:55:56 +02:00
parent bc78ff64b5
commit 5c3c868682
6 changed files with 23 additions and 23 deletions

View file

@ -69,8 +69,8 @@ public class RealWorldTest {
}
@Test
public void should_allow_keys_with_same_name_in_different_groups() throws Exception {
Toml toml = new Toml().parse(new File(getClass().getResource("should_allow_keys_with_same_name_in_different_groups.toml").getFile()));
public void should_allow_keys_with_same_name_in_different_tables() throws Exception {
Toml toml = new Toml().parse(new File(getClass().getResource("should_allow_keys_with_same_name_in_different_tables.toml").getFile()));
assertTrue(toml.getTable("siteInfo.local.sh").getBoolean("enable"));
assertFalse(toml.getTable("siteInfo.localMobile.sh").getBoolean("enable"));

View file

@ -45,14 +45,14 @@ public class TomlDefaultsTest {
}
@Test
public void should_fall_back_to_key_group() throws Exception {
public void should_fall_back_to_table() throws Exception {
Toml toml = new Toml(defaultToml).parse("");
assertEquals("a", toml.getTable("group").getString("a"));
}
@Test
public void should_fall_back_to_key_within_key_group() throws Exception {
public void should_fall_back_to_key_within_table() throws Exception {
Toml toml = new Toml(defaultToml).parse("[group]\nb=1");
assertEquals(1, toml.getTable("group").getLong("b").intValue());

View file

@ -78,7 +78,7 @@ public class TomlTest {
}
@Test
public void should_get_key_group() throws Exception {
public void should_get_table() throws Exception {
Toml toml = new Toml().parse("[group]\nkey = \"value\"");
Toml group = toml.getTable("group");
@ -94,28 +94,28 @@ public class TomlTest {
}
@Test
public void should_get_value_for_multi_key_with_no_parent_key_group() throws Exception {
public void should_get_value_for_multi_key_with_no_parent_table() throws Exception {
Toml toml = new Toml().parse("[group.sub]\nkey = \"value\"");
assertEquals("value", toml.getString("group.sub.key"));
}
@Test
public void should_get_key_group_for_multi_key() throws Exception {
public void should_get_table_for_multi_key() throws Exception {
Toml toml = new Toml().parse("[group]\nother=1\n[group.sub]\nkey = \"value\"");
assertEquals("value", toml.getTable("group.sub").getString("key"));
}
@Test
public void should_get_key_group_for_multi_key_with_no_parent_key_group() throws Exception {
public void should_get_table_for_multi_key_with_no_parent_table() throws Exception {
Toml toml = new Toml().parse("[group.sub]\nkey = \"value\"");
assertEquals("value", toml.getTable("group.sub").getString("key"));
}
@Test
public void should_get_value_from_key_group_with_sub_key_group() throws Exception {
public void should_get_value_from_table_with_sub_table() throws Exception {
Toml toml = new Toml().parse("[a.b]\nc=1\n[a]\nd=2");
assertEquals(2, toml.getLong("a.d").intValue());
@ -151,7 +151,7 @@ public class TomlTest {
}
@Test
public void should_support_numbers_in_key_group_names() throws Exception {
public void should_support_numbers_in_table_names() throws Exception {
Toml toml = new Toml().parse("[group1]\na = 1");
assertEquals(1, toml.getLong("group1.a").intValue());
@ -172,14 +172,14 @@ public class TomlTest {
}
@Test
public void should_support_underscores_in_key_group_names() throws Exception {
public void should_support_underscores_in_table_names() throws Exception {
Toml toml = new Toml().parse("[group_a]\na = 1");
assertEquals(1, toml.getLong("group_a.a").intValue());
}
@Test
public void should_support_sharp_sign_in_key_group_names() throws Exception {
public void should_support_sharp_sign_in_table_names() throws Exception {
Toml toml = new Toml().parse("[group#]\nkey=1");
assertEquals(1, toml.getLong("group#.key").intValue());
@ -229,7 +229,7 @@ public class TomlTest {
}
@Test(expected = IllegalStateException.class)
public void should_fail_when_key_is_overwritten_by_key_group() {
public void should_fail_when_key_is_overwritten_by_table() {
new Toml().parse("[a]\nb=1\n[a.b]\nc=2");
}
@ -239,13 +239,13 @@ public class TomlTest {
}
@Test(expected = IllegalStateException.class)
public void should_fail_when_key_group_defined_twice() throws Exception {
public void should_fail_when_table_defined_twice() throws Exception {
new Toml().parse("[a]\nb=1\n[a]\nc=2");
}
@Ignore
@Test(expected = IllegalStateException.class)
public void should_fail_when_illegal_characters_after_key_group() throws Exception {
public void should_fail_when_illegal_characters_after_table() throws Exception {
new Toml().parse("[error] if you didn't catch this, your parser is broken");
}
}

View file

@ -3,16 +3,16 @@ package com.moandjiezana.toml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import com.moandjiezana.toml.testutils.TableAsMap;
import com.moandjiezana.toml.testutils.TomlTables;
import com.moandjiezana.toml.testutils.TomlPrimitives;
import java.io.File;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
import com.moandjiezana.toml.testutils.TableAsMap;
import com.moandjiezana.toml.testutils.TomlPrimitives;
import com.moandjiezana.toml.testutils.TomlTables;
public class TomlToClassTest {
@Test
@ -34,8 +34,8 @@ public class TomlToClassTest {
}
@Test
public void should_convert_key_groups() throws Exception {
String fileName = "should_convert_key_groups.toml";
public void should_convert_tables() throws Exception {
String fileName = "should_convert_tables.toml";
Toml toml = new Toml().parse(file(fileName));
TomlTables tomlTables = toml.to(TomlTables.class);
@ -46,7 +46,7 @@ public class TomlToClassTest {
@Test
public void should_use_defaults() throws Exception {
Toml defaults = new Toml().parse(file("should_convert_key_groups.toml"));
Toml defaults = new Toml().parse(file("should_convert_tables.toml"));
Toml toml = new Toml(defaults).parse("");
TomlTables tomlTables = toml.to(TomlTables.class);
@ -63,7 +63,7 @@ public class TomlToClassTest {
}
@Test
public void should_convert_key_group_as_map() throws Exception {
public void should_convert_table_as_map() throws Exception {
TableAsMap tableAsMap = new Toml().parse("[group]\nkey=\"value\"").to(TableAsMap.class);
assertEquals("value", tableAsMap.group.get("key"));