From dfdf3610184b949891b6f8c1b597d07c77293325 Mon Sep 17 00:00:00 2001 From: The8472 Date: Tue, 6 Jul 2021 20:18:52 +0200 Subject: [PATCH] add Ord tests for Path comparisons --- library/std/src/path/tests.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/library/std/src/path/tests.rs b/library/std/src/path/tests.rs index 6b7df78d3d7e5..c10ded08f2ce4 100644 --- a/library/std/src/path/tests.rs +++ b/library/std/src/path/tests.rs @@ -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";