aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/tests/datetime.rs2
-rw-r--r--test-suite/tests/invalid/string-bad-line-ending-escape.toml3
-rw-r--r--test-suite/tests/serde.rs60
-rw-r--r--test-suite/tests/valid/multiline-string.json8
-rw-r--r--test-suite/tests/valid/multiline-string.toml11
5 files changed, 78 insertions, 6 deletions
diff --git a/test-suite/tests/datetime.rs b/test-suite/tests/datetime.rs
index f3b77e3..a0064fb 100644
--- a/test-suite/tests/datetime.rs
+++ b/test-suite/tests/datetime.rs
@@ -21,6 +21,8 @@ fn times() {
good("1997-09-09T09:09:09-09:09");
good("1997-09-09T09:09:09");
good("1997-09-09");
+ dogood("1997-09-09 ", "1997-09-09");
+ dogood("1997-09-09 # comment", "1997-09-09");
good("09:09:09");
good("1997-09-09T09:09:09.09Z");
good("1997-09-09T09:09:09.09+09:09");
diff --git a/test-suite/tests/invalid/string-bad-line-ending-escape.toml b/test-suite/tests/invalid/string-bad-line-ending-escape.toml
new file mode 100644
index 0000000..32e2c48
--- /dev/null
+++ b/test-suite/tests/invalid/string-bad-line-ending-escape.toml
@@ -0,0 +1,3 @@
+invalid-escape = """\
+ This string has a non whitespace-character after the line ending escape. \ a
+"""
diff --git a/test-suite/tests/serde.rs b/test-suite/tests/serde.rs
index b97937f..c1b6d78 100644
--- a/test-suite/tests/serde.rs
+++ b/test-suite/tests/serde.rs
@@ -580,15 +580,63 @@ fn table_structs_empty() {
#[test]
fn fixed_size_array() {
- #[derive(Serialize, PartialEq, Eq, Deserialize, Debug)]
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
struct Entity {
pos: [i32; 2]
}
- let text = "pos = [1, 2]\n";
- let value: Entity = toml::from_str(text).unwrap();
- let expected = Entity { pos: [1, 2] };
- assert_eq!(value, expected);
- assert_eq!(toml::to_string(&value).unwrap(), text);
+
+ equivalent! {
+ Entity { pos: [1, 2] },
+ Table(map! {
+ pos: Array(vec![
+ Integer(1),
+ Integer(2),
+ ])
+ }),
+ }
+}
+
+#[test]
+fn homogeneous_tuple() {
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
+ struct Collection {
+ elems: (i64, i64, i64),
+ }
+
+ equivalent! {
+ Collection { elems: (0, 1, 2) },
+ Table(map! {
+ elems: Array(vec![
+ Integer(0),
+ Integer(1),
+ Integer(2),
+ ])
+ }),
+ }
+}
+
+#[test]
+fn homogeneous_tuple_struct() {
+ #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
+ struct Object(Vec<String>, Vec<String>, Vec<String>);
+
+ equivalent! {
+ map! {
+ obj: Object(vec!["foo".to_string()], vec![], vec!["bar".to_string(), "baz".to_string()])
+ },
+ Table(map! {
+ obj: Array(vec![
+ Array(vec![
+ Value::String("foo".to_string()),
+ ]),
+ Array(vec![]),
+ Array(vec![
+ Value::String("bar".to_string()),
+ Value::String("baz".to_string()),
+ ]),
+ ])
+ }),
+ }
}
#[test]
diff --git a/test-suite/tests/valid/multiline-string.json b/test-suite/tests/valid/multiline-string.json
index 075bf50..3223bae 100644
--- a/test-suite/tests/valid/multiline-string.json
+++ b/test-suite/tests/valid/multiline-string.json
@@ -15,6 +15,10 @@
"type": "string",
"value": ""
},
+ "multiline_empty_five": {
+ "type": "string",
+ "value": ""
+ },
"equivalent_one": {
"type": "string",
"value": "The quick brown fox jumps over the lazy dog."
@@ -26,5 +30,9 @@
"equivalent_three": {
"type": "string",
"value": "The quick brown fox jumps over the lazy dog."
+ },
+ "equivalent_four": {
+ "type": "string",
+ "value": "The quick brown fox jumps over the lazy dog."
}
}
diff --git a/test-suite/tests/valid/multiline-string.toml b/test-suite/tests/valid/multiline-string.toml
index 15b1143..2c4237f 100644
--- a/test-suite/tests/valid/multiline-string.toml
+++ b/test-suite/tests/valid/multiline-string.toml
@@ -7,6 +7,11 @@ multiline_empty_four = """\
\
\
"""
+multiline_empty_five = """\
+ \
+ \
+ \
+ """
equivalent_one = "The quick brown fox jumps over the lazy dog."
equivalent_two = """
@@ -21,3 +26,9 @@ equivalent_three = """\
fox jumps over \
the lazy dog.\
"""
+
+equivalent_four = """\
+ The quick brown \
+ fox jumps over \
+ the lazy dog.\
+ """