mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-06-01 01:11:36 +00:00
Incorporated all of validator's valid tests into JUnit test suite
This commit is contained in:
parent
0bca81e5da
commit
b2888519fb
|
@ -31,30 +31,175 @@ public class BurntSushiValidTest {
|
|||
|
||||
@Test
|
||||
public void array_empty() throws Exception {
|
||||
runValidTest("array-empty");
|
||||
run("array-empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void array_nospaces() throws Exception {
|
||||
run("array-nospaces");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arrays_hetergeneous() throws Exception {
|
||||
runValidTest("arrays-hetergeneous");
|
||||
run("arrays-hetergeneous");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arrays_nested() throws Exception {
|
||||
run("arrays-nested");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arrays() throws Exception {
|
||||
run("arrays");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bool() throws Exception {
|
||||
run("bool");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void comments_everywhere() throws Exception {
|
||||
runValidTest("comments-everywhere");
|
||||
run("comments-everywhere");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void datetime() throws Exception {
|
||||
run("datetime");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void empty() throws Exception {
|
||||
run("empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void example() throws Exception {
|
||||
run("example");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void float_() throws Exception {
|
||||
run("float");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void implicit_and_explicit_after() throws Exception {
|
||||
run("implicit-and-explicit-after");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void implicit_and_explicit_before() throws Exception {
|
||||
run("implicit-and-explicit-before");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void implicit_groups() throws Exception {
|
||||
run("implicit-groups");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integer() throws Exception {
|
||||
run("integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void key_equals_nospace() throws Exception {
|
||||
run("key-equals-nospace");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void key_space() throws Exception {
|
||||
run("key-space");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void key_special_chars() throws Exception {
|
||||
runValidTest("key-special-chars");
|
||||
run("key-special-chars");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void long_float() throws Exception {
|
||||
run("long-float");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void long_integer() throws Exception {
|
||||
run("long-integer");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void string_empty() throws Exception {
|
||||
run("string-empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void string_escapes() throws Exception {
|
||||
run("string-escapes");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void string_simple() throws Exception {
|
||||
run("string-simple");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void string_with_pound() throws Exception {
|
||||
run("string-with-pound");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_array_implicit() throws Exception {
|
||||
runValidTest("table-array-implicit");
|
||||
run("table-array-implicit");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void table_array_many() throws Exception {
|
||||
run("table-array-many");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_array_nest() throws Exception {
|
||||
run("table-array-nest");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_array_one() throws Exception {
|
||||
run("table-array-one");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_empty() throws Exception {
|
||||
run("table-empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_sub_empty() throws Exception {
|
||||
run("table-sub-empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_whitespace() throws Exception {
|
||||
run("table-whitespace");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void table_with_pound() throws Exception {
|
||||
run("table-with-pound");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unicode_escape() throws Exception {
|
||||
run("unicode-escape");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unicode_literal() throws Exception {
|
||||
run("unicode-literal");
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws IOException {
|
||||
inputToml.close();
|
||||
|
@ -63,7 +208,7 @@ public class BurntSushiValidTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void runValidTest(String testName) {
|
||||
private void run(String testName) {
|
||||
inputToml = getClass().getResourceAsStream("burntsushi/valid/" + testName + ".toml");
|
||||
expectedJsonReader = new InputStreamReader(getClass().getResourceAsStream("burntsushi/valid/" + testName + ".json"));
|
||||
JsonElement expectedJson = new Gson().fromJson(expectedJsonReader, JsonElement.class);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"ints": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "integer", "value": "1"},
|
||||
{"type": "integer", "value": "2"},
|
||||
{"type": "integer", "value": "3"}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
ints = [1,2,3]
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"nest": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "array", "value": [
|
||||
{"type": "string", "value": "a"}
|
||||
]},
|
||||
{"type": "array", "value": [
|
||||
{"type": "string", "value": "b"}
|
||||
]}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
nest = [["a"], ["b"]]
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"ints": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "integer", "value": "1"},
|
||||
{"type": "integer", "value": "2"},
|
||||
{"type": "integer", "value": "3"}
|
||||
]
|
||||
},
|
||||
"floats": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "float", "value": "1.0"},
|
||||
{"type": "float", "value": "2.0"},
|
||||
{"type": "float", "value": "3.0"}
|
||||
]
|
||||
},
|
||||
"strings": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "string", "value": "a"},
|
||||
{"type": "string", "value": "b"},
|
||||
{"type": "string", "value": "c"}
|
||||
]
|
||||
},
|
||||
"dates": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "datetime", "value": "1987-07-05T17:45:00Z"},
|
||||
{"type": "datetime", "value": "1979-05-27T07:32:00Z"},
|
||||
{"type": "datetime", "value": "2006-06-01T11:00:00Z"}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
ints = [1, 2, 3]
|
||||
floats = [1.0, 2.0, 3.0]
|
||||
strings = ["a", "b", "c"]
|
||||
dates = [
|
||||
1987-07-05T17:45:00Z,
|
||||
1979-05-27T07:32:00Z,
|
||||
2006-06-01T11:00:00Z,
|
||||
]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"f": {"type": "bool", "value": "false"},
|
||||
"t": {"type": "bool", "value": "true"}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
t = true
|
||||
f = false
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"bestdayever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
bestdayever = 1987-07-05T17:45:00Z
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"best-day-ever": {"type": "datetime", "value": "1987-07-05T17:45:00Z"},
|
||||
"numtheory": {
|
||||
"boring": {"type": "bool", "value": "false"},
|
||||
"perfection": {
|
||||
"type": "array",
|
||||
"value": [
|
||||
{"type": "integer", "value": "6"},
|
||||
{"type": "integer", "value": "28"},
|
||||
{"type": "integer", "value": "496"}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
best-day-ever = 1987-07-05T17:45:00Z
|
||||
|
||||
[numtheory]
|
||||
boring = false
|
||||
perfection = [6, 28, 496]
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"pi": {"type": "float", "value": "3.14"},
|
||||
"negpi": {"type": "float", "value": "-3.14"}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
pi = 3.14
|
||||
negpi = -3.14
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"a": {
|
||||
"better": {"type": "integer", "value": "43"},
|
||||
"b": {
|
||||
"c": {
|
||||
"answer": {"type": "integer", "value": "42"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
[a.b.c]
|
||||
answer = 42
|
||||
|
||||
[a]
|
||||
better = 43
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"a": {
|
||||
"better": {"type": "integer", "value": "43"},
|
||||
"b": {
|
||||
"c": {
|
||||
"answer": {"type": "integer", "value": "42"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
[a]
|
||||
better = 43
|
||||
|
||||
[a.b.c]
|
||||
answer = 42
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"a": {
|
||||
"b": {
|
||||
"c": {
|
||||
"answer": {"type": "integer", "value": "42"}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
[a.b.c]
|
||||
answer = 42
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"answer": {"type": "integer", "value": "42"},
|
||||
"neganswer": {"type": "integer", "value": "-42"}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
answer = 42
|
||||
neganswer = -42
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"answer": {"type": "integer", "value": "42"}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
answer=42
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"a b": {"type": "integer", "value": "1"}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
a b = 1
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"longpi": {"type": "float", "value": "3.141592653589793"},
|
||||
"neglongpi": {"type": "float", "value": "-3.141592653589793"}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
longpi = 3.141592653589793
|
||||
neglongpi = -3.141592653589793
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"answer": {"type": "integer", "value": "9223372036854775807"},
|
||||
"neganswer": {"type": "integer", "value": "-9223372036854775808"}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
answer = 9223372036854775807
|
||||
neganswer = -9223372036854775808
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"answer": {
|
||||
"type": "string",
|
||||
"value": ""
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
answer = ""
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"backspace": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u0008 backspace character."
|
||||
},
|
||||
"tab": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u0009 tab character."
|
||||
},
|
||||
"newline": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u000A new line character."
|
||||
},
|
||||
"formfeed": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u000C form feed character."
|
||||
},
|
||||
"carriage": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u000D carriage return character."
|
||||
},
|
||||
"quote": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u0022 quote character."
|
||||
},
|
||||
"slash": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u002F slash character."
|
||||
},
|
||||
"backslash": {
|
||||
"type": "string",
|
||||
"value": "This string has a \u005C backslash character."
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
backspace = "This string has a \b backspace character."
|
||||
tab = "This string has a \t tab character."
|
||||
newline = "This string has a \n new line character."
|
||||
formfeed = "This string has a \f form feed character."
|
||||
carriage = "This string has a \r carriage return character."
|
||||
quote = "This string has a \" quote character."
|
||||
slash = "This string has a \/ slash character."
|
||||
backslash = "This string has a \\ backslash character."
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"answer": {
|
||||
"type": "string",
|
||||
"value": "You are not drinking enough whisky."
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
answer = "You are not drinking enough whisky."
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"pound": {"type": "string", "value": "We see no # comments here."},
|
||||
"poundcomment": {
|
||||
"type": "string",
|
||||
"value": "But there are # some comments here."
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
pound = "We see no # comments here."
|
||||
poundcomment = "But there are # some comments here." # Did I # mess you up?
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"people": [
|
||||
{
|
||||
"first_name": {"type": "string", "value": "Bruce"},
|
||||
"last_name": {"type": "string", "value": "Springsteen"}
|
||||
},
|
||||
{
|
||||
"first_name": {"type": "string", "value": "Eric"},
|
||||
"last_name": {"type": "string", "value": "Clapton"}
|
||||
},
|
||||
{
|
||||
"first_name": {"type": "string", "value": "Bob"},
|
||||
"last_name": {"type": "string", "value": "Seger"}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
[[people]]
|
||||
first_name = "Bruce"
|
||||
last_name = "Springsteen"
|
||||
|
||||
[[people]]
|
||||
first_name = "Eric"
|
||||
last_name = "Clapton"
|
||||
|
||||
[[people]]
|
||||
first_name = "Bob"
|
||||
last_name = "Seger"
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"albums": [
|
||||
{
|
||||
"name": {"type": "string", "value": "Born to Run"},
|
||||
"songs": [
|
||||
{"name": {"type": "string", "value": "Jungleland"}},
|
||||
{"name": {"type": "string", "value": "Meeting Across the River"}}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": {"type": "string", "value": "Born in the USA"},
|
||||
"songs": [
|
||||
{"name": {"type": "string", "value": "Glory Days"}},
|
||||
{"name": {"type": "string", "value": "Dancing in the Dark"}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
[[albums]]
|
||||
name = "Born to Run"
|
||||
|
||||
[[albums.songs]]
|
||||
name = "Jungleland"
|
||||
|
||||
[[albums.songs]]
|
||||
name = "Meeting Across the River"
|
||||
|
||||
[[albums]]
|
||||
name = "Born in the USA"
|
||||
|
||||
[[albums.songs]]
|
||||
name = "Glory Days"
|
||||
|
||||
[[albums.songs]]
|
||||
name = "Dancing in the Dark"
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"people": [
|
||||
{
|
||||
"first_name": {"type": "string", "value": "Bruce"},
|
||||
"last_name": {"type": "string", "value": "Springsteen"}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
[[people]]
|
||||
first_name = "Bruce"
|
||||
last_name = "Springsteen"
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"a": {}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
[a]
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"a": { "b": {} }
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
[a]
|
||||
[a.b]
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"valid key": {}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
[valid key]
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"key#group": {
|
||||
"answer": {"type": "integer", "value": "42"}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
[key#group]
|
||||
answer = 42
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"answer": {"type": "string", "value": "\u03B4"}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
answer = "\u03B4"
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"answer": {"type": "string", "value": "δ"}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
answer = "δ"
|
Loading…
Reference in a new issue