Unverified Commit 8402b776 authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

Add tests for normalize_path (#78840)

Just some simple unit tests

I developed these while pursuing a performance improvement that ultimately failed, but i figured i should keep the tests.
parent e22f3f80
......@@ -194,3 +194,34 @@ pub async fn uri_from_file(root: Vc<FileSystemPath>, path: Option<&str>) -> Resu
Ok(uri)
}
#[cfg(test)]
mod tests {
use rstest::*;
use crate::util::normalize_path;
#[rstest]
#[case("file.js")]
#[case("a/b/c/d/e/file.js")]
fn test_normalize_path_no_op(#[case] path: &str) {
assert_eq!(path, normalize_path(path).unwrap());
}
#[rstest]
#[case("/file.js", "file.js")]
#[case("./file.js", "file.js")]
#[case("././file.js", "file.js")]
#[case("a/../c/../file.js", "file.js")]
fn test_normalize_path(#[case] path: &str, #[case] normalized: &str) {
assert_eq!(normalized, normalize_path(path).unwrap());
}
#[rstest]
#[case("../file.js")]
#[case("a/../../file.js")]
fn test_normalize_path_invalid(#[case] path: &str) {
assert_eq!(None, normalize_path(path));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment