From 35b52d33b97edeff60b77f8f4501ea2ac1af3d51 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 29 May 2021 20:09:58 -0400 Subject: regex: add unit tests for non-matching anchor bytes This is in addition to the integration level test added in 581a35e568c3acd32461d276a4cfe746524e17cd. --- crates/regex/src/non_matching.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/regex/src/non_matching.rs b/crates/regex/src/non_matching.rs index e2e0755b..7f68e84a 100644 --- a/crates/regex/src/non_matching.rs +++ b/crates/regex/src/non_matching.rs @@ -128,4 +128,12 @@ mod tests { assert_eq!(sparse(&extract(r"\xFF")), sparse_except(&[0xC3, 0xBF])); assert_eq!(sparse(&extract(r"(?-u)\xFF")), sparse_except(&[0xFF])); } + + #[test] + fn anchor() { + assert_eq!(sparse(&extract(r"^")), sparse_except(&[b'\n'])); + assert_eq!(sparse(&extract(r"$")), sparse_except(&[b'\n'])); + assert_eq!(sparse(&extract(r"\A")), sparse_except(&[b'\n'])); + assert_eq!(sparse(&extract(r"\z")), sparse_except(&[b'\n'])); + } } -- cgit v1.2.3