inline_variable_test.cc
Go to the documentation of this file.
00001 // Copyright 2017 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 #include <type_traits>
00016 
00017 #include "absl/base/internal/inline_variable.h"
00018 #include "absl/base/internal/inline_variable_testing.h"
00019 
00020 #include "gtest/gtest.h"
00021 
00022 namespace absl {
00023 namespace inline_variable_testing_internal {
00024 namespace {
00025 
00026 TEST(InlineVariableTest, Constexpr) {
00027   static_assert(inline_variable_foo.value == 5, "");
00028   static_assert(other_inline_variable_foo.value == 5, "");
00029   static_assert(inline_variable_int == 5, "");
00030   static_assert(other_inline_variable_int == 5, "");
00031 }
00032 
00033 TEST(InlineVariableTest, DefaultConstructedIdentityEquality) {
00034   EXPECT_EQ(get_foo_a().value, 5);
00035   EXPECT_EQ(get_foo_b().value, 5);
00036   EXPECT_EQ(&get_foo_a(), &get_foo_b());
00037 }
00038 
00039 TEST(InlineVariableTest, DefaultConstructedIdentityInequality) {
00040   EXPECT_NE(&inline_variable_foo, &other_inline_variable_foo);
00041 }
00042 
00043 TEST(InlineVariableTest, InitializedIdentityEquality) {
00044   EXPECT_EQ(get_int_a(), 5);
00045   EXPECT_EQ(get_int_b(), 5);
00046   EXPECT_EQ(&get_int_a(), &get_int_b());
00047 }
00048 
00049 TEST(InlineVariableTest, InitializedIdentityInequality) {
00050   EXPECT_NE(&inline_variable_int, &other_inline_variable_int);
00051 }
00052 
00053 TEST(InlineVariableTest, FunPtrType) {
00054   static_assert(
00055       std::is_same<void(*)(),
00056                    std::decay<decltype(inline_variable_fun_ptr)>::type>::value,
00057       "");
00058 }
00059 
00060 }  // namespace
00061 }  // namespace inline_variable_testing_internal
00062 }  // namespace absl


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