30 #include "gmock/gmock-nice-strict.h"
34 #include "gmock/gmock.h"
35 #include "gtest/gtest-spi.h"
36 #include "gtest/gtest.h"
51 namespace gmock_nice_strict_test {
59 #if GTEST_HAS_STREAM_REDIRECTION
100 static_cast<char>(a6) + a7 + a8 + (a9 ?
'T' :
'F') + (a10 ?
'T' :
'F');
133 #if GTEST_HAS_STREAM_REDIRECTION
136 TEST(RawMockTest, WarningForUninterestingCall) {
144 raw_foo.DoThat(
true);
146 HasSubstr(
"Uninteresting mock function call"));
153 TEST(RawMockTest, WarningForUninterestingCallAfterDeath) {
157 MockFoo*
const raw_foo =
new MockFoo;
165 HasSubstr(
"Uninteresting mock function call"));
172 TEST(RawMockTest, InfoForUninterestingCall) {
180 HasSubstr(
"Uninteresting mock function call"));
185 TEST(RawMockTest, IsNaggy_IsNice_IsStrict) {
193 TEST(NiceMockTest, NoWarningForUninterestingCall) {
194 NiceMock<MockFoo> nice_foo;
198 nice_foo.DoThat(
true);
204 TEST(NiceMockTest, NoWarningForUninterestingCallAfterDeath) {
205 NiceMock<MockFoo>*
const nice_foo =
new NiceMock<MockFoo>;
217 TEST(NiceMockTest, InfoForUninterestingCall) {
218 NiceMock<MockFoo> nice_foo;
225 HasSubstr(
"Uninteresting mock function call"));
230 #endif // GTEST_HAS_STREAM_REDIRECTION
233 TEST(NiceMockTest, AllowsExpectedCall) {
243 TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) {
245 #if GTEST_HAS_EXCEPTIONS
247 nice_foo.ReturnNonDefaultConstructible();
249 }
catch (
const std::runtime_error&
ex) {
258 TEST(NiceMockTest, UnexpectedCallFails) {
267 TEST(NiceMockTest, NonDefaultConstructor) {
272 nice_bar.That(5,
true);
277 TEST(NiceMockTest, NonDefaultConstructor10) {
279 "g",
"h",
true,
false);
283 nice_bar.That(5,
true);
286 TEST(NiceMockTest, AllowLeak) {
288 Mock::AllowLeak(leaked);
293 TEST(NiceMockTest, MoveOnlyConstructor) {
299 TEST(NiceMockTest, AcceptsClassNamedMock) {
305 TEST(NiceMockTest, IsNaggy_IsNice_IsStrict) {
312 #if GTEST_HAS_STREAM_REDIRECTION
315 TEST(NaggyMockTest, WarningForUninterestingCall) {
323 naggy_foo.DoThat(
true);
325 HasSubstr(
"Uninteresting mock function call"));
332 TEST(NaggyMockTest, WarningForUninterestingCallAfterDeath) {
336 NaggyMock<MockFoo>*
const naggy_foo =
new NaggyMock<MockFoo>;
344 HasSubstr(
"Uninteresting mock function call"));
349 #endif // GTEST_HAS_STREAM_REDIRECTION
352 TEST(NaggyMockTest, AllowsExpectedCall) {
360 TEST(NaggyMockTest, UnexpectedCallFails) {
365 "called more times than expected");
370 TEST(NaggyMockTest, NonDefaultConstructor) {
375 naggy_bar.That(5,
true);
380 TEST(NaggyMockTest, NonDefaultConstructor10) {
382 "6",
"7",
true,
false);
383 EXPECT_EQ(
"01234567TF", naggy_bar.str());
386 naggy_bar.That(5,
true);
389 TEST(NaggyMockTest, AllowLeak) {
391 Mock::AllowLeak(leaked);
396 TEST(NaggyMockTest, MoveOnlyConstructor) {
402 TEST(NaggyMockTest, AcceptsClassNamedMock) {
408 TEST(NaggyMockTest, IsNaggy_IsNice_IsStrict) {
416 TEST(StrictMockTest, AllowsExpectedCall) {
424 TEST(StrictMockTest, UnexpectedCallFails) {
429 "called more times than expected");
433 TEST(StrictMockTest, UninterestingCallFails) {
437 "Uninteresting mock function call");
442 TEST(StrictMockTest, UninterestingCallFailsAfterDeath) {
449 "Uninteresting mock function call");
454 TEST(StrictMockTest, NonDefaultConstructor) {
459 "Uninteresting mock function call");
464 TEST(StrictMockTest, NonDefaultConstructor10) {
466 "g",
"h",
true,
false);
467 EXPECT_EQ(
"abcdefghTF", strict_bar.str());
470 "Uninteresting mock function call");
473 TEST(StrictMockTest, AllowLeak) {
475 Mock::AllowLeak(leaked);
480 TEST(StrictMockTest, MoveOnlyConstructor) {
486 TEST(StrictMockTest, AcceptsClassNamedMock) {
492 TEST(StrictMockTest, IsNaggy_IsNice_IsStrict) {