aboutsummaryrefslogtreecommitdiff
path: root/tests/pretty.rs
blob: f9b6d2039839e16c201f9839fb333fa394255885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extern crate toml;
extern crate serde;

use serde::ser::Serialize;

const EXAMPLE: &'static str = "\
[example]
array = [
    \"item 1\",
    \"item 2\",
]
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();
    println!("example:\n{}", EXAMPLE);
    println!("result:\n{}", result);
    assert_eq!(EXAMPLE, &result);
}