| 1 |
#include <pbcopper/container/Unordered.h> |
| 2 |
|
| 3 |
#include <gtest/gtest.h> |
| 4 |
|
| 5 |
#include <algorithm> |
| 6 |
#include <cstdint> |
| 7 |
#include <limits> |
| 8 |
#include <random> |
| 9 |
#include <sstream> |
| 10 |
#include <stdexcept> |
| 11 |
#include <string_view> |
| 12 |
#include <unordered_map> |
| 13 |
#include <unordered_set> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
using namespace PacBio; |
| 17 |
|
| 18 |
TEST(Container_Unordered, InsertionInvariance) |
| 19 |
{ |
| 20 |
Container::UnorderedSet<int> rightHand; |
| 21 |
Container::UnorderedSet<int> leftHand; |
| 22 |
for (int i = 0; i < 10000; ++i) { |
| 23 |
rightHand.insert(10000 - i - 1); |
| 24 |
leftHand.insert(i); |
| 25 |
} |
| 26 |
EXPECT_EQ(rightHand, leftHand); |
| 27 |
} |
| 28 |
|
| 29 |
TEST(Container_Unordered, Counting) |
| 30 |
{ |
| 31 |
Container::UnorderedMap<int, int> rhs; |
| 32 |
std::unordered_map<int, int> lhs; |
| 33 |
for (int i = 0; i < 1000000; ++i) { |
| 34 |
rhs[i] = 1; |
| 35 |
lhs[i] = 1; |
| 36 |
} |
| 37 |
EXPECT_EQ(std::all_of(rhs.begin(), rhs.end(), [](const auto x) { return x.second == 1; }), |
| 38 |
true); |
| 39 |
for (const auto pair : rhs) { |
| 40 |
EXPECT_EQ(pair.second, lhs[pair.first]); |
| 41 |
} |
| 42 |
} |