Skip to content

Commit 92d26be

Browse files
committed
Fix string_transparent_hash_ut (#158)
1 parent 6b381be commit 92d26be

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

util/CMakeLists.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ if (YDB_SDK_TESTS)
9191
generic/stack_ut.cpp
9292
generic/store_policy_ut.cpp
9393
generic/strbuf_ut.cpp
94-
# See fix/util-unit-tests branch
95-
# generic/string_transparent_hash_ut.cpp
94+
generic/string_transparent_hash_ut.cpp
9695
generic/string_ut.cpp
9796
generic/typelist_ut.cpp
9897
generic/typetraits_ut.cpp
@@ -162,8 +161,7 @@ if (YDB_SDK_TESTS)
162161

163162
add_ydb_multiple_tests(PREFIX util-random
164163
FILES
165-
# See fix/util-unit-tests branch
166-
# random/common_ops_ut.cpp
164+
random/common_ops_ut.cpp
167165
random/easy_ut.cpp
168166
random/entropy_ut.cpp
169167
random/fast_ut.cpp
@@ -246,17 +244,15 @@ if (YDB_SDK_TESTS)
246244
system/cpu_id_ut.cpp
247245
system/daemon_ut.cpp
248246
system/datetime_ut.cpp
249-
# See fix/util-unit-tests branch
250-
# system/direct_io_ut.cpp
247+
system/direct_io_ut.cpp
251248
system/env_ut.cpp
252249
system/error_ut.cpp
253250
system/event_ut.cpp
254251
system/execpath_ut.cpp
255252
system/filemap_ut.cpp
256253
system/file_ut.cpp
257254
system/flock_ut.cpp
258-
# See fix/util-unit-tests branch
259-
# system/fstat_ut.cpp
255+
system/fstat_ut.cpp
260256
system/fs_ut.cpp
261257
system/getpid_ut.cpp
262258
system/guard_ut.cpp
@@ -281,8 +277,7 @@ if (YDB_SDK_TESTS)
281277
system/src_root_ut.cpp
282278
system/tempfile_ut.cpp
283279
system/tls_ut.cpp
284-
# See fix/util-unit-tests branch
285-
# system/type_name_ut.cpp
280+
system/type_name_ut.cpp
286281
system/types_ut.cpp
287282
# TODO: add library/cpp/testing/benchmark
288283
# depends only on NBench::Clobber, that's a memory optimization barrier

util/generic/string_transparent_hash_ut.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,28 @@
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>
6+
7+
#if __cplusplus < 202002L
8+
#include <library/cpp/containers/absl_flat_hash/flat_hash_set.h>
9+
#else
10+
#include <unordered_set>
11+
#endif
712

813
#include <util/str_stl.h>
914

1015
Y_UNIT_TEST_SUITE(StringHashFunctorTests) {
1116
Y_UNIT_TEST(TestTransparencyWithUnorderedSet) {
1217
// Using Abseil hash set because `std::unordered_set` is transparent only from C++20 (while
1318
// we stuck with C++17 right now).
14-
absl::flat_hash_set<TString, THash<TString>, TEqualTo<TString>> s = {"foo"};
19+
using TTransparentHashSet =
20+
#if __cplusplus < 202002L
21+
absl::flat_hash_set
22+
#else
23+
std::unordered_set
24+
#endif
25+
<TString, THash<TString>, TEqualTo<TString>>;
26+
27+
TTransparentHashSet s = {"foo"};
1528
// If either `THash` or `TEqualTo` is not transparent compilation will fail.
1629
UNIT_ASSERT_UNEQUAL(s.find(TStringBuf("foo")), s.end());
1730
UNIT_ASSERT_EQUAL(s.find(TStringBuf("bar")), s.end());

0 commit comments

Comments
 (0)