unordered_map_members_test.h
Go to the documentation of this file.
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 ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_
16 #define ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_
17 
18 #include <type_traits>
19 #include "gmock/gmock.h"
20 #include "gtest/gtest.h"
21 #include "absl/meta/type_traits.h"
22 
23 namespace absl {
24 namespace container_internal {
25 
26 template <class UnordMap>
27 class MembersTest : public ::testing::Test {};
28 
30 
31 template <typename T>
32 void UseType() {}
33 
35  EXPECT_TRUE((std::is_same<std::pair<const typename TypeParam::key_type,
36  typename TypeParam::mapped_type>,
37  typename TypeParam::value_type>()));
38  EXPECT_TRUE((absl::conjunction<
39  absl::negation<std::is_signed<typename TypeParam::size_type>>,
40  std::is_integral<typename TypeParam::size_type>>()));
41  EXPECT_TRUE((absl::conjunction<
42  std::is_signed<typename TypeParam::difference_type>,
43  std::is_integral<typename TypeParam::difference_type>>()));
44  EXPECT_TRUE((std::is_convertible<
45  decltype(std::declval<const typename TypeParam::hasher&>()(
46  std::declval<const typename TypeParam::key_type&>())),
47  size_t>()));
48  EXPECT_TRUE((std::is_convertible<
49  decltype(std::declval<const typename TypeParam::key_equal&>()(
50  std::declval<const typename TypeParam::key_type&>(),
51  std::declval<const typename TypeParam::key_type&>())),
52  bool>()));
53  EXPECT_TRUE((std::is_same<typename TypeParam::allocator_type::value_type,
54  typename TypeParam::value_type>()));
55  EXPECT_TRUE((std::is_same<typename TypeParam::value_type&,
56  typename TypeParam::reference>()));
57  EXPECT_TRUE((std::is_same<const typename TypeParam::value_type&,
58  typename TypeParam::const_reference>()));
59  EXPECT_TRUE((std::is_same<typename std::allocator_traits<
60  typename TypeParam::allocator_type>::pointer,
61  typename TypeParam::pointer>()));
62  EXPECT_TRUE(
63  (std::is_same<typename std::allocator_traits<
64  typename TypeParam::allocator_type>::const_pointer,
65  typename TypeParam::const_pointer>()));
66 }
67 
68 TYPED_TEST_P(MembersTest, SimpleFunctions) {
69  EXPECT_GT(TypeParam().max_size(), 0);
70 }
71 
73  TypeParam t = {typename TypeParam::value_type{}};
74  EXPECT_EQ(t.begin(), t.cbegin());
75  EXPECT_EQ(t.end(), t.cend());
76  EXPECT_NE(t.begin(), t.end());
77  EXPECT_NE(t.cbegin(), t.cend());
78 }
79 
80 REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd);
81 
82 } // namespace container_internal
83 } // namespace absl
84 
85 #endif // ABSL_CONTAINER_INTERNAL_UNORDERED_MAP_MEMBERS_TEST_H_
TYPED_TEST_SUITE_P(ConstructorTest)
Definition: algorithm.h:29
std::pair< std::string, std::string > pair
REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd)
TYPED_TEST_P(ConstructorTest, NoArgs)


abseil_cpp
Author(s):
autogenerated on Tue Jun 18 2019 19:44:37