@@ -2667,14 +2667,36 @@ mod tests {
2667
2667
}
2668
2668
2669
2669
#[ 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 ( ) ;
2672
2673
let m = Match :: new ( haystack, 0 , haystack. len ( ) ) ;
2673
2674
let debug_str = format ! ( "{:?}" , m) ;
2674
2675
2675
2676
assert_eq ! (
2676
2677
debug_str,
2677
- r#"Match { start: 0, end: 44 , bytes: "아스키문자는 아닌데 UTF-8 문자열 " }"#
2678
+ r#"Match { start: 0, end: 62 , bytes: "Hello, 😊 world! 안녕하세요? مرحبا بالعالم! " }"#
2678
2679
) ;
2679
2680
}
2681
+
2682
+ #[ test]
2683
+ fn test_debug_output_ascii_escape ( ) {
2684
+ let haystack = b"Hello,\t world!\n This 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
+ }
2680
2702
}
0 commit comments