Add warning when whitespace is not skipped after an escaped newline.
This commit is contained in:
parent
1195bea5a7
commit
5d59b4412e
4 changed files with 75 additions and 8 deletions
|
@ -98,6 +98,25 @@ fn test_unescape_char_good() {
|
|||
check(r"\u{1F63b}", '😻');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unescape_str_warn() {
|
||||
fn check(literal: &str, expected: &[(Range<usize>, Result<char, EscapeError>)]) {
|
||||
let mut unescaped = Vec::with_capacity(literal.len());
|
||||
unescape_literal(literal, Mode::Str, &mut |range, res| unescaped.push((range, res)));
|
||||
assert_eq!(unescaped, expected);
|
||||
}
|
||||
|
||||
check(
|
||||
"\\\n \u{a0} x",
|
||||
&[
|
||||
(0..5, Err(EscapeError::UnskippedWhitespaceWarning)),
|
||||
(3..5, Ok('\u{a0}')),
|
||||
(5..6, Ok(' ')),
|
||||
(6..7, Ok('x')),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unescape_str_good() {
|
||||
fn check(literal_text: &str, expected: &str) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue