tesseract v5.3.3.20231005
testing::gmock_nice_strict_test Namespace Reference

Classes

class  CallsMockMethodInDestructor
 
class  Foo
 
class  MockBar
 
class  MockBaz
 
class  MockFoo
 
class  NotDefaultConstructible
 

Functions

 TEST (NiceMockTest, AllowsExpectedCall)
 
 TEST (NiceMockTest, ThrowsExceptionForUnknownReturnTypes)
 
 TEST (NiceMockTest, UnexpectedCallFails)
 
 TEST (NiceMockTest, NonDefaultConstructor)
 
 TEST (NiceMockTest, NonDefaultConstructor10)
 
 TEST (NiceMockTest, AllowLeak)
 
 TEST (NiceMockTest, MoveOnlyConstructor)
 
 TEST (NiceMockTest, AcceptsClassNamedMock)
 
 TEST (NiceMockTest, IsNiceInDestructor)
 
 TEST (NiceMockTest, IsNaggy_IsNice_IsStrict)
 
 TEST (NaggyMockTest, AllowsExpectedCall)
 
 TEST (NaggyMockTest, UnexpectedCallFails)
 
 TEST (NaggyMockTest, NonDefaultConstructor)
 
 TEST (NaggyMockTest, NonDefaultConstructor10)
 
 TEST (NaggyMockTest, AllowLeak)
 
 TEST (NaggyMockTest, MoveOnlyConstructor)
 
 TEST (NaggyMockTest, AcceptsClassNamedMock)
 
 TEST (NaggyMockTest, IsNaggyInDestructor)
 
 TEST (NaggyMockTest, IsNaggy_IsNice_IsStrict)
 
 TEST (StrictMockTest, AllowsExpectedCall)
 
 TEST (StrictMockTest, UnexpectedCallFails)
 
 TEST (StrictMockTest, UninterestingCallFails)
 
 TEST (StrictMockTest, UninterestingCallFailsAfterDeath)
 
 TEST (StrictMockTest, NonDefaultConstructor)
 
 TEST (StrictMockTest, NonDefaultConstructor10)
 
 TEST (StrictMockTest, AllowLeak)
 
 TEST (StrictMockTest, MoveOnlyConstructor)
 
 TEST (StrictMockTest, AcceptsClassNamedMock)
 
 TEST (StrictMockTest, IsStrictInDestructor)
 
 TEST (StrictMockTest, IsNaggy_IsNice_IsStrict)
 

Function Documentation

◆ TEST() [1/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
AcceptsClassNamedMock   
)

Definition at line 415 of file gmock-nice-strict_test.cc.

415 {
416 NaggyMock< ::Mock> naggy;
417 EXPECT_CALL(naggy, DoThis());
418 naggy.DoThis();
419}
#define EXPECT_CALL(obj, call)

◆ TEST() [2/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
AllowLeak   
)

Definition at line 402 of file gmock-nice-strict_test.cc.

402 {
404 Mock::AllowLeak(leaked);
405 EXPECT_CALL(*leaked, DoThis());
406 leaked->DoThis();
407}

◆ TEST() [3/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
AllowsExpectedCall   
)

Definition at line 365 of file gmock-nice-strict_test.cc.

365 {
366 NaggyMock<MockFoo> naggy_foo;
367
368 EXPECT_CALL(naggy_foo, DoThis());
369 naggy_foo.DoThis();
370}

◆ TEST() [4/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
IsNaggy_IsNice_IsStrict   
)

Definition at line 437 of file gmock-nice-strict_test.cc.

437 {
438 NaggyMock<MockFoo> naggy_foo;
439 EXPECT_TRUE(Mock::IsNaggy(&naggy_foo));
440 EXPECT_FALSE(Mock::IsNice(&naggy_foo));
441 EXPECT_FALSE(Mock::IsStrict(&naggy_foo));
442}
#define EXPECT_TRUE(condition)
Definition: gtest.h:1982
#define EXPECT_FALSE(condition)
Definition: gtest.h:1986

◆ TEST() [5/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
IsNaggyInDestructor   
)

Definition at line 421 of file gmock-nice-strict_test.cc.

421 {
422 const std::string saved_flag = GMOCK_FLAG(verbose);
423 GMOCK_FLAG(verbose) = "warning";
425
426 {
428 // Don't add an expectation for the call before the mock goes out of scope.
429 }
430
432 HasSubstr("Uninteresting mock function call"));
433
434 GMOCK_FLAG(verbose) = saved_flag;
435}
#define GMOCK_FLAG(name)
Definition: gmock-port.h:67
#define EXPECT_THAT(value, matcher)
GTEST_API_ void CaptureStdout()
GTEST_API_ std::string GetCapturedStdout()

◆ TEST() [6/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
MoveOnlyConstructor   
)

◆ TEST() [7/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
NonDefaultConstructor   
)

Definition at line 383 of file gmock-nice-strict_test.cc.

383 {
384 NaggyMock<MockBar> naggy_bar("hi");
385 EXPECT_EQ("hi", naggy_bar.str());
386
387 naggy_bar.This();
388 naggy_bar.That(5, true);
389}
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:2043

◆ TEST() [8/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
NonDefaultConstructor10   
)

Definition at line 393 of file gmock-nice-strict_test.cc.

393 {
394 NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5',
395 "6", "7", true, false);
396 EXPECT_EQ("01234567TF", naggy_bar.str());
397
398 naggy_bar.This();
399 naggy_bar.That(5, true);
400}

◆ TEST() [9/30]

testing::gmock_nice_strict_test::TEST ( NaggyMockTest  ,
UnexpectedCallFails   
)

Definition at line 373 of file gmock-nice-strict_test.cc.

373 {
374 NaggyMock<MockFoo> naggy_foo;
375
376 EXPECT_CALL(naggy_foo, DoThis()).Times(0);
377 EXPECT_NONFATAL_FAILURE(naggy_foo.DoThis(),
378 "called more times than expected");
379}
#define EXPECT_NONFATAL_FAILURE(statement, substr)

◆ TEST() [10/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
AcceptsClassNamedMock   
)

Definition at line 305 of file gmock-nice-strict_test.cc.

305 {
307 EXPECT_CALL(nice, DoThis());
308 nice.DoThis();
309}

◆ TEST() [11/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
AllowLeak   
)

Definition at line 292 of file gmock-nice-strict_test.cc.

292 {
294 Mock::AllowLeak(leaked);
295 EXPECT_CALL(*leaked, DoThis());
296 leaked->DoThis();
297}

◆ TEST() [12/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
AllowsExpectedCall   
)

Definition at line 239 of file gmock-nice-strict_test.cc.

239 {
240 NiceMock<MockFoo> nice_foo;
241
242 EXPECT_CALL(nice_foo, DoThis());
243 nice_foo.DoThis();
244}

◆ TEST() [13/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
IsNaggy_IsNice_IsStrict   
)

Definition at line 318 of file gmock-nice-strict_test.cc.

318 {
319 NiceMock<MockFoo> nice_foo;
320 EXPECT_FALSE(Mock::IsNaggy(&nice_foo));
321 EXPECT_TRUE(Mock::IsNice(&nice_foo));
322 EXPECT_FALSE(Mock::IsStrict(&nice_foo));
323}

◆ TEST() [14/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
IsNiceInDestructor   
)

Definition at line 311 of file gmock-nice-strict_test.cc.

311 {
312 {
314 // Don't add an expectation for the call before the mock goes out of scope.
315 }
316}

◆ TEST() [15/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
MoveOnlyConstructor   
)

Definition at line 299 of file gmock-nice-strict_test.cc.

299 {
301}

◆ TEST() [16/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
NonDefaultConstructor   
)

Definition at line 273 of file gmock-nice-strict_test.cc.

273 {
274 NiceMock<MockBar> nice_bar("hi");
275 EXPECT_EQ("hi", nice_bar.str());
276
277 nice_bar.This();
278 nice_bar.That(5, true);
279}

◆ TEST() [17/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
NonDefaultConstructor10   
)

Definition at line 283 of file gmock-nice-strict_test.cc.

283 {
284 NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f',
285 "g", "h", true, false);
286 EXPECT_EQ("abcdefghTF", nice_bar.str());
287
288 nice_bar.This();
289 nice_bar.That(5, true);
290}

◆ TEST() [18/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
ThrowsExceptionForUnknownReturnTypes   
)

Definition at line 249 of file gmock-nice-strict_test.cc.

249 {
250 NiceMock<MockFoo> nice_foo;
251#if GTEST_HAS_EXCEPTIONS
252 try {
253 nice_foo.ReturnNonDefaultConstructible();
254 FAIL();
255 } catch (const std::runtime_error& ex) {
256 EXPECT_THAT(ex.what(), HasSubstr("ReturnNonDefaultConstructible"));
257 }
258#else
259 EXPECT_DEATH_IF_SUPPORTED({ nice_foo.ReturnNonDefaultConstructible(); }, "");
260#endif
261}
#define FAIL()
Definition: gtest.h:1928
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)

◆ TEST() [19/30]

testing::gmock_nice_strict_test::TEST ( NiceMockTest  ,
UnexpectedCallFails   
)

Definition at line 264 of file gmock-nice-strict_test.cc.

264 {
265 NiceMock<MockFoo> nice_foo;
266
267 EXPECT_CALL(nice_foo, DoThis()).Times(0);
268 EXPECT_NONFATAL_FAILURE(nice_foo.DoThis(), "called more times than expected");
269}

◆ TEST() [20/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
AcceptsClassNamedMock   
)

Definition at line 515 of file gmock-nice-strict_test.cc.

515 {
516 StrictMock< ::Mock> strict;
517 EXPECT_CALL(strict, DoThis());
518 strict.DoThis();
519}

◆ TEST() [21/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
AllowLeak   
)

Definition at line 502 of file gmock-nice-strict_test.cc.

502 {
504 Mock::AllowLeak(leaked);
505 EXPECT_CALL(*leaked, DoThis());
506 leaked->DoThis();
507}

◆ TEST() [22/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
AllowsExpectedCall   
)

Definition at line 445 of file gmock-nice-strict_test.cc.

445 {
446 StrictMock<MockFoo> strict_foo;
447
448 EXPECT_CALL(strict_foo, DoThis());
449 strict_foo.DoThis();
450}

◆ TEST() [23/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
IsNaggy_IsNice_IsStrict   
)

Definition at line 531 of file gmock-nice-strict_test.cc.

531 {
532 StrictMock<MockFoo> strict_foo;
533 EXPECT_FALSE(Mock::IsNaggy(&strict_foo));
534 EXPECT_FALSE(Mock::IsNice(&strict_foo));
535 EXPECT_TRUE(Mock::IsStrict(&strict_foo));
536}

◆ TEST() [24/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
IsStrictInDestructor   
)

Definition at line 521 of file gmock-nice-strict_test.cc.

521 {
523 {
525 // Don't add an expectation for the call before the mock goes out of
526 // scope.
527 },
528 "Uninteresting mock function call");
529}

◆ TEST() [25/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
MoveOnlyConstructor   
)

Definition at line 509 of file gmock-nice-strict_test.cc.

509 {
511}

◆ TEST() [26/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
NonDefaultConstructor   
)

Definition at line 483 of file gmock-nice-strict_test.cc.

483 {
484 StrictMock<MockBar> strict_bar("hi");
485 EXPECT_EQ("hi", strict_bar.str());
486
487 EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
488 "Uninteresting mock function call");
489}

◆ TEST() [27/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
NonDefaultConstructor10   
)

Definition at line 493 of file gmock-nice-strict_test.cc.

493 {
494 StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f',
495 "g", "h", true, false);
496 EXPECT_EQ("abcdefghTF", strict_bar.str());
497
498 EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
499 "Uninteresting mock function call");
500}

◆ TEST() [28/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
UnexpectedCallFails   
)

Definition at line 453 of file gmock-nice-strict_test.cc.

453 {
454 StrictMock<MockFoo> strict_foo;
455
456 EXPECT_CALL(strict_foo, DoThis()).Times(0);
457 EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),
458 "called more times than expected");
459}

◆ TEST() [29/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
UninterestingCallFails   
)

Definition at line 462 of file gmock-nice-strict_test.cc.

462 {
463 StrictMock<MockFoo> strict_foo;
464
465 EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),
466 "Uninteresting mock function call");
467}

◆ TEST() [30/30]

testing::gmock_nice_strict_test::TEST ( StrictMockTest  ,
UninterestingCallFailsAfterDeath   
)

Definition at line 471 of file gmock-nice-strict_test.cc.

471 {
472 StrictMock<MockFoo>* const strict_foo = new StrictMock<MockFoo>;
473
474 ON_CALL(*strict_foo, DoThis())
475 .WillByDefault(Invoke(strict_foo, &MockFoo::Delete));
476
477 EXPECT_NONFATAL_FAILURE(strict_foo->DoThis(),
478 "Uninteresting mock function call");
479}
#define ON_CALL(obj, call)
std::decay< FunctionImpl >::type Invoke(FunctionImpl &&function_impl)