diff options
Diffstat (limited to 'googlemock/test/gmock-internal-utils_test.cc')
-rw-r--r-- | googlemock/test/gmock-internal-utils_test.cc | 128 |
1 files changed, 58 insertions, 70 deletions
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc index 67865c23..d000e692 100644 --- a/googlemock/test/gmock-internal-utils_test.cc +++ b/googlemock/test/gmock-internal-utils_test.cc @@ -33,17 +33,20 @@ // This file tests the internal utilities. #include "gmock/internal/gmock-internal-utils.h" + #include <stdlib.h> + #include <map> #include <memory> -#include <string> #include <sstream> +#include <string> #include <type_traits> #include <vector> + #include "gmock/gmock.h" #include "gmock/internal/gmock-port.h" -#include "gtest/gtest.h" #include "gtest/gtest-spi.h" +#include "gtest/gtest.h" // Indicates that this translation unit is part of Google Test's // implementation. It must come before gtest-internal-inl.h is @@ -122,15 +125,17 @@ TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) { } TEST(PointeeOfTest, WorksForSmartPointers) { - CompileAssertTypesEqual<int, PointeeOf<std::unique_ptr<int> >::type>(); - CompileAssertTypesEqual<std::string, - PointeeOf<std::shared_ptr<std::string> >::type>(); + EXPECT_TRUE( + (std::is_same<int, PointeeOf<std::unique_ptr<int>>::type>::value)); + EXPECT_TRUE( + (std::is_same<std::string, + PointeeOf<std::shared_ptr<std::string>>::type>::value)); } TEST(PointeeOfTest, WorksForRawPointers) { - CompileAssertTypesEqual<int, PointeeOf<int*>::type>(); - CompileAssertTypesEqual<const char, PointeeOf<const char*>::type>(); - CompileAssertTypesEqual<void, PointeeOf<void*>::type>(); + EXPECT_TRUE((std::is_same<int, PointeeOf<int*>::type>::value)); + EXPECT_TRUE((std::is_same<const char, PointeeOf<const char*>::type>::value)); + EXPECT_TRUE((std::is_void<PointeeOf<void*>::type>::value)); } TEST(GetRawPointerTest, WorksForSmartPointers) { @@ -503,26 +508,6 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) { TestLogWithSeverity("invalid", kWarning, true); } -#endif // GTEST_HAS_STREAM_REDIRECTION - -TEST(TypeTraitsTest, true_type) { - EXPECT_TRUE(true_type::value); -} - -TEST(TypeTraitsTest, false_type) { - EXPECT_FALSE(false_type::value); -} - -TEST(TypeTraitsTest, remove_reference) { - EXPECT_TRUE((std::is_same<char, remove_reference<char&>::type>::value)); - EXPECT_TRUE( - (std::is_same<const int, remove_reference<const int&>::type>::value)); - EXPECT_TRUE((std::is_same<int, remove_reference<int>::type>::value)); - EXPECT_TRUE((std::is_same<double*, remove_reference<double*>::type>::value)); -} - -#if GTEST_HAS_STREAM_REDIRECTION - // Verifies that Log() behaves correctly for the given verbosity level // and log severity. std::string GrabOutput(void(*logger)(), const char* verbosity) { @@ -681,63 +666,66 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) { TEST(FunctionTest, Nullary) { typedef Function<int()> F; // NOLINT EXPECT_EQ(0u, F::ArgumentCount); - CompileAssertTypesEqual<int, F::Result>(); - CompileAssertTypesEqual<std::tuple<>, F::ArgumentTuple>(); - CompileAssertTypesEqual<std::tuple<>, F::ArgumentMatcherTuple>(); - CompileAssertTypesEqual<void(), F::MakeResultVoid>(); - CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>(); + EXPECT_TRUE((std::is_same<int, F::Result>::value)); + EXPECT_TRUE((std::is_same<std::tuple<>, F::ArgumentTuple>::value)); + EXPECT_TRUE((std::is_same<std::tuple<>, F::ArgumentMatcherTuple>::value)); + EXPECT_TRUE((std::is_same<void(), F::MakeResultVoid>::value)); + EXPECT_TRUE((std::is_same<IgnoredValue(), F::MakeResultIgnoredValue>::value)); } TEST(FunctionTest, Unary) { typedef Function<int(bool)> F; // NOLINT EXPECT_EQ(1u, F::ArgumentCount); - CompileAssertTypesEqual<int, F::Result>(); - CompileAssertTypesEqual<bool, F::Arg<0>::type>(); - CompileAssertTypesEqual<std::tuple<bool>, F::ArgumentTuple>(); - CompileAssertTypesEqual<std::tuple<Matcher<bool> >, - F::ArgumentMatcherTuple>(); - CompileAssertTypesEqual<void(bool), F::MakeResultVoid>(); // NOLINT - CompileAssertTypesEqual<IgnoredValue(bool), // NOLINT - F::MakeResultIgnoredValue>(); + EXPECT_TRUE((std::is_same<int, F::Result>::value)); + EXPECT_TRUE((std::is_same<bool, F::Arg<0>::type>::value)); + EXPECT_TRUE((std::is_same<std::tuple<bool>, F::ArgumentTuple>::value)); + EXPECT_TRUE(( + std::is_same<std::tuple<Matcher<bool>>, F::ArgumentMatcherTuple>::value)); + EXPECT_TRUE((std::is_same<void(bool), F::MakeResultVoid>::value)); // NOLINT + EXPECT_TRUE((std::is_same<IgnoredValue(bool), // NOLINT + F::MakeResultIgnoredValue>::value)); } TEST(FunctionTest, Binary) { typedef Function<int(bool, const long&)> F; // NOLINT EXPECT_EQ(2u, F::ArgumentCount); - CompileAssertTypesEqual<int, F::Result>(); - CompileAssertTypesEqual<bool, F::Arg<0>::type>(); - CompileAssertTypesEqual<const long&, F::Arg<1>::type>(); // NOLINT - CompileAssertTypesEqual<std::tuple<bool, const long&>, // NOLINT - F::ArgumentTuple>(); - CompileAssertTypesEqual< - std::tuple<Matcher<bool>, Matcher<const long&> >, // NOLINT - F::ArgumentMatcherTuple>(); - CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>(); // NOLINT - CompileAssertTypesEqual<IgnoredValue(bool, const long&), // NOLINT - F::MakeResultIgnoredValue>(); + EXPECT_TRUE((std::is_same<int, F::Result>::value)); + EXPECT_TRUE((std::is_same<bool, F::Arg<0>::type>::value)); + EXPECT_TRUE((std::is_same<const long&, F::Arg<1>::type>::value)); // NOLINT + EXPECT_TRUE((std::is_same<std::tuple<bool, const long&>, // NOLINT + F::ArgumentTuple>::value)); + EXPECT_TRUE( + (std::is_same<std::tuple<Matcher<bool>, Matcher<const long&>>, // NOLINT + F::ArgumentMatcherTuple>::value)); + EXPECT_TRUE((std::is_same<void(bool, const long&), // NOLINT + F::MakeResultVoid>::value)); + EXPECT_TRUE((std::is_same<IgnoredValue(bool, const long&), // NOLINT + F::MakeResultIgnoredValue>::value)); } TEST(FunctionTest, LongArgumentList) { typedef Function<char(bool, int, char*, int&, const long&)> F; // NOLINT EXPECT_EQ(5u, F::ArgumentCount); - CompileAssertTypesEqual<char, F::Result>(); - CompileAssertTypesEqual<bool, F::Arg<0>::type>(); - CompileAssertTypesEqual<int, F::Arg<1>::type>(); - CompileAssertTypesEqual<char*, F::Arg<2>::type>(); - CompileAssertTypesEqual<int&, F::Arg<3>::type>(); - CompileAssertTypesEqual<const long&, F::Arg<4>::type>(); // NOLINT - CompileAssertTypesEqual< - std::tuple<bool, int, char*, int&, const long&>, // NOLINT - F::ArgumentTuple>(); - CompileAssertTypesEqual< - std::tuple<Matcher<bool>, Matcher<int>, Matcher<char*>, Matcher<int&>, - Matcher<const long&> >, // NOLINT - F::ArgumentMatcherTuple>(); - CompileAssertTypesEqual<void(bool, int, char*, int&, const long&), // NOLINT - F::MakeResultVoid>(); - CompileAssertTypesEqual< - IgnoredValue(bool, int, char*, int&, const long&), // NOLINT - F::MakeResultIgnoredValue>(); + EXPECT_TRUE((std::is_same<char, F::Result>::value)); + EXPECT_TRUE((std::is_same<bool, F::Arg<0>::type>::value)); + EXPECT_TRUE((std::is_same<int, F::Arg<1>::type>::value)); + EXPECT_TRUE((std::is_same<char*, F::Arg<2>::type>::value)); + EXPECT_TRUE((std::is_same<int&, F::Arg<3>::type>::value)); + EXPECT_TRUE((std::is_same<const long&, F::Arg<4>::type>::value)); // NOLINT + EXPECT_TRUE( + (std::is_same<std::tuple<bool, int, char*, int&, const long&>, // NOLINT + F::ArgumentTuple>::value)); + EXPECT_TRUE( + (std::is_same< + std::tuple<Matcher<bool>, Matcher<int>, Matcher<char*>, Matcher<int&>, + Matcher<const long&>>, // NOLINT + F::ArgumentMatcherTuple>::value)); + EXPECT_TRUE( + (std::is_same<void(bool, int, char*, int&, const long&), // NOLINT + F::MakeResultVoid>::value)); + EXPECT_TRUE(( + std::is_same<IgnoredValue(bool, int, char*, int&, const long&), // NOLINT + F::MakeResultIgnoredValue>::value)); } } // namespace |