Skip to content

Commit 32e124e

Browse files
authored
Fixed util test string_transparent_hash_ut (#311)
1 parent e111838 commit 32e124e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

util/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ if (YDB_SDK_TESTS)
9696
generic/stack_ut.cpp
9797
generic/store_policy_ut.cpp
9898
generic/strbuf_ut.cpp
99-
# TODO: uncomment this test after we get the fix
100-
# generic/string_transparent_hash_ut.cpp
99+
generic/string_transparent_hash_ut.cpp
101100
generic/string_ut.cpp
102101
generic/typelist_ut.cpp
103102
generic/typetraits_ut.cpp

util/generic/string_transparent_hash_ut.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,27 @@
33
#include "strbuf.h"
44

55
#include <library/cpp/testing/unittest/registar.h>
6-
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
76

87
#include <util/str_stl.h>
98

9+
#ifdef __cpp_lib_generic_unordered_lookup
10+
#include <unordered_set>
11+
12+
template <class T, class THasher, class TPred>
13+
using THashSetType = std::unordered_set<T, THasher, TPred>;
14+
#else
15+
// Using Abseil hash set because `std::unordered_set` is transparent only from libstdc++11.
16+
// Meanwhile clang-linux-x86_64-release-stl-system autocheck sets OS_SDK=ubuntu-20,
17+
// that support libstdc++10 by default.
18+
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
19+
20+
template <class T, class THasher, class TPred>
21+
using THashSetType = absl::flat_hash_set<T, THasher, TPred>;
22+
#endif
23+
1024
Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
1125
Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
12-
// Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
13-
// we stuck with C++17 right now).
14-
absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
26+
THashSetType<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
1527
// If either `THash` or `TEqualTo` is not transparent compilation will fail.
1628
UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
1729
UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());

0 commit comments

Comments
 (0)