Googletest export
Remove the #ifs for old, unsupported and buggy compilers: * old versions of GCC & MSVC * Symbian PiperOrigin-RevId: 227116941
This commit is contained in:
committed by
Gennadiy Civil
parent
933e5df283
commit
f8b1c1af17
@@ -444,19 +444,12 @@ class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
|
||||
}
|
||||
};
|
||||
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
// Compiling this test on Nokia's Symbian compiler fails with:
|
||||
// 'Result' is not a member of class 'testing::internal::Function<int>'
|
||||
// (point of instantiation: '@unnamed@gmock_actions_test_cc@::
|
||||
// ActionTest_CanBeConvertedToOtherActionType_Test::TestBody()')
|
||||
// with no obvious fix.
|
||||
TEST(ActionTest, CanBeConvertedToOtherActionType) {
|
||||
const Action<bool(int)> a1(new IsNotZero); // NOLINT
|
||||
const Action<int(char)> a2 = Action<int(char)>(a1); // NOLINT
|
||||
EXPECT_EQ(1, a2.Perform(std::make_tuple('a')));
|
||||
EXPECT_EQ(0, a2.Perform(std::make_tuple('\0')));
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
|
||||
// The following two classes are for testing MakePolymorphicAction().
|
||||
|
||||
@@ -805,9 +798,7 @@ TEST(SetArgPointeeTest, SetsTheNthPointee) {
|
||||
EXPECT_EQ('a', ch);
|
||||
}
|
||||
|
||||
#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
|
||||
// Tests that SetArgPointee<N>() accepts a string literal.
|
||||
// GCC prior to v4.0 and the Symbian compiler do not support this.
|
||||
TEST(SetArgPointeeTest, AcceptsStringLiteral) {
|
||||
typedef void MyFunction(std::string*, const char**);
|
||||
Action<MyFunction> a = SetArgPointee<0>("hi");
|
||||
@@ -841,7 +832,6 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
|
||||
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Tests that SetArgPointee<N>() accepts a char pointer.
|
||||
TEST(SetArgPointeeTest, AcceptsCharPointer) {
|
||||
|
||||
@@ -45,13 +45,6 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// There is a bug in MSVC (fixed in VS 2008) that prevents creating a
|
||||
// mock for a function with const arguments, so we don't test such
|
||||
// cases for MSVC versions older than 2008.
|
||||
#if !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)
|
||||
# define GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
#endif // !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)
|
||||
|
||||
namespace testing {
|
||||
namespace gmock_function_mocker_test {
|
||||
|
||||
@@ -84,9 +77,7 @@ class FooInterface {
|
||||
|
||||
virtual bool TakesNonConstReference(int& n) = 0; // NOLINT
|
||||
virtual std::string TakesConstReference(const int& n) = 0;
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
virtual bool TakesConst(const int x) = 0;
|
||||
#endif // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
|
||||
virtual int OverloadedOnArgumentNumber() = 0;
|
||||
virtual int OverloadedOnArgumentNumber(int n) = 0;
|
||||
@@ -137,10 +128,7 @@ class MockFoo : public FooInterface {
|
||||
|
||||
MOCK_METHOD(bool, TakesNonConstReference, (int&)); // NOLINT
|
||||
MOCK_METHOD(std::string, TakesConstReference, (const int&));
|
||||
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
MOCK_METHOD(bool, TakesConst, (const int)); // NOLINT
|
||||
#endif
|
||||
|
||||
// Tests that the function return type can contain unprotected comma.
|
||||
MOCK_METHOD((std::map<int, std::string>), ReturnTypeWithComma, (), ());
|
||||
@@ -248,7 +236,6 @@ TEST_F(MockMethodFunctionMockerTest, MocksFunctionWithConstReferenceArgument) {
|
||||
EXPECT_EQ("Hello", foo_->TakesConstReference(a));
|
||||
}
|
||||
|
||||
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
// Tests mocking a function that takes a const variable.
|
||||
TEST_F(MockMethodFunctionMockerTest, MocksFunctionWithConstArgument) {
|
||||
EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))
|
||||
@@ -256,7 +243,6 @@ TEST_F(MockMethodFunctionMockerTest, MocksFunctionWithConstArgument) {
|
||||
|
||||
EXPECT_FALSE(foo_->TakesConst(5));
|
||||
}
|
||||
#endif // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
|
||||
|
||||
// Tests mocking functions overloaded on the number of arguments.
|
||||
TEST_F(MockMethodFunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {
|
||||
|
||||
@@ -145,7 +145,6 @@ TEST(GetRawPointerTest, WorksForSmartPointers) {
|
||||
|
||||
TEST(GetRawPointerTest, WorksForRawPointers) {
|
||||
int* p = nullptr;
|
||||
// Don't use EXPECT_EQ as no NULL-testing magic on Symbian.
|
||||
EXPECT_TRUE(nullptr == GetRawPointer(p));
|
||||
int n = 1;
|
||||
EXPECT_EQ(&n, GetRawPointer(&n));
|
||||
@@ -521,12 +520,6 @@ TEST(TypeTraitsTest, is_reference) {
|
||||
EXPECT_TRUE(is_reference<const int&>::value);
|
||||
}
|
||||
|
||||
TEST(TypeTraitsTest, is_pointer) {
|
||||
EXPECT_FALSE(is_pointer<int>::value);
|
||||
EXPECT_FALSE(is_pointer<char&>::value);
|
||||
EXPECT_TRUE(is_pointer<const int*>::value);
|
||||
}
|
||||
|
||||
TEST(TypeTraitsTest, type_equals) {
|
||||
EXPECT_FALSE((type_equals<int, const int>::value));
|
||||
EXPECT_FALSE((type_equals<int, int&>::value));
|
||||
|
||||
@@ -1167,20 +1167,10 @@ TEST(IsNullTest, MatchesNullPointer) {
|
||||
EXPECT_TRUE(m2.Matches(p2));
|
||||
EXPECT_FALSE(m2.Matches("hi"));
|
||||
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
// Nokia's Symbian compiler generates:
|
||||
// gmock-matchers.h: ambiguous access to overloaded function
|
||||
// gmock-matchers.h: 'testing::Matcher<void *>::Matcher(void *)'
|
||||
// gmock-matchers.h: 'testing::Matcher<void *>::Matcher(const testing::
|
||||
// MatcherInterface<void *> *)'
|
||||
// gmock-matchers.h: (point of instantiation: 'testing::
|
||||
// gmock_matchers_test::IsNullTest_MatchesNullPointer_Test::TestBody()')
|
||||
// gmock-matchers.h: (instantiating: 'testing::PolymorphicMatc
|
||||
Matcher<void*> m3 = IsNull();
|
||||
void* p3 = nullptr;
|
||||
EXPECT_TRUE(m3.Matches(p3));
|
||||
EXPECT_FALSE(m3.Matches(reinterpret_cast<void*>(0xbeef)));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(IsNullTest, StdFunction) {
|
||||
@@ -3168,20 +3158,8 @@ TEST(MatcherAssertionTest, WorksForByRefArguments) {
|
||||
"Actual: 0" + OfType("int") + ", which is located @");
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN
|
||||
// Tests that ASSERT_THAT() and EXPECT_THAT() work when the matcher is
|
||||
// monomorphic.
|
||||
|
||||
// ASSERT_THAT("hello", starts_with_he) fails to compile with Nokia's
|
||||
// Symbian compiler: it tries to compile
|
||||
// template<T, U> class MatcherCastImpl { ...
|
||||
// virtual bool MatchAndExplain(T x, ...) const {
|
||||
// return source_matcher_.MatchAndExplain(static_cast<U>(x), ...);
|
||||
// with U == string and T == const char*
|
||||
// With ASSERT_THAT("hello"...) changed to ASSERT_THAT(string("hello") ... )
|
||||
// the compiler silently crashes with no output.
|
||||
// If MatcherCastImpl is changed to use U(x) instead of static_cast<U>(x)
|
||||
// the code compiles but the converted string is bogus.
|
||||
TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
|
||||
Matcher<const char*> starts_with_he = StartsWith("he");
|
||||
ASSERT_THAT("hello", starts_with_he);
|
||||
@@ -3199,7 +3177,6 @@ TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
|
||||
"Expected: is > 5\n"
|
||||
" Actual: 5" + OfType("int"));
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN
|
||||
|
||||
// Tests floating-point matchers.
|
||||
template <typename RawType>
|
||||
|
||||
@@ -294,21 +294,13 @@ TEST(NiceMockTest, MoveOnlyConstructor) {
|
||||
NiceMock<MockBaz> nice_baz(MockBaz::MoveOnly{});
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
// Tests that NiceMock<Mock> compiles where Mock is a user-defined
|
||||
// class (as opposed to ::testing::Mock). We had to work around an
|
||||
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
|
||||
// NiceMock to be looked up in the wrong context, and this test
|
||||
// ensures that our fix works.
|
||||
//
|
||||
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||
// causes the program to crash there, for reasons unclear to us yet.
|
||||
// class (as opposed to ::testing::Mock).
|
||||
TEST(NiceMockTest, AcceptsClassNamedMock) {
|
||||
NiceMock< ::Mock> nice;
|
||||
EXPECT_CALL(nice, DoThis());
|
||||
nice.DoThis();
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
TEST(NiceMockTest, IsNaggy_IsNice_IsStrict) {
|
||||
NiceMock<MockFoo> nice_foo;
|
||||
@@ -405,21 +397,13 @@ TEST(NaggyMockTest, MoveOnlyConstructor) {
|
||||
NaggyMock<MockBaz> naggy_baz(MockBaz::MoveOnly{});
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
// Tests that NaggyMock<Mock> compiles where Mock is a user-defined
|
||||
// class (as opposed to ::testing::Mock). We had to work around an
|
||||
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
|
||||
// NaggyMock to be looked up in the wrong context, and this test
|
||||
// ensures that our fix works.
|
||||
//
|
||||
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||
// causes the program to crash there, for reasons unclear to us yet.
|
||||
// class (as opposed to ::testing::Mock).
|
||||
TEST(NaggyMockTest, AcceptsClassNamedMock) {
|
||||
NaggyMock< ::Mock> naggy;
|
||||
EXPECT_CALL(naggy, DoThis());
|
||||
naggy.DoThis();
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
TEST(NaggyMockTest, IsNaggy_IsNice_IsStrict) {
|
||||
NaggyMock<MockFoo> naggy_foo;
|
||||
@@ -497,21 +481,13 @@ TEST(StrictMockTest, MoveOnlyConstructor) {
|
||||
StrictMock<MockBaz> strict_baz(MockBaz::MoveOnly{});
|
||||
}
|
||||
|
||||
#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
// Tests that StrictMock<Mock> compiles where Mock is a user-defined
|
||||
// class (as opposed to ::testing::Mock). We had to work around an
|
||||
// MSVC 8.0 bug that caused the symbol Mock used in the definition of
|
||||
// StrictMock to be looked up in the wrong context, and this test
|
||||
// ensures that our fix works.
|
||||
//
|
||||
// We have to skip this test on Symbian and Windows Mobile, as it
|
||||
// causes the program to crash there, for reasons unclear to us yet.
|
||||
// class (as opposed to ::testing::Mock).
|
||||
TEST(StrictMockTest, AcceptsClassNamedMock) {
|
||||
StrictMock< ::Mock> strict;
|
||||
EXPECT_CALL(strict, DoThis());
|
||||
strict.DoThis();
|
||||
}
|
||||
#endif // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
TEST(StrictMockTest, IsNaggy_IsNice_IsStrict) {
|
||||
StrictMock<MockFoo> strict_foo;
|
||||
|
||||
Reference in New Issue
Block a user