Skip to content

Commit

Permalink
Merge pull request #743 from decathorpe/main
Browse files Browse the repository at this point in the history
tests: update snapbox fixtures for should-panic-in-debug tests
  • Loading branch information
epage authored Feb 14, 2025
2 parents 78e01a7 + 1c46d3b commit 382f25a
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 7 deletions.
42 changes: 39 additions & 3 deletions src/ascii/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,19 @@ 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 +2097,19 @@ 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 +2134,19 @@ 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
69 changes: 66 additions & 3 deletions src/combinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,26 @@ 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 +2520,29 @@ 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 +3559,29 @@ 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 382f25a

Please sign in to comment.