| 1 | use ron::ser::{to_string_pretty, PrettyConfig}; |
| 2 | |
| 3 | #[test] |
| 4 | fn small_array() { |
| 5 | let arr = &[(), (), ()][..]; |
| 6 | assert_eq!( |
| 7 | to_string_pretty(&arr, PrettyConfig::new().new_line("\n")).unwrap(), |
| 8 | "[ |
| 9 | (), |
| 10 | (), |
| 11 | (), |
| 12 | ]" |
| 13 | ); |
| 14 | assert_eq!( |
| 15 | to_string_pretty( |
| 16 | &arr, |
| 17 | PrettyConfig::new().new_line("\n").compact_arrays(true) |
| 18 | ) |
| 19 | .unwrap(), |
| 20 | "[(), (), ()]" |
| 21 | ); |
| 22 | assert_eq!( |
| 23 | to_string_pretty( |
| 24 | &arr, |
| 25 | PrettyConfig::new() |
| 26 | .new_line("\n") |
| 27 | .compact_arrays(true) |
| 28 | .separator("") |
| 29 | ) |
| 30 | .unwrap(), |
| 31 | "[(),(),()]" |
| 32 | ); |
| 33 | assert_eq!( |
| 34 | to_string_pretty( |
| 35 | &vec![(1, 2), (3, 4)], |
| 36 | PrettyConfig::new() |
| 37 | .new_line("\n") |
| 38 | .separate_tuple_members(true) |
| 39 | .compact_arrays(true) |
| 40 | ) |
| 41 | .unwrap(), |
| 42 | "[( |
| 43 | 1, |
| 44 | 2, |
| 45 | ), ( |
| 46 | 3, |
| 47 | 4, |
| 48 | )]" |
| 49 | ); |
| 50 | } |