aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--googlemock/include/gmock/gmock-actions.h4
-rw-r--r--googlemock/test/gmock-internal-utils_test.cc101
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h9
-rw-r--r--googletest/test/gtest_unittest.cc14
4 files changed, 59 insertions, 69 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 9605c43a..9842f320 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -619,7 +619,7 @@ class ReturnVoidAction {
// Allows Return() to be used in any void-returning function.
template <typename Result, typename ArgumentTuple>
static void Perform(const ArgumentTuple&) {
- CompileAssertTypesEqual<void, Result>();
+ static_assert(std::is_void<Result>::value, "Result should be void.");
}
};
@@ -842,7 +842,7 @@ class IgnoreResultAction {
typedef typename internal::Function<F>::Result Result;
// Asserts at compile time that F returns void.
- CompileAssertTypesEqual<void, Result>();
+ static_assert(std::is_void<Result>::value, "Result type should be void.");
return Action<F>(new Impl<F>(action_));
}
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index 7df4078e..d000e692 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -125,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) {
@@ -664,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
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 3a98ce48..62af6692 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -847,15 +847,6 @@ class GTEST_API_ Random {
GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
};
-// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a
-// compiler error if T1 and T2 are different types.
-template <typename T1, typename T2>
-struct CompileAssertTypesEqual;
-
-template <typename T>
-struct CompileAssertTypesEqual<T, T> {
-};
-
// Turns const U&, U&, const U, and U all into U.
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
typename std::remove_const<typename std::remove_reference<T>::type>::type
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 12c5a871..2c0552dc 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -233,7 +233,6 @@ using testing::internal::AppendUserMessage;
using testing::internal::ArrayAwareFind;
using testing::internal::ArrayEq;
using testing::internal::CodePointToUtf8;
-using testing::internal::CompileAssertTypesEqual;
using testing::internal::CopyArray;
using testing::internal::CountIf;
using testing::internal::EqFailure;
@@ -7102,18 +7101,12 @@ TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {
EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value);
}
-// Tests that CompileAssertTypesEqual compiles when the type arguments are
-// equal.
-TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {
- CompileAssertTypesEqual<void, void>();
- CompileAssertTypesEqual<int*, int*>();
-}
-
// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.
template <typename T1, typename T2>
void TestGTestRemoveReferenceAndConst() {
- CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>();
+ static_assert(std::is_same<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>::value,
+ "GTEST_REMOVE_REFERENCE_AND_CONST_ failed.");
}
TEST(RemoveReferenceToConstTest, Works) {
@@ -7128,7 +7121,8 @@ TEST(RemoveReferenceToConstTest, Works) {
template <typename T1, typename T2>
void TestGTestReferenceToConst() {
- CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>();
+ static_assert(std::is_same<T1, GTEST_REFERENCE_TO_CONST_(T2)>::value,
+ "GTEST_REFERENCE_TO_CONST_ failed.");
}
TEST(GTestReferenceToConstTest, Works) {