unordered_set_members_test.h
Go to the documentation of this file.
00001 // Copyright 2019 The Abseil Authors.
00002 //
00003 // Licensed under the Apache License, Version 2.0 (the "License");
00004 // you may not use this file except in compliance with the License.
00005 // You may obtain a copy of the License at
00006 //
00007 //      https://www.apache.org/licenses/LICENSE-2.0
00008 //
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00014 
00015 #ifndef ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_
00016 #define ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_
00017 
00018 #include <type_traits>
00019 #include "gmock/gmock.h"
00020 #include "gtest/gtest.h"
00021 #include "absl/meta/type_traits.h"
00022 
00023 namespace absl {
00024 namespace container_internal {
00025 
00026 template <class UnordSet>
00027 class MembersTest : public ::testing::Test {};
00028 
00029 TYPED_TEST_SUITE_P(MembersTest);
00030 
00031 template <typename T>
00032 void UseType() {}
00033 
00034 TYPED_TEST_P(MembersTest, Typedefs) {
00035   EXPECT_TRUE((std::is_same<typename TypeParam::key_type,
00036                             typename TypeParam::value_type>()));
00037   EXPECT_TRUE((absl::conjunction<
00038                absl::negation<std::is_signed<typename TypeParam::size_type>>,
00039                std::is_integral<typename TypeParam::size_type>>()));
00040   EXPECT_TRUE((absl::conjunction<
00041                std::is_signed<typename TypeParam::difference_type>,
00042                std::is_integral<typename TypeParam::difference_type>>()));
00043   EXPECT_TRUE((std::is_convertible<
00044                decltype(std::declval<const typename TypeParam::hasher&>()(
00045                    std::declval<const typename TypeParam::key_type&>())),
00046                size_t>()));
00047   EXPECT_TRUE((std::is_convertible<
00048                decltype(std::declval<const typename TypeParam::key_equal&>()(
00049                    std::declval<const typename TypeParam::key_type&>(),
00050                    std::declval<const typename TypeParam::key_type&>())),
00051                bool>()));
00052   EXPECT_TRUE((std::is_same<typename TypeParam::allocator_type::value_type,
00053                             typename TypeParam::value_type>()));
00054   EXPECT_TRUE((std::is_same<typename TypeParam::value_type&,
00055                             typename TypeParam::reference>()));
00056   EXPECT_TRUE((std::is_same<const typename TypeParam::value_type&,
00057                             typename TypeParam::const_reference>()));
00058   EXPECT_TRUE((std::is_same<typename std::allocator_traits<
00059                                 typename TypeParam::allocator_type>::pointer,
00060                             typename TypeParam::pointer>()));
00061   EXPECT_TRUE(
00062       (std::is_same<typename std::allocator_traits<
00063                         typename TypeParam::allocator_type>::const_pointer,
00064                     typename TypeParam::const_pointer>()));
00065 }
00066 
00067 TYPED_TEST_P(MembersTest, SimpleFunctions) {
00068   EXPECT_GT(TypeParam().max_size(), 0);
00069 }
00070 
00071 TYPED_TEST_P(MembersTest, BeginEnd) {
00072   TypeParam t = {typename TypeParam::value_type{}};
00073   EXPECT_EQ(t.begin(), t.cbegin());
00074   EXPECT_EQ(t.end(), t.cend());
00075   EXPECT_NE(t.begin(), t.end());
00076   EXPECT_NE(t.cbegin(), t.cend());
00077 }
00078 
00079 REGISTER_TYPED_TEST_SUITE_P(MembersTest, Typedefs, SimpleFunctions, BeginEnd);
00080 
00081 }  // namespace container_internal
00082 }  // namespace absl
00083 
00084 #endif  // ABSL_CONTAINER_INTERNAL_UNORDERED_SET_MEMBERS_TEST_H_


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:16