1use basic_toml::to_string;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
5struct User {
6 pub name: String,
7 pub surname: String,
8}
9
10#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
11struct Users {
12 pub user: Vec<User>,
13}
14
15#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
16struct TwoUsers {
17 pub user0: User,
18 pub user1: User,
19}
20
21#[test]
22fn no_unnecessary_newlines_array() {
23 assert!(!to_string(&Users {
24 user: vec![
25 User {
26 name: "John".to_string(),
27 surname: "Doe".to_string(),
28 },
29 User {
30 name: "Jane".to_string(),
31 surname: "Dough".to_string(),
32 },
33 ],
34 })
35 .unwrap()
36 .starts_with('\n'));
37}
38
39#[test]
40fn no_unnecessary_newlines_table() {
41 assert!(!to_string(&TwoUsers {
42 user0: User {
43 name: "John".to_string(),
44 surname: "Doe".to_string(),
45 },
46 user1: User {
47 name: "Jane".to_string(),
48 surname: "Dough".to_string(),
49 },
50 })
51 .unwrap()
52 .starts_with('\n'));
53}
54