mirror of
https://github.com/plexusorg/toml4j.git
synced 2025-08-04 03:26:01 +00:00
Read empty string followed by new line.
Fix #3 https://github.com/mwanji/toml4j/issues/3
This commit is contained in:
parent
14ec051e22
commit
e36b8dbe8e
3 changed files with 14 additions and 17 deletions
|
@ -114,7 +114,7 @@ class TomlParser extends BaseParser<Object> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rule AnyCharacter() {
|
Rule AnyCharacter() {
|
||||||
return Sequence(ANY, pushCharacter(match()));
|
return Sequence(TestNot(NewLine()), ANY, pushCharacter(match()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressNode
|
@SuppressNode
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.moandjiezana.toml;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class EmptyStringTest {
|
|
||||||
@Test
|
|
||||||
public void should_parse_multiple_sections() {
|
|
||||||
Toml toml = new Toml().parse("str1 = \"\"\nstr2 = \"Hello, world!\"");
|
|
||||||
assertEquals("", toml.getString("str1"));
|
|
||||||
assertEquals("Hello, world!", toml.getString("str2"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,6 +25,18 @@ public class TomlTest {
|
||||||
assertEquals("a", toml.getString("a"));
|
assertEquals("a", toml.getString("a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_get_empty_string() {
|
||||||
|
Toml toml = new Toml().parse("a = \"\"");
|
||||||
|
assertEquals("", toml.getString("a"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void should_get_empty_string_with_trailing_new_line() {
|
||||||
|
Toml toml = new Toml().parse("a = \"\"\n");
|
||||||
|
assertEquals("", toml.getString("a"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_get_number() throws Exception {
|
public void should_get_number() throws Exception {
|
||||||
Toml toml = new Toml().parse("b = 1001");
|
Toml toml = new Toml().parse("b = 1001");
|
||||||
|
@ -226,7 +238,7 @@ public class TomlTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void should_support_unicode_characters_in_strings() throws Exception {
|
public void should_support_unicode_characters_in_strings() throws Exception {
|
||||||
Toml toml = new Toml().parse("key=\"\\u00B1\"");
|
Toml toml = new Toml().parse("key=\"\\u00B1\"\n");
|
||||||
|
|
||||||
assertEquals("±", toml.getString("key"));
|
assertEquals("±", toml.getString("key"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue