| 1 |
// Copyright 2019 The Abseil Authors. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
#ifndef PHMAP_PRIV_UNORDERED_MAP_MEMBERS_TEST_H_ |
| 16 |
#define PHMAP_PRIV_UNORDERED_MAP_MEMBERS_TEST_H_ |
| 17 |
|
| 18 |
#include <type_traits> |
| 19 |
|
| 20 |
#ifdef _MSC_VER |
| 21 |
#pragma warning(push, 0) |
| 22 |
#endif |
| 23 |
|
| 24 |
#include "gmock/gmock.h" |
| 25 |
#include "gtest/gtest.h" |
| 26 |
#include "hash_generator_testing.h" |
| 27 |
#include "hash_policy_testing.h" |
| 28 |
|
| 29 |
#ifdef _MSC_VER |
| 30 |
#pragma warning(pop) |
| 31 |
#endif |
| 32 |
|
| 33 |
namespace phmap { |
| 34 |
namespace priv { |
| 35 |
|
| 36 |
template <class UnordMap> |
| 37 |
class MembersTest : public ::testing::Test {}; |
| 38 |
|
| 39 |
TYPED_TEST_SUITE_P(MembersTest); |
| 40 |
|
| 41 |
template <typename T> |
| 42 |
void UseType() {} |
| 43 |
|
| 44 |
TYPED_TEST_P(MembersTest, Typedefs) { |
| 45 |
EXPECT_TRUE((std::is_same<std::pair<const typename TypeParam::key_type, |
| 46 |
typename TypeParam::mapped_type>, |
| 47 |
typename TypeParam::value_type>())); |
| 48 |
EXPECT_TRUE((phmap::conjunction< |
| 49 |
phmap::negation<std::is_signed<typename TypeParam::size_type>>, |
| 50 |
std::is_integral<typename TypeParam::size_type>>())); |
| 51 |
EXPECT_TRUE((phmap::conjunction< |
| 52 |
std::is_signed<typename TypeParam::difference_type>, |
| 53 |
std::is_integral<typename TypeParam::difference_type>>())); |
| 54 |
EXPECT_TRUE((std::is_convertible< |
| 55 |
decltype(std::declval<const typename TypeParam::hasher&>()( |
| 56 |
std::declval<const typename TypeParam::key_type&>())), |
| 57 |
size_t>())); |
| 58 |
EXPECT_TRUE((std::is_convertible< |
| 59 |
decltype(std::declval<const typename TypeParam::key_equal&>()( |
| 60 |
std::declval<const typename TypeParam::key_type&>(), |
| 61 |
std::declval<const typename TypeParam::key_type&>())), |
| 62 |
bool>())); |
| 63 |
EXPECT_TRUE((std::is_same<typename TypeParam::allocator_type::value_type, |
| 64 |
typename TypeParam::value_type>())); |
| 65 |
EXPECT_TRUE((std::is_same<typename TypeParam::value_type&, |
| 66 |
typename TypeParam::reference>())); |
| 67 |
EXPECT_TRUE((std::is_same<const typename TypeParam::value_type&, |
| 68 |
typename TypeParam::const_reference>())); |
| 69 |
EXPECT_TRUE((std::is_same<typename std::allocator_traits< |
| 70 |
typename TypeParam::allocator_type>::pointer, |
| 71 |
typename TypeParam::pointer>())); |
| 72 |
EXPECT_TRUE( |
| 73 |
(std::is_same<typename std::allocator_traits< |
| 74 |
typename TypeParam::allocator_type>::const_pointer, |
| 75 |
typename TypeParam::const_pointer>())); |
| 76 |
} |
| 77 |
|
| 78 |
TYPED_TEST_P(MembersTest, SimpleFunctions) { |
| 79 |
EXPECT_GT(TypeParam().max_size(), 0); |
| 80 |
} |
| 81 |
|
| 82 |
TYPED_TEST_P(MembersTest, BeginEnd) { |
| 83 |
TypeParam t = {typename TypeParam::value_type{}}; |
| 84 |
EXPECT_EQ(t.begin(), t.cbegin()); |
| 85 |
EXPECT_EQ(t.end(), t.cend()); |
| 86 |
EXPECT_NE(t.begin(), t.end()); |
| 87 |
EXPECT_NE(t.cbegin(), t.cend()); |
| 88 |
} |
| 89 |
|
| 90 |
REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd); |
| 91 |
|
| 92 |
} // namespace priv |
| 93 |
} // namespace phmap |
| 94 |
|
| 95 |
#endif // PHMAP_PRIV_UNORDERED_MAP_MEMBERS_TEST_H_ |