Skip to content

Commit d18841e

Browse files
committed
add more tests
1 parent 88112b3 commit d18841e

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/regex/bytes.rs

+25-3
Original file line numberDiff line numberDiff line change
@@ -2667,14 +2667,36 @@ mod tests {
26672667
}
26682668

26692669
#[test]
2670-
fn test_non_ascii_utf8() {
2671-
let haystack = "아스키문자는 아닌데 UTF-8 문자열".as_bytes();
2670+
fn test_debug_output_various_unicode() {
2671+
let haystack =
2672+
"Hello, 😊 world! 안녕하세요? مرحبا بالعالم!".as_bytes();
26722673
let m = Match::new(haystack, 0, haystack.len());
26732674
let debug_str = format!("{:?}", m);
26742675

26752676
assert_eq!(
26762677
debug_str,
2677-
r#"Match { start: 0, end: 44, bytes: "아스키문자는 아닌데 UTF-8 문자열" }"#
2678+
r#"Match { start: 0, end: 62, bytes: "Hello, 😊 world! 안녕하세요? مرحبا بالعالم!" }"#
26782679
);
26792680
}
2681+
2682+
#[test]
2683+
fn test_debug_output_ascii_escape() {
2684+
let haystack = b"Hello,\tworld!\nThis is a \x1b[31mtest\x1b[0m.";
2685+
let m = Match::new(haystack, 0, haystack.len());
2686+
let debug_str = format!("{:?}", m);
2687+
2688+
assert_eq!(
2689+
debug_str,
2690+
r#"Match { start: 0, end: 38, bytes: "Hello,\tworld!\nThis is a \u{1b}[31mtest\u{1b}[0m." }"#
2691+
);
2692+
}
2693+
2694+
#[test]
2695+
fn test_debug_output_match_in_middle() {
2696+
let haystack = b"The quick brown fox jumps over the lazy dog.";
2697+
let m = Match::new(haystack, 16, 19);
2698+
let debug_str = format!("{:?}", m);
2699+
2700+
assert_eq!(debug_str, r#"Match { start: 16, end: 19, bytes: "fox" }"#);
2701+
}
26802702
}

0 commit comments

Comments
 (0)