+20
-18
@@ -858,8 +858,9 @@ pub fn compare_paths(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use util_macros::perf;
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn compare_paths_with_dots() {
|
||||
let mut paths = vec![
|
||||
(Path::new("test_dirs"), false),
|
||||
@@ -897,7 +898,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn compare_paths_with_same_name_different_extensions() {
|
||||
let mut paths = vec![
|
||||
(Path::new("test_dirs/file.rs"), true),
|
||||
@@ -919,7 +920,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn compare_paths_case_semi_sensitive() {
|
||||
let mut paths = vec![
|
||||
(Path::new("test_DIRS"), false),
|
||||
@@ -951,7 +952,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn path_with_position_parse_posix_path() {
|
||||
// Test POSIX filename edge cases
|
||||
// Read more at https://en.wikipedia.org/wiki/Filename
|
||||
@@ -1038,7 +1039,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn path_with_position_parse_posix_path_with_suffix() {
|
||||
assert_eq!(
|
||||
@@ -1094,7 +1095,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn path_with_position_parse_windows_path() {
|
||||
assert_eq!(
|
||||
@@ -1116,7 +1117,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn path_with_position_parse_windows_path_with_suffix() {
|
||||
assert_eq!(
|
||||
@@ -1229,7 +1230,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_path_compact() {
|
||||
let path: PathBuf = [
|
||||
home_dir().to_string_lossy().to_string(),
|
||||
@@ -1244,7 +1245,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_extension_or_hidden_file_name() {
|
||||
// No dots in name
|
||||
let path = Path::new("/a/b/c/file_name.rs");
|
||||
@@ -1267,7 +1268,7 @@ mod tests {
|
||||
assert_eq!(path.extension_or_hidden_file_name(), Some("eslintrc.js"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn edge_of_glob() {
|
||||
let path = Path::new("/work/node_modules");
|
||||
let path_matcher =
|
||||
@@ -1278,7 +1279,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn project_search() {
|
||||
let path = Path::new("/Users/someonetoignore/work/zed/zed.dev/node_modules");
|
||||
let path_matcher =
|
||||
@@ -1289,7 +1290,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn test_sanitized_path() {
|
||||
let path = Path::new("C:\\Users\\someone\\test_file.rs");
|
||||
@@ -1307,7 +1308,7 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_compare_numeric_segments() {
|
||||
// Helper function to create peekable iterators and test
|
||||
fn compare(a: &str, b: &str) -> Ordering {
|
||||
@@ -1375,7 +1376,7 @@ mod tests {
|
||||
assert_eq!(b_iter.collect::<String>(), "def");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_natural_sort() {
|
||||
// Basic alphanumeric
|
||||
assert_eq!(natural_sort("a", "b"), Ordering::Less);
|
||||
@@ -1429,7 +1430,7 @@ mod tests {
|
||||
assert_eq!(natural_sort("File_a1", "File_A1"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_compare_paths() {
|
||||
// Helper function for cleaner tests
|
||||
fn compare(a: &str, is_a_file: bool, b: &str, is_b_file: bool) -> Ordering {
|
||||
@@ -1515,8 +1516,9 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_natural_sort_case_sensitivity() {
|
||||
std::thread::sleep(std::time::Duration::from_millis(100));
|
||||
// Same letter different case - lowercase should come first
|
||||
assert_eq!(natural_sort("a", "A"), Ordering::Less);
|
||||
assert_eq!(natural_sort("A", "a"), Ordering::Greater);
|
||||
@@ -1534,7 +1536,7 @@ mod tests {
|
||||
assert_eq!(natural_sort("a", "B"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_natural_sort_with_numbers() {
|
||||
// Basic number ordering
|
||||
assert_eq!(natural_sort("file1", "file2"), Ordering::Less);
|
||||
@@ -1612,7 +1614,7 @@ mod tests {
|
||||
assert_eq!(natural_sort("file1", "File2"), Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[perf]
|
||||
fn test_natural_sort_edge_cases() {
|
||||
// Empty strings
|
||||
assert_eq!(natural_sort("", ""), Ordering::Equal);
|
||||
|
||||
Reference in New Issue
Block a user