Skip to content

Commit dfdf361

Browse files
committed
add Ord tests for Path comparisons
1 parent 5e87710 commit dfdf361

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

library/std/src/path/tests.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,23 @@ fn into_rc() {
13951395
assert_eq!(&*arc2, path);
13961396
}
13971397

1398+
#[test]
1399+
fn test_ord() {
1400+
macro_rules! ord(
1401+
($ord:ident, $left:expr, $right:expr) => ( {
1402+
assert_eq!(Path::new($left).cmp(&Path::new($right)), core::cmp::Ordering::$ord);
1403+
});
1404+
);
1405+
1406+
ord!(Less, "1", "2");
1407+
ord!(Less, "/foo/bar", "/foo./bar");
1408+
ord!(Less, "foo/bar", "foo/bar.");
1409+
ord!(Equal, "foo/./bar", "foo/bar/");
1410+
ord!(Equal, "foo/bar", "foo/bar/");
1411+
ord!(Equal, "foo/bar", "foo/bar/.");
1412+
ord!(Equal, "foo/bar", "foo/bar//");
1413+
}
1414+
13981415
#[bench]
13991416
fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) {
14001417
let prefix = "my/home";

0 commit comments

Comments
 (0)