test: Add unit tests for file handling and configuration merging (#7)

* test: Add unit tests for file handling and configuration merging

* test: Update IO error conversion test to use new error creation method
This commit is contained in:
Eli Peter 2025-06-24 23:38:32 +02:00 committed by GitHub
parent 8497800b13
commit 46c4732f6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 225 additions and 57 deletions

View file

@ -15,16 +15,20 @@ pub fn lowercase_ext(path: &std::path::Path) -> Option<&'static str> {
#[test]
fn lowercase_ext_recognises_known_extensions() {
let cases = [
("file.rs", Some("rs")),
("FILE.RS", Some("rs")),
("main.cpp", Some("cpp")),
("script.PY",Some("py")),
("index.tsx",Some("ts")),
("style.css",None), // unsupported
];
let cases = [
("file.rs", Some("rs")),
("FILE.RS", Some("rs")),
("main.cpp", Some("cpp")),
("script.PY", Some("py")),
("index.tsx", Some("ts")),
("style.css", None), // unsupported
];
for (file, expected) in cases {
assert_eq!(lowercase_ext(std::path::Path::new(file)), expected, "case: {file}");
}
for (file, expected) in cases {
assert_eq!(
lowercase_ext(std::path::Path::new(file)),
expected,
"case: {file}"
);
}
}