From 391cb61dffd51322bd310be7cba8641fe3398c19 Mon Sep 17 00:00:00 2001 From: Garrett Berg Date: Sun, 9 Jul 2017 14:58:48 -0600 Subject: add pretty sting serialization --- tests/pretty.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/pretty.rs (limited to 'tests') diff --git a/tests/pretty.rs b/tests/pretty.rs new file mode 100644 index 0000000..71c9e63 --- /dev/null +++ b/tests/pretty.rs @@ -0,0 +1,20 @@ +extern crate toml; +extern crate serde; + +use serde::ser::Serialize; + +const example: &str = "\ +[example] +text = ''' +this is the first line +this is the second line +''' +"; + +#[test] +fn test_pretty() { + let value: toml::Value = toml::from_str(example).unwrap(); + let mut result = String::with_capacity(128); + value.serialize(&mut toml::Serializer::pretty(&mut result)).unwrap(); + assert_eq!(example, &result); +} -- cgit v1.2.3