use std::path::PathBuf;
#[test]
fn test_path_normalization() {
let windows_path = "C:\\Windows\\System32\\cmd.exe";
let normalized = windows_path.replace('\\', "/");
assert_eq!(normalized, "C:/Windows/System32/cmd.exe");
let path = PathBuf::from("foo\\bar\\baz.txt");
let norm = path.display().to_string().replace('\\', "/");
assert_eq!(norm, "foo/bar/baz.txt");
}
#[test]
fn test_line_endings_match() {
let re = regex::RegexBuilder::new(r"(?m)secret[=:]\s*[a-zA-Z0-9]{10,}$")
.crlf(true)
.build()
.unwrap();
let unix = "secret=abcdefghij12345\n";
assert!(re.is_match(unix));
let win = "secret=abcdefghij12345\r\n";
assert!(re.is_match(win));
}
#[test]
fn test_binary_detection() {
let bytes_null = b"text\0text";
let bytes_pdf = b"%PDF-1.4";
let bytes_utf16_le = b"\xFF\xFEa\x00b\x00";
let bytes_utf16_be = b"\xFE\xFF\x00a\x00b";
let bytes_normal = b"hello world\n";
assert!(bytes_null.contains(&0));
assert!(bytes_pdf.starts_with(b"%PDF-"));
assert!(bytes_utf16_le.starts_with(b"\xFF\xFE"));
assert!(bytes_utf16_be.starts_with(b"\xFE\xFF"));
assert!(!bytes_normal.contains(&0));
}