]>
git.proxmox.com Git - rustc.git/blob - vendor/camino/tests/integration_tests.rs
1 // Copyright (c) The camino Contributors
2 // SPDX-License-Identifier: MIT OR Apache-2.0
4 use camino
::{Utf8Path, Utf8PathBuf}
;
6 collections
::hash_map
::DefaultHasher
,
11 static PATH_CORPUS
: &[&str] = &[
19 "../foo/bar/./../baz",
36 "C:\\foo\\..\\.\\bar",
38 "\\\\server\\foo\\bar",
40 "\\\\.\\C:\\foo\\bar.txt",
44 fn test_borrow_eq_ord() {
45 // Utf8PathBuf implements Borrow<Utf8Path> so equality and ordering comparisons should
47 for (idx
, &path1
) in PATH_CORPUS
.iter().enumerate() {
48 for &path2
in &PATH_CORPUS
[idx
..] {
49 let borrowed1
= Utf8Path
::new(path1
);
50 let borrowed2
= Utf8Path
::new(path2
);
51 let owned1
= Utf8PathBuf
::from(path1
);
52 let owned2
= Utf8PathBuf
::from(path2
);
55 borrowed1
== borrowed2
,
57 "Eq impls match: {} == {}",
62 borrowed1
.cmp(borrowed2
),
64 "Ord impls match: {} and {}",
69 // Also check against std paths.
70 let std1
= Path
::new(path1
);
71 let std2
= Path
::new(path2
);
74 "Eq between Path and Utf8Path: {}",
78 borrowed1
== borrowed2
,
80 "Eq impl matches Path: {} == {}",
85 borrowed1
.cmp(borrowed2
),
87 "Ord impl matches Path: {} and {}",
96 fn test_borrow_hash() {
97 // Utf8PathBuf implements Borrow<Utf8Path> so hash comparisons should match.
98 fn hash_output(x
: impl Hash
) -> u64 {
99 let mut hasher
= DefaultHasher
::new();
104 for &path
in PATH_CORPUS
{
105 let borrowed
= Utf8Path
::new(path
);
106 let owned
= Utf8PathBuf
::from(path
);
110 hash_output(borrowed
),
111 "consistent Hash: {}",