mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-28 03:04:14 +00:00
Add unit tests for spaces and strings in table names
This commit is contained in:
parent
b919f5f446
commit
e2b212e0a5
2 changed files with 15 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue