diff options
author | Joshua Cannon <joshdcannon@gmail.com> | 2019-10-23 19:46:46 (GMT) |
---|---|---|
committer | Joshua Cannon <joshdcannon@gmail.com> | 2019-10-23 19:46:46 (GMT) |
commit | 676d0444bf95d0ffba07973dcc7234e645acdb91 (patch) | |
tree | ac04fdea16ae4f4709ab50777edb995cea7bd5cf /googlemock/test/gmock-function-mocker_test.cc | |
parent | 1110c471cadf9cf40cb735890d67f135d6313471 (diff) | |
download | googletest-676d0444bf95d0ffba07973dcc7234e645acdb91.zip googletest-676d0444bf95d0ffba07973dcc7234e645acdb91.tar.gz googletest-676d0444bf95d0ffba07973dcc7234e645acdb91.tar.bz2 |
Revert "Merge pull request #2498 from thejcannon:noexcept_spec"refs/pull/2533/head
This reverts commit ba513d2c9525a7c986c115ed5d603f2cf17c6016, reversing
changes made to a3ca5b9e0bf9abc3bc639684966085c4d3182578.
Diffstat (limited to 'googlemock/test/gmock-function-mocker_test.cc')
-rw-r--r-- | googlemock/test/gmock-function-mocker_test.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 55be70a..90d6b5f 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -42,6 +42,8 @@ #include <map> #include <string> +#include <type_traits> + #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -663,5 +665,32 @@ TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) { EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes4)); } +void hasTwoParams(int, int); +void MaybeThrows(); +void DoesntThrow() noexcept; +struct MockMethodNoexceptSpecifier { + MOCK_METHOD(void, func1, (), (noexcept)); + MOCK_METHOD(void, func2, (), (noexcept(true))); + MOCK_METHOD(void, func3, (), (noexcept(false))); + MOCK_METHOD(void, func4, (), (noexcept(noexcept(MaybeThrows())))); + MOCK_METHOD(void, func5, (), (noexcept(noexcept(DoesntThrow())))); + MOCK_METHOD(void, func6, (), (noexcept(noexcept(DoesntThrow())), const)); + MOCK_METHOD(void, func7, (), (const, noexcept(noexcept(DoesntThrow())))); + // Put commas in the noexcept expression + MOCK_METHOD(void, func8, (), (noexcept(noexcept(hasTwoParams(1, 2))), const)); +}; + +TEST(MockMethodMockFunctionTest, NoexceptSpecifierPreserved) { + EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func1())); + EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func2())); + EXPECT_FALSE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func3())); + EXPECT_FALSE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func4())); + EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func5())); + EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func6())); + EXPECT_TRUE(noexcept(std::declval<MockMethodNoexceptSpecifier>().func7())); + EXPECT_EQ(noexcept(std::declval<MockMethodNoexceptSpecifier>().func8()), + noexcept(hasTwoParams(1, 2))); +} + } // namespace gmock_function_mocker_test } // namespace testing |