Skip to content

Commit b463f3d

Browse files
authored
Merge pull request #757 from epage/key
fix(encode): Correct encoding for key with mixed quotes
2 parents cd9321f + 3d8852b commit b463f3d

File tree

6 files changed

+518
-99
lines changed

6 files changed

+518
-99
lines changed

Cargo.lock

+190-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/toml/tests/testsuite/display.rs

-66
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use serde::Deserialize;
2-
use snapbox::assert_data_eq;
3-
use snapbox::prelude::*;
4-
use snapbox::str;
51
use toml::map::Map;
6-
use toml::Value;
72
use toml::Value::{Array, Boolean, Float, Integer, String, Table};
83

94
macro_rules! map( ($($k:expr => $v:expr),*) => ({
@@ -119,64 +114,3 @@ fn table() {
119114
test2 = 2\n"
120115
);
121116
}
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-
}

crates/toml_edit/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ toml-test-harness = "0.4.8"
5353
toml-test-data = "1.11.0"
5454
libtest-mimic = "0.7.2"
5555
snapbox = "0.6.0"
56+
proptest = "1.5.0"
5657

5758
[[test]]
5859
name = "testsuite"

0 commit comments

Comments
 (0)