Skip to content

Commit ee1ba4e

Browse files
committed
Added brute force find test.
1 parent 45e2593 commit ee1ba4e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/find_tests.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#pragma once
22

3+
#include <ctime>
4+
#include <random>
5+
#include <cmath>
6+
37
class FindTests
48
: public ::testing::Test
59
{
610
public:
711
using types = IntervalTypes <int>;
812
protected:
913
IntervalTypes <int>::tree_type tree;
14+
std::default_random_engine gen;
15+
std::uniform_int_distribution <int> distLarge{-50000, 50000};
1016
};
1117

1218
TEST_F(FindTests, WillReturnEndIfTreeIsEmpty)
@@ -78,4 +84,22 @@ TEST_F(FindTests, WillFindAllCanExitPreemptively)
7884
EXPECT_EQ(findCount, 3);
7985
}
8086

87+
TEST_F(FindTests, CanFindAllElementsBack)
88+
{
89+
constexpr int amount = 10'000;
90+
91+
std::vector <decltype(tree)::interval_type> intervals;
92+
intervals.reserve(amount);
93+
for (int i = 0; i != amount; ++i)
94+
{
95+
const auto interval = lib_interval_tree::make_safe_interval(distLarge(gen), distLarge(gen));
96+
intervals.emplace_back(interval);
97+
tree.insert(interval);
98+
}
99+
for (auto const& ival : intervals)
100+
{
101+
ASSERT_NE(tree.find(ival), std::end(tree));
102+
}
103+
}
104+
81105

0 commit comments

Comments
 (0)