Skip to content

Commit

Permalink
add Ord tests for Path comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed Jul 6, 2021
1 parent 5e87710 commit dfdf361
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions library/std/src/path/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,23 @@ fn into_rc() {
assert_eq!(&*arc2, path);
}

#[test]
fn test_ord() {
macro_rules! ord(
($ord:ident, $left:expr, $right:expr) => ( {
assert_eq!(Path::new($left).cmp(&Path::new($right)), core::cmp::Ordering::$ord);
});
);

ord!(Less, "1", "2");
ord!(Less, "/foo/bar", "/foo./bar");
ord!(Less, "foo/bar", "foo/bar.");
ord!(Equal, "foo/./bar", "foo/bar/");
ord!(Equal, "foo/bar", "foo/bar/");
ord!(Equal, "foo/bar", "foo/bar/.");
ord!(Equal, "foo/bar", "foo/bar//");
}

#[bench]
fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) {
let prefix = "my/home";
Expand Down

0 comments on commit dfdf361

Please sign in to comment.