summaryrefslogtreecommitdiff
path: root/absl/hash/hash_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/hash/hash_test.cc')
-rw-r--r--absl/hash/hash_test.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/absl/hash/hash_test.cc b/absl/hash/hash_test.cc
index 111f375b..59fe8dea 100644
--- a/absl/hash/hash_test.cc
+++ b/absl/hash/hash_test.cc
@@ -48,6 +48,10 @@
#include "absl/types/optional.h"
#include "absl/types/variant.h"
+#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#include <filesystem> // NOLINT
+#endif
+
#ifdef ABSL_HAVE_STD_STRING_VIEW
#include <string_view>
#endif
@@ -480,6 +484,43 @@ TEST(HashValueTest, U32StringView) {
#endif
}
+TEST(HashValueTest, StdFilesystemPath) {
+#ifndef ABSL_INTERNAL_STD_FILESYSTEM_PATH_HASH_AVAILABLE
+ GTEST_SKIP() << "std::filesystem::path is unavailable on this platform";
+#else
+ EXPECT_TRUE((is_hashable<std::filesystem::path>::value));
+
+ // clang-format off
+ const auto kTestCases = std::make_tuple(
+ std::filesystem::path(),
+ std::filesystem::path("/"),
+#ifndef __GLIBCXX__
+ // libstdc++ has a known issue normalizing "//".
+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106452
+ std::filesystem::path("//"),
+#endif
+ std::filesystem::path("/a/b"),
+ std::filesystem::path("/a//b"),
+ std::filesystem::path("a/b"),
+ std::filesystem::path("a/b/"),
+ std::filesystem::path("a//b"),
+ std::filesystem::path("a//b/"),
+ std::filesystem::path("c:/"),
+ std::filesystem::path("c:\\"),
+ std::filesystem::path("c:\\/"),
+ std::filesystem::path("c:\\//"),
+ std::filesystem::path("c://"),
+ std::filesystem::path("c://\\"),
+ std::filesystem::path("/e/p"),
+ std::filesystem::path("/s/../e/p"),
+ std::filesystem::path("e/p"),
+ std::filesystem::path("s/../e/p"));
+ // clang-format on
+
+ EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly(kTestCases));
+#endif
+}
+
TEST(HashValueTest, StdArray) {
EXPECT_TRUE((is_hashable<std::array<int, 3>>::value));