Skip to content

Commit

Permalink
tests: update snapbox fixtures for should-panic-in-debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
decathorpe committed Feb 14, 2025
1 parent 78e01a7 commit b6afd15
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 7 deletions.
33 changes: 30 additions & 3 deletions src/ascii/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,16 @@ Err(
}

let input = "7";
assert_parse!(escaped_string.parse_peek(input), str![]);
assert_parse!(escaped_string.parse_peek(input), str![[r#"
Err(
Cut(
InputError {
input: "7",
},
),
)
"#]]);
}

// issue #1336 "take_escaped hangs if normal parser accepts empty"
Expand All @@ -2085,7 +2094,16 @@ Err(
}

let input = "a7";
assert_parse!(escaped_string.parse_peek(input), str![]);
assert_parse!(escaped_string.parse_peek(input), str![[r#"
Err(
Cut(
InputError {
input: "7",
},
),
)
"#]]);
}

#[test]
Expand All @@ -2110,7 +2128,16 @@ Err(
}

let input = r#""""#;
assert_parse!(unquote.parse_peek(input), str![]);
assert_parse!(unquote.parse_peek(input), str![[r#"
Err(
Cut(
InputError {
input: "/"",
},
),
)
"#]]);
}

#[cfg(feature = "alloc")]
Expand Down
60 changes: 57 additions & 3 deletions src/combinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,23 @@ fn separated0_empty_sep_test() {

let i = &b"abcabc"[..];

assert_parse!(empty_sep.parse_peek(Partial::new(i)), str![]);
assert_parse!(empty_sep.parse_peek(Partial::new(i)), str![[r#"
Err(
Cut(
InputError {
input: Partial {
input: [
97,
98,
99,
],
partial: true,
},
},
),
)
"#]]);
}

#[test]
Expand Down Expand Up @@ -2501,7 +2517,26 @@ fn repeat0_empty_test() {
repeat(0.., "").parse_next(i)
}

assert_parse!(multi_empty.parse_peek(Partial::new(&b"abcdef"[..])), str![]);
assert_parse!(multi_empty.parse_peek(Partial::new(&b"abcdef"[..])), str![[r#"
Err(
Cut(
InputError {
input: Partial {
input: [
97,
98,
99,
100,
101,
102,
],
partial: true,
},
},
),
)
"#]]);
}

#[test]
Expand Down Expand Up @@ -3518,7 +3553,26 @@ fn fold_repeat0_empty_test() {
repeat(0.., "").fold(Vec::new, fold_into_vec).parse_next(i)
}

assert_parse!(multi_empty.parse_peek(Partial::new(&b"abcdef"[..])), str![]);
assert_parse!(multi_empty.parse_peek(Partial::new(&b"abcdef"[..])), str![[r#"
Err(
Cut(
InputError {
input: Partial {
input: [
97,
98,
99,
100,
101,
102,
],
partial: true,
},
},
),
)
"#]]);
}

#[test]
Expand Down
14 changes: 13 additions & 1 deletion tests/testsuite/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,19 @@ fn issue_848_overflow_incomplete_bits_to_bytes() {

bits(bytes(take)).parse_next(input)
}
assert_parse!(parser.parse_peek(Partial::new(&b""[..])), str![]);
assert_parse!(parser.parse_peek(Partial::new(&b""[..])), str![[r#"
Err(
Cut(
InputError {
input: Partial {
input: [],
partial: true,
},
},
),
)
"#]]);
}

#[test]
Expand Down

0 comments on commit b6afd15

Please sign in to comment.