aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-02 22:54:46 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-02 22:54:46 -0800
commitb3e9653b7fb4c78ccd5f7c23e402f8a3f678c924 (patch)
treee353a6c96d97beaf996ca4a4a490db38eed2375a /tests
parent68e6c34b9073f0c2f1546c93cade12e792f04e1e (diff)
downloadmilf-rs-b3e9653b7fb4c78ccd5f7c23e402f8a3f678c924.tar.gz
milf-rs-b3e9653b7fb4c78ccd5f7c23e402f8a3f678c924.zip
Properly escape keys when printing TOML
Closes #53
Diffstat (limited to 'tests')
-rw-r--r--tests/valid.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/valid.rs b/tests/valid.rs
index 628130e..1e47829 100644
--- a/tests/valid.rs
+++ b/tests/valid.rs
@@ -46,14 +46,20 @@ fn run(toml: &str, json: &str) {
(e.desc.clone(), toml.slice(e.lo - 5, e.hi + 5))
}).collect::<Vec<(String, &str)>>());
assert!(table.is_some());
- let table = table.unwrap();
+ let toml = Table(table.unwrap());
+ let toml_string = format!("{}", toml);
let json = Json::from_str(json).unwrap();
- let toml_json = to_json(Table(table));
+ let toml_json = to_json(toml.clone());
assert!(json == toml_json,
"expected\n{}\ngot\n{}\n",
json.pretty(),
toml_json.pretty());
+
+ let table2 = Parser::new(&toml_string).parse().unwrap();
+ // floats are a little lossy
+ if table2.values().any(|v| v.as_float().is_some()) { return }
+ assert_eq!(toml, Table(table2));
}
macro_rules! test( ($name:ident, $toml:expr, $json:expr) => (