2017-01-29 18:53:20 -06:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2016-09-06 14:16:21 -05:00
|
|
|
extern crate toml;
|
|
|
|
|
2017-01-29 18:53:20 -06:00
|
|
|
use toml::to_string;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
2016-09-06 14:16:21 -05:00
|
|
|
struct User {
|
|
|
|
pub name: String,
|
|
|
|
pub surname: String,
|
|
|
|
}
|
|
|
|
|
2017-01-29 18:53:20 -06:00
|
|
|
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
2016-09-06 14:16:21 -05:00
|
|
|
struct Users {
|
|
|
|
pub user: Vec<User>,
|
|
|
|
}
|
|
|
|
|
2017-01-29 18:53:20 -06:00
|
|
|
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
2016-09-06 14:16:21 -05:00
|
|
|
struct TwoUsers {
|
|
|
|
pub user0: User,
|
|
|
|
pub user1: User,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_unnecessary_newlines_array() {
|
2017-01-29 18:53:20 -06:00
|
|
|
assert!(!to_string(&Users {
|
2016-09-06 14:16:21 -05:00
|
|
|
user: vec![
|
|
|
|
User {
|
|
|
|
name: "John".to_string(),
|
|
|
|
surname: "Doe".to_string(),
|
|
|
|
},
|
|
|
|
User {
|
|
|
|
name: "Jane".to_string(),
|
|
|
|
surname: "Dough".to_string(),
|
|
|
|
},
|
|
|
|
],
|
2017-01-29 18:53:20 -06:00
|
|
|
}).unwrap()
|
2016-09-06 14:16:21 -05:00
|
|
|
.starts_with("\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_unnecessary_newlines_table() {
|
2017-01-29 18:53:20 -06:00
|
|
|
assert!(!to_string(&TwoUsers {
|
2016-09-06 14:16:21 -05:00
|
|
|
user0: User {
|
|
|
|
name: "John".to_string(),
|
|
|
|
surname: "Doe".to_string(),
|
|
|
|
},
|
|
|
|
user1: User {
|
|
|
|
name: "Jane".to_string(),
|
|
|
|
surname: "Dough".to_string(),
|
|
|
|
},
|
2017-01-29 18:53:20 -06:00
|
|
|
}).unwrap()
|
2016-09-06 14:16:21 -05:00
|
|
|
.starts_with("\n"));
|
|
|
|
}
|