Add unit tests for spaces and strings in table names

This commit is contained in:
Moandji Ezana 2016-08-04 12:49:27 +02:00
parent b919f5f446
commit e2b212e0a5
2 changed files with 15 additions and 1 deletions

View file

@ -163,7 +163,7 @@ class Identifier {
}
} else if (Character.isWhitespace(c)) {
char prev = trimmed.charAt(i - 1);
if (!Character.isWhitespace(prev) && prev != '.' && prev != '"') {
if (!Character.isWhitespace(prev) && prev != '.') {
charAllowed = false;
dotAllowed = true;
quoteAllowed = true;

View file

@ -78,6 +78,13 @@ public class TableTest {
assertEquals("b", toml.getString("target.\"cfg(unix)\".dependencies.b"));
}
@Test
public void should_accept_table_name_part_with_whitespace_and_basic_string() {
Toml toml = new Toml().read("[ target . \"cfg (unix)\" . dependencies ]\nb = 'b'");
assertEquals("b", toml.getString("target.\"cfg (unix)\".dependencies.b"));
}
@Test
public void should_accept_table_name_with_literal_string() {
Toml toml = new Toml().read("['a']\nb = 'b'");
@ -91,6 +98,13 @@ public class TableTest {
assertEquals("b", toml.getString("target.'cfg(unix)'.dependencies.b"));
}
@Test
public void should_accept_table_name_part_with_whitespace_and_literal_string() {
Toml toml = new Toml().read("[target . 'cfg(unix)' . dependencies]\nb = 'b'");
assertEquals("b", toml.getString("target.'cfg(unix)'.dependencies.b"));
}
@Test
public void should_return_null_when_navigating_to_missing_value() throws Exception {