aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett Berg <vitiral@gmail.com>2017-08-13 15:23:50 -0600
committerGarrett Berg <vitiral@gmail.com>2017-08-13 15:31:09 -0600
commita0d0a313dfbcffa33942c0d2f1a6dd337f350ceb (patch)
tree835a99a14d0b789b580351bab1e8a4a3a3d8ce96 /tests
parentea251b375316fab8c9c87726751d9a3014b38ed7 (diff)
downloadmilf-rs-a0d0a313dfbcffa33942c0d2f1a6dd337f350ceb.tar.gz
milf-rs-a0d0a313dfbcffa33942c0d2f1a6dd337f350ceb.zip
add spaces between array items and test for them
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/pretty.rs b/tests/pretty.rs
index cceb815..3a9777c 100644
--- a/tests/pretty.rs
+++ b/tests/pretty.rs
@@ -212,3 +212,51 @@ fn pretty_tricky() {
println!("\nRESULT:\n{}", result);
assert_eq!(toml, &result);
}
+
+const PRETTY_TABLE_ARRAY: &'static str = r##"[[array]]
+key = 'foo'
+
+[[array]]
+key = 'bar'
+
+[abc]
+doc = 'this is a table'
+
+[example]
+single = 'this is a single line string'
+"##;
+
+#[test]
+fn pretty_table_array() {
+ let toml = PRETTY_TABLE_ARRAY;
+ let value: toml::Value = toml::from_str(toml).unwrap();
+ let mut result = String::with_capacity(128);
+ value.serialize(&mut toml::Serializer::pretty(&mut result)).unwrap();
+ println!("EXPECTED:\n{}", toml);
+ println!("\nRESULT:\n{}", result);
+ assert_eq!(toml, &result);
+}
+
+const TABLE_ARRAY: &'static str = r##"[[array]]
+key = "foo"
+
+[[array]]
+key = "bar"
+
+[abc]
+doc = "this is a table"
+
+[example]
+single = "this is a single line string"
+"##;
+
+#[test]
+fn table_array() {
+ let toml = TABLE_ARRAY;
+ let value: toml::Value = toml::from_str(toml).unwrap();
+ let mut result = String::with_capacity(128);
+ value.serialize(&mut toml::Serializer::new(&mut result)).unwrap();
+ println!("EXPECTED:\n{}", toml);
+ println!("\nRESULT:\n{}", result);
+ assert_eq!(toml, &result);
+}