Skip to content

Commit c17304e

Browse files
committed
Fix string_transparent_hash_ut (#158)
1 parent f49d1a1 commit c17304e

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
stack_ut.cpp
9292
store_policy_ut.cpp
9393
strbuf_ut.cpp
94-
# See fix/util-unit-tests branch
95-
# string_transparent_hash_ut.cpp
94+
string_transparent_hash_ut.cpp
9695
string_ut.cpp
9796
typelist_ut.cpp
9897
typetraits_ut.cpp
@@ -162,8 +161,7 @@ if (YDB_SDK_TESTS)
162161

163162
add_ydb_multiple_tests(PREFIX util BASE_DIR random
164163
FILES
165-
# See fix/util-unit-tests branch
166-
# common_ops_ut.cpp
164+
common_ops_ut.cpp
167165
easy_ut.cpp
168166
entropy_ut.cpp
169167
fast_ut.cpp
@@ -246,17 +244,15 @@ if (YDB_SDK_TESTS)
246244
cpu_id_ut.cpp
247245
daemon_ut.cpp
248246
datetime_ut.cpp
249-
# See fix/util-unit-tests branch
250-
# direct_io_ut.cpp
247+
direct_io_ut.cpp
251248
env_ut.cpp
252249
error_ut.cpp
253250
event_ut.cpp
254251
execpath_ut.cpp
255252
filemap_ut.cpp
256253
file_ut.cpp
257254
flock_ut.cpp
258-
# See fix/util-unit-tests branch
259-
# fstat_ut.cpp
255+
fstat_ut.cpp
260256
fs_ut.cpp
261257
getpid_ut.cpp
262258
guard_ut.cpp
@@ -281,8 +277,7 @@ if (YDB_SDK_TESTS)
281277
src_root_ut.cpp
282278
tempfile_ut.cpp
283279
tls_ut.cpp
284-
# See fix/util-unit-tests branch
285-
# type_name_ut.cpp
280+
type_name_ut.cpp
286281
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)