2017-07-09 15:58:48 -05:00
|
|
|
extern crate toml;
|
|
|
|
extern crate serde;
|
|
|
|
|
|
|
|
use serde::ser::Serialize;
|
|
|
|
|
2017-07-09 16:10:36 -05:00
|
|
|
const EXAMPLE: &str = "\
|
2017-07-09 15:58:48 -05:00
|
|
|
[example]
|
|
|
|
text = '''
|
|
|
|
this is the first line
|
|
|
|
this is the second line
|
|
|
|
'''
|
|
|
|
";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_pretty() {
|
2017-07-09 16:10:36 -05:00
|
|
|
let value: toml::Value = toml::from_str(EXAMPLE).unwrap();
|
2017-07-09 15:58:48 -05:00
|
|
|
let mut result = String::with_capacity(128);
|
|
|
|
value.serialize(&mut toml::Serializer::pretty(&mut result)).unwrap();
|
2017-07-09 16:10:36 -05:00
|
|
|
assert_eq!(EXAMPLE, &result);
|
2017-07-09 15:58:48 -05:00
|
|
|
}
|