|
1 |
| -use serde::Deserialize; |
2 |
| -use snapbox::assert_data_eq; |
3 |
| -use snapbox::prelude::*; |
4 |
| -use snapbox::str; |
5 | 1 | use toml::map::Map;
|
6 |
| -use toml::Value; |
7 | 2 | use toml::Value::{Array, Boolean, Float, Integer, String, Table};
|
8 | 3 |
|
9 | 4 | macro_rules! map( ($($k:expr => $v:expr),*) => ({
|
@@ -119,64 +114,3 @@ fn table() {
|
119 | 114 | test2 = 2\n"
|
120 | 115 | );
|
121 | 116 | }
|
122 |
| - |
123 |
| -#[test] |
124 |
| -fn string_roundtrip() { |
125 |
| - assert_string_round_trip(r#""""#, str![[r#""""#]]); |
126 |
| - assert_string_round_trip(r#""a""#, str![[r#""a""#]]); |
127 |
| - |
128 |
| - assert_string_round_trip(r#""tab \t tab""#, str![[r#""tab /t tab""#]]); |
129 |
| - assert_string_round_trip( |
130 |
| - r#""lf \n lf""#, |
131 |
| - str![[r#" |
132 |
| -""" |
133 |
| -lf |
134 |
| - lf""" |
135 |
| -"#]], |
136 |
| - ); |
137 |
| - assert_string_round_trip( |
138 |
| - r#""crlf \r\n crlf""#, |
139 |
| - str![[r#" |
140 |
| -""" |
141 |
| -crlf /r |
142 |
| - crlf""" |
143 |
| -"#]], |
144 |
| - ); |
145 |
| - assert_string_round_trip(r#""bell \b bell""#, str![[r#""bell /b bell""#]]); |
146 |
| - assert_string_round_trip(r#""feed \f feed""#, str![[r#""feed /f feed""#]]); |
147 |
| - assert_string_round_trip( |
148 |
| - r#""backslash \\ backslash""#, |
149 |
| - str!["'backslash / backslash'"], |
150 |
| - ); |
151 |
| - |
152 |
| - assert_string_round_trip(r#""squote ' squote""#, str![[r#""squote ' squote""#]]); |
153 |
| - assert_string_round_trip( |
154 |
| - r#""triple squote ''' triple squote""#, |
155 |
| - str![[r#""triple squote ''' triple squote""#]], |
156 |
| - ); |
157 |
| - assert_string_round_trip(r#""end squote '""#, str![[r#""end squote '""#]]); |
158 |
| - |
159 |
| - assert_string_round_trip(r#""quote \" quote""#, str![[r#"'quote " quote'"#]]); |
160 |
| - assert_string_round_trip( |
161 |
| - r#""triple quote \"\"\" triple quote""#, |
162 |
| - str![[r#"'triple quote """ triple quote'"#]], |
163 |
| - ); |
164 |
| - assert_string_round_trip(r#""end quote \"""#, str![[r#"'end quote "'"#]]); |
165 |
| -} |
166 |
| - |
167 |
| -#[track_caller] |
168 |
| -fn assert_string_round_trip(input: &str, expected: impl IntoData) { |
169 |
| - let value = Value::deserialize(toml::de::ValueDeserializer::new(input)).unwrap(); |
170 |
| - let actual = value.to_string(); |
171 |
| - let _ = Value::deserialize(toml::de::ValueDeserializer::new(input)).unwrap_or_else(|_err| { |
172 |
| - panic!( |
173 |
| - "invalid value: |
174 |
| -``` |
175 |
| -{actual} |
176 |
| -``` |
177 |
| -" |
178 |
| - ) |
179 |
| - }); |
180 |
| - let expected = expected.into_data(); |
181 |
| - assert_data_eq!(actual, expected); |
182 |
| -} |
0 commit comments