From 08b8aa725ec45246a01c88cd5c2787de3d3af6ba Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 4 Mar 2023 17:13:25 -0800 Subject: [PATCH] Add test of escape sequences in strings --- tests/test_serde.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_serde.rs b/tests/test_serde.rs index a22c2ed4..b506f4e7 100644 --- a/tests/test_serde.rs +++ b/tests/test_serde.rs @@ -244,6 +244,27 @@ fn test_basic_struct() { test_serde(&thing, yaml); } +#[test] +fn test_string_escapes() { + let yaml = indoc! {r#" + ascii + "#}; + test_serde(&"ascii".to_owned(), yaml); + + let yaml = indoc! {r#" + "\0\a\b\t\n\v\f\r\e\"\\\N\L\P" + "#}; + test_serde( + &"\0\u{7}\u{8}\t\n\u{b}\u{c}\r\u{1b}\"\\\u{85}\u{2028}\u{2029}".to_owned(), + yaml, + ); + + let yaml = indoc! {r#" + "\x1F\uFEFF" + "#}; + test_serde(&"\u{1f}\u{feff}".to_owned(), yaml); +} + #[test] fn test_multiline_string() { #[derive(Serialize, Deserialize, PartialEq, Debug)]