From 3ad6e71f53a87215fb5286bcf87de15524699561 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 12 Nov 2017 17:26:09 -0800 Subject: Move tests into their own crate --- test-suite/tests/tables-last.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test-suite/tests/tables-last.rs (limited to 'test-suite/tests/tables-last.rs') diff --git a/test-suite/tests/tables-last.rs b/test-suite/tests/tables-last.rs new file mode 100644 index 0000000..d05c8f0 --- /dev/null +++ b/test-suite/tests/tables-last.rs @@ -0,0 +1,30 @@ +#[macro_use] +extern crate serde_derive; +extern crate toml; + +use std::collections::HashMap; + +#[derive(Serialize)] +struct A { + #[serde(serialize_with = "toml::ser::tables_last")] + vals: HashMap<&'static str, Value>, +} + +#[derive(Serialize)] +#[serde(untagged)] +enum Value { + Map(HashMap<&'static str, &'static str>), + Int(i32), +} + +#[test] +fn always_works() { + let mut a = A { vals: HashMap::new() }; + a.vals.insert("foo", Value::Int(0)); + + let mut sub = HashMap::new(); + sub.insert("foo", "bar"); + a.vals.insert("bar", Value::Map(sub)); + + toml::to_string(&a).unwrap(); +} -- cgit v1.2.3