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 {
|
2019-05-08 19:45:39 -05:00
|
|
|
user: vec![
|
|
|
|
User {
|
2016-09-06 14:16:21 -05:00
|
|
|
name: "John".to_string(),
|
|
|
|
surname: "Doe".to_string(),
|
|
|
|
},
|
2019-05-08 19:45:39 -05:00
|
|
|
User {
|
2016-09-06 14:16:21 -05:00
|
|
|
name: "Jane".to_string(),
|
|
|
|
surname: "Dough".to_string(),
|
|
|
|
},
|
2019-05-08 19:45:39 -05:00
|
|
|
],
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
.starts_with("\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_unnecessary_newlines_table() {
|
|
|
|
assert!(!to_string(&TwoUsers {
|
|
|
|
user0: User {
|
|
|
|
name: "John".to_string(),
|
|
|
|
surname: "Doe".to_string(),
|
|
|
|
},
|
|
|
|
user1: User {
|
|
|
|
name: "Jane".to_string(),
|
|
|
|
surname: "Dough".to_string(),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.unwrap()
|
|
|
|
.starts_with("\n"));
|
2016-09-06 14:16:21 -05:00
|
|
|
}
|