15 #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ 16 #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ 18 #include "gmock/gmock.h" 19 #include "gtest/gtest.h" 24 namespace container_internal {
26 template <
class UnordMap>
33 std::vector<T> values;
34 std::generate_n(std::back_inserter(values), 10,
36 TypeParam m(values.begin(), values.end());
37 for (
const auto& p : values) {
38 const auto& val = m.at(p.first);
39 EXPECT_EQ(p.second, val) << ::testing::PrintToString(p.first);
45 using V =
typename TypeParam::mapped_type;
46 std::vector<T> values;
47 std::generate_n(std::back_inserter(values), 10,
50 for (
const auto& p : values) {
51 auto& val = m[p.first];
52 EXPECT_EQ(V(), val) << ::testing::PrintToString(p.first);
55 for (
const auto& p : values)
56 EXPECT_EQ(p.second, m[p.first]) << ::testing::PrintToString(p.first);
61 std::vector<T> values;
62 std::generate_n(std::back_inserter(values), 10,
65 for (
const auto& p : values)
66 EXPECT_EQ(0, m.count(p.first)) << ::testing::PrintToString(p.first);
67 m.insert(values.begin(), values.end());
68 for (
const auto& p : values)
69 EXPECT_EQ(1, m.count(p.first)) << ::testing::PrintToString(p.first);
75 std::vector<T> values;
76 std::generate_n(std::back_inserter(values), 10,
79 for (
const auto& p : values)
80 EXPECT_TRUE(m.end() == m.find(p.first))
81 << ::testing::PrintToString(p.first);
82 m.insert(values.begin(), values.end());
83 for (
const auto& p : values) {
84 auto it = m.find(p.first);
85 EXPECT_TRUE(m.end() != it) << ::testing::PrintToString(p.first);
86 EXPECT_EQ(p.second, get<1>(*it)) << ::testing::PrintToString(p.first);
93 std::vector<T> values;
94 std::generate_n(std::back_inserter(values), 10,
97 for (
const auto& p : values) {
98 auto r = m.equal_range(p.first);
99 ASSERT_EQ(0, std::distance(r.first, r.second));
101 m.insert(values.begin(), values.end());
102 for (
const auto& p : values) {
103 auto r = m.equal_range(p.first);
104 ASSERT_EQ(1, std::distance(r.first, r.second));
105 EXPECT_EQ(p.second, get<1>(*r.first)) << ::testing::PrintToString(p.first);
115 #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_LOOKUP_TEST_H_ constexpr size_t Find(Needle, Needle, Ts...)
TYPED_TEST_SUITE_P(ConstructorTest)
TYPED_TEST_P(ConstructorTest, NoArgs)
decltype(std::declval< const Generator< typename std::conditional< generator_internal::IsMap< Container >::value, typename Container::value_type, typename Container::key_type >::type > & >()()) GeneratedType
absl::string_view get(const Cont &c)
REGISTER_TYPED_TEST_CASE_P(ConstructorTest, NoArgs, BucketCount, BucketCountHash, BucketCountHashEqual, BucketCountHashEqualAlloc, BucketCountAlloc, BucketCountHashAlloc, Alloc, InputIteratorBucketHashEqualAlloc, InputIteratorBucketAlloc, InputIteratorBucketHashAlloc, CopyConstructor, CopyConstructorAlloc, MoveConstructor, MoveConstructorAlloc, InitializerListBucketHashEqualAlloc, InitializerListBucketAlloc, InitializerListBucketHashAlloc, Assignment, MoveAssignment, AssignmentFromInitializerList, AssignmentOverwritesExisting, MoveAssignmentOverwritesExisting, AssignmentFromInitializerListOverwritesExisting, AssignmentOnSelf)