1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- namespace {
- using testing::HasSubstr;
- using testing::internal::GoogleTestFailureException;
- class NonDefaultConstructible {
- public:
- explicit NonDefaultConstructible(int ) {}
- };
- class MockFoo {
- public:
-
-
- MOCK_METHOD0(GetNonDefaultConstructible, NonDefaultConstructible());
- };
- TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
- MockFoo mock;
- try {
-
-
-
-
-
- mock.GetNonDefaultConstructible();
- FAIL() << "GetNonDefaultConstructible()'s return type has no default "
- << "value, so Google Mock should have thrown.";
- } catch (const GoogleTestFailureException& ) {
- FAIL() << "Google Test does not try to catch an exception of type "
- << "GoogleTestFailureException, which is used for reporting "
- << "a failure to other testing frameworks. Google Mock should "
- << "not throw a GoogleTestFailureException as it will kill the "
- << "entire test program instead of just the current TEST.";
- } catch (const std::exception& ex) {
- EXPECT_THAT(ex.what(), HasSubstr("has no default value"));
- }
- }
- }
|