blob: 593f8cbb1bb701eab480ead0fe63e2f2a6460b5a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include <library/cpp/containers/flat_hash/lib/probings.h>
#include <library/cpp/testing/unittest/registar.h>
using namespace NFlatHash;
namespace {
struct TDummySizeFitter {
constexpr auto EvalIndex(size_t idx, size_t) const {
return idx;
}
};
constexpr TDummySizeFitter SIZE_FITTER;
auto atLeast13 = [](size_t idx) { return idx >= 13; };
}
Y_UNIT_TEST_SUITE(TProbingsTest) {
Y_UNIT_TEST(LinearProbingTest) {
using TProbing = TLinearProbing;
UNIT_ASSERT_EQUAL(TProbing::FindBucket(SIZE_FITTER, 1, 0, atLeast13), 13);
}
Y_UNIT_TEST(QuadraticProbingTest) {
using TProbing = TQuadraticProbing;
UNIT_ASSERT_EQUAL(TProbing::FindBucket(SIZE_FITTER, 1, 0, atLeast13), 17);
}
Y_UNIT_TEST(DenseProbingTest) {
using TProbing = TDenseProbing;
UNIT_ASSERT_EQUAL(TProbing::FindBucket(SIZE_FITTER, 1, 0, atLeast13), 16);
}
}
|