gmock-nice-strict_test.cc 15.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Gennadiy Civil's avatar
 
Gennadiy Civil committed
29

Abseil Team's avatar
Abseil Team committed
30
#include "gmock/gmock-nice-strict.h"
31
32

#include <string>
Gennadiy Civil's avatar
 
Gennadiy Civil committed
33
#include <utility>
34
35
#include "gmock/gmock.h"
#include "gtest/gtest-spi.h"
Gennadiy Civil's avatar
 
Gennadiy Civil committed
36
#include "gtest/gtest.h"
37

38
39
40
41
// This must not be defined inside the ::testing namespace, or it will
// clash with ::testing::Mock.
class Mock {
 public:
42
43
  Mock() {}

44
  MOCK_METHOD0(DoThis, void());
45
46
47

 private:
  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);
48
49
};

50
51
52
53
namespace testing {
namespace gmock_nice_strict_test {

using testing::HasSubstr;
zhanyong.wan's avatar
zhanyong.wan committed
54
using testing::NaggyMock;
55
56
57
using testing::NiceMock;
using testing::StrictMock;

58
#if GTEST_HAS_STREAM_REDIRECTION
59
60
using testing::internal::CaptureStdout;
using testing::internal::GetCapturedStdout;
61
#endif
62

63
64
// Class without default constructor.
class NotDefaultConstructible {
65
 public:
66
  explicit NotDefaultConstructible(int) {}
67
68
};

Abseil Team's avatar
Abseil Team committed
69
70
71
72
73
74
class CallsMockMethodInDestructor {
 public:
  ~CallsMockMethodInDestructor() { OnDestroy(); }
  MOCK_METHOD(void, OnDestroy, ());
};

75
76
77
78
79
80
81
82
83
84
85
86
// Defines some mock classes needed by the tests.

class Foo {
 public:
  virtual ~Foo() {}

  virtual void DoThis() = 0;
  virtual int DoThat(bool flag) = 0;
};

class MockFoo : public Foo {
 public:
87
  MockFoo() {}
88
89
90
91
  void Delete() { delete this; }

  MOCK_METHOD0(DoThis, void());
  MOCK_METHOD1(DoThat, int(bool flag));
92
  MOCK_METHOD0(ReturnNonDefaultConstructible, NotDefaultConstructible());
93
94
95

 private:
  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);
96
97
98
99
};

class MockBar {
 public:
100
  explicit MockBar(const std::string& s) : str_(s) {}
101

102
103
104
  MockBar(char a1, char a2, std::string a3, std::string a4, int a5, int a6,
          const std::string& a7, const std::string& a8, bool a9, bool a10) {
    str_ = std::string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) +
105
106
107
108
109
        static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') + (a10 ? 'T' : 'F');
  }

  virtual ~MockBar() {}

110
  const std::string& str() const { return str_; }
111
112

  MOCK_METHOD0(This, int());
113
  MOCK_METHOD2(That, std::string(int, bool));
114
115

 private:
116
  std::string str_;
117
118

  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);
119
120
};

Gennadiy Civil's avatar
 
Gennadiy Civil committed
121
122
123
124

class MockBaz {
 public:
  class MoveOnly {
Abseil Team's avatar
Abseil Team committed
125
   public:
Gennadiy Civil's avatar
 
Gennadiy Civil committed
126
127
128
    MoveOnly() = default;

    MoveOnly(const MoveOnly&) = delete;
Abseil Team's avatar
Abseil Team committed
129
    MoveOnly& operator=(const MoveOnly&) = delete;
Gennadiy Civil's avatar
 
Gennadiy Civil committed
130
131

    MoveOnly(MoveOnly&&) = default;
Abseil Team's avatar
Abseil Team committed
132
    MoveOnly& operator=(MoveOnly&&) = default;
Gennadiy Civil's avatar
 
Gennadiy Civil committed
133
134
135
  };

  MockBaz(MoveOnly) {}
Abseil Team's avatar
Abseil Team committed
136
};
Gennadiy Civil's avatar
 
Gennadiy Civil committed
137

138
#if GTEST_HAS_STREAM_REDIRECTION
139

140
141
// Tests that a raw mock generates warnings for uninteresting calls.
TEST(RawMockTest, WarningForUninterestingCall) {
Abseil Team's avatar
Abseil Team committed
142
143
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "warning");
144
145
146
147
148
149
150
151
152

  MockFoo raw_foo;

  CaptureStdout();
  raw_foo.DoThis();
  raw_foo.DoThat(true);
  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
153
  GMOCK_FLAG_SET(verbose, saved_flag);
154
155
156
157
158
}

// Tests that a raw mock generates warnings for uninteresting calls
// that delete the mock object.
TEST(RawMockTest, WarningForUninterestingCallAfterDeath) {
Abseil Team's avatar
Abseil Team committed
159
160
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "warning");
161
162
163
164
165
166
167
168
169
170
171

  MockFoo* const raw_foo = new MockFoo;

  ON_CALL(*raw_foo, DoThis())
      .WillByDefault(Invoke(raw_foo, &MockFoo::Delete));

  CaptureStdout();
  raw_foo->DoThis();
  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
172
  GMOCK_FLAG_SET(verbose, saved_flag);
173
174
175
176
177
178
179
}

// Tests that a raw mock generates informational logs for
// uninteresting calls.
TEST(RawMockTest, InfoForUninterestingCall) {
  MockFoo raw_foo;

Abseil Team's avatar
Abseil Team committed
180
181
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "info");
182
183
184
185
186
  CaptureStdout();
  raw_foo.DoThis();
  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
187
  GMOCK_FLAG_SET(verbose, saved_flag);
188
189
}

190
191
TEST(RawMockTest, IsNaggy_IsNice_IsStrict) {
  MockFoo raw_foo;
192
  EXPECT_TRUE(Mock::IsNaggy(&raw_foo));
193
194
195
196
  EXPECT_FALSE(Mock::IsNice(&raw_foo));
  EXPECT_FALSE(Mock::IsStrict(&raw_foo));
}

197
198
199
200
// Tests that a nice mock generates no warning for uninteresting calls.
TEST(NiceMockTest, NoWarningForUninterestingCall) {
  NiceMock<MockFoo> nice_foo;

201
  CaptureStdout();
202
203
  nice_foo.DoThis();
  nice_foo.DoThat(true);
zhanyong.wan's avatar
zhanyong.wan committed
204
  EXPECT_EQ("", GetCapturedStdout());
205
206
207
208
209
210
211
212
213
214
}

// Tests that a nice mock generates no warning for uninteresting calls
// that delete the mock object.
TEST(NiceMockTest, NoWarningForUninterestingCallAfterDeath) {
  NiceMock<MockFoo>* const nice_foo = new NiceMock<MockFoo>;

  ON_CALL(*nice_foo, DoThis())
      .WillByDefault(Invoke(nice_foo, &MockFoo::Delete));

215
  CaptureStdout();
216
  nice_foo->DoThis();
zhanyong.wan's avatar
zhanyong.wan committed
217
  EXPECT_EQ("", GetCapturedStdout());
218
219
220
221
222
223
224
}

// Tests that a nice mock generates informational logs for
// uninteresting calls.
TEST(NiceMockTest, InfoForUninterestingCall) {
  NiceMock<MockFoo> nice_foo;

Abseil Team's avatar
Abseil Team committed
225
226
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "info");
227
  CaptureStdout();
228
  nice_foo.DoThis();
zhanyong.wan's avatar
zhanyong.wan committed
229
  EXPECT_THAT(GetCapturedStdout(),
230
231
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
232
  GMOCK_FLAG_SET(verbose, saved_flag);
233
234
}

235
#endif  // GTEST_HAS_STREAM_REDIRECTION
236
237
238
239
240
241
242
243
244

// Tests that a nice mock allows expected calls.
TEST(NiceMockTest, AllowsExpectedCall) {
  NiceMock<MockFoo> nice_foo;

  EXPECT_CALL(nice_foo, DoThis());
  nice_foo.DoThis();
}

Gennadiy Civil's avatar
 
Gennadiy Civil committed
245
246
247
// Tests that an unexpected call on a nice mock which returns a
// not-default-constructible type throws an exception and the exception contains
// the method's name.
248
TEST(NiceMockTest, ThrowsExceptionForUnknownReturnTypes) {
249
  NiceMock<MockFoo> nice_foo;
250
#if GTEST_HAS_EXCEPTIONS
251
  try {
252
    nice_foo.ReturnNonDefaultConstructible();
253
254
    FAIL();
  } catch (const std::runtime_error& ex) {
255
    EXPECT_THAT(ex.what(), HasSubstr("ReturnNonDefaultConstructible"));
256
  }
257
#else
258
  EXPECT_DEATH_IF_SUPPORTED({ nice_foo.ReturnNonDefaultConstructible(); }, "");
259
#endif
260
261
}

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
// Tests that an unexpected call on a nice mock fails.
TEST(NiceMockTest, UnexpectedCallFails) {
  NiceMock<MockFoo> nice_foo;

  EXPECT_CALL(nice_foo, DoThis()).Times(0);
  EXPECT_NONFATAL_FAILURE(nice_foo.DoThis(), "called more times than expected");
}

// Tests that NiceMock works with a mock class that has a non-default
// constructor.
TEST(NiceMockTest, NonDefaultConstructor) {
  NiceMock<MockBar> nice_bar("hi");
  EXPECT_EQ("hi", nice_bar.str());

  nice_bar.This();
  nice_bar.That(5, true);
}

// Tests that NiceMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(NiceMockTest, NonDefaultConstructor10) {
  NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f',
                             "g", "h", true, false);
  EXPECT_EQ("abcdefghTF", nice_bar.str());

  nice_bar.This();
  nice_bar.That(5, true);
}

291
292
293
294
295
296
297
TEST(NiceMockTest, AllowLeak) {
  NiceMock<MockFoo>* leaked = new NiceMock<MockFoo>;
  Mock::AllowLeak(leaked);
  EXPECT_CALL(*leaked, DoThis());
  leaked->DoThis();
}

Gennadiy Civil's avatar
 
Gennadiy Civil committed
298
TEST(NiceMockTest, MoveOnlyConstructor) {
Abseil Team's avatar
Abseil Team committed
299
  NiceMock<MockBaz> nice_baz(MockBaz::MoveOnly{});
Gennadiy Civil's avatar
 
Gennadiy Civil committed
300
301
}

302
// Tests that NiceMock<Mock> compiles where Mock is a user-defined
Abseil Team's avatar
Abseil Team committed
303
// class (as opposed to ::testing::Mock).
304
305
306
307
308
309
TEST(NiceMockTest, AcceptsClassNamedMock) {
  NiceMock< ::Mock> nice;
  EXPECT_CALL(nice, DoThis());
  nice.DoThis();
}

Abseil Team's avatar
Abseil Team committed
310
311
312
313
314
315
316
TEST(NiceMockTest, IsNiceInDestructor) {
  {
    NiceMock<CallsMockMethodInDestructor> nice_on_destroy;
    // Don't add an expectation for the call before the mock goes out of scope.
  }
}

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

zhanyong.wan's avatar
zhanyong.wan committed
324
325
326
327
#if GTEST_HAS_STREAM_REDIRECTION

// Tests that a naggy mock generates warnings for uninteresting calls.
TEST(NaggyMockTest, WarningForUninterestingCall) {
Abseil Team's avatar
Abseil Team committed
328
329
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "warning");
zhanyong.wan's avatar
zhanyong.wan committed
330
331
332
333
334
335
336
337
338

  NaggyMock<MockFoo> naggy_foo;

  CaptureStdout();
  naggy_foo.DoThis();
  naggy_foo.DoThat(true);
  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
339
  GMOCK_FLAG_SET(verbose, saved_flag);
zhanyong.wan's avatar
zhanyong.wan committed
340
341
342
343
344
}

// Tests that a naggy mock generates a warning for an uninteresting call
// that deletes the mock object.
TEST(NaggyMockTest, WarningForUninterestingCallAfterDeath) {
Abseil Team's avatar
Abseil Team committed
345
346
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "warning");
zhanyong.wan's avatar
zhanyong.wan committed
347
348
349
350
351
352
353
354
355
356
357

  NaggyMock<MockFoo>* const naggy_foo = new NaggyMock<MockFoo>;

  ON_CALL(*naggy_foo, DoThis())
      .WillByDefault(Invoke(naggy_foo, &MockFoo::Delete));

  CaptureStdout();
  naggy_foo->DoThis();
  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
358
  GMOCK_FLAG_SET(verbose, saved_flag);
zhanyong.wan's avatar
zhanyong.wan committed
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
}

#endif  // GTEST_HAS_STREAM_REDIRECTION

// Tests that a naggy mock allows expected calls.
TEST(NaggyMockTest, AllowsExpectedCall) {
  NaggyMock<MockFoo> naggy_foo;

  EXPECT_CALL(naggy_foo, DoThis());
  naggy_foo.DoThis();
}

// Tests that an unexpected call on a naggy mock fails.
TEST(NaggyMockTest, UnexpectedCallFails) {
  NaggyMock<MockFoo> naggy_foo;

  EXPECT_CALL(naggy_foo, DoThis()).Times(0);
  EXPECT_NONFATAL_FAILURE(naggy_foo.DoThis(),
                          "called more times than expected");
}

// Tests that NaggyMock works with a mock class that has a non-default
// constructor.
TEST(NaggyMockTest, NonDefaultConstructor) {
  NaggyMock<MockBar> naggy_bar("hi");
  EXPECT_EQ("hi", naggy_bar.str());

  naggy_bar.This();
  naggy_bar.That(5, true);
}

// Tests that NaggyMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(NaggyMockTest, NonDefaultConstructor10) {
  NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5',
                               "6", "7", true, false);
  EXPECT_EQ("01234567TF", naggy_bar.str());

  naggy_bar.This();
  naggy_bar.That(5, true);
}

401
402
403
404
405
406
407
TEST(NaggyMockTest, AllowLeak) {
  NaggyMock<MockFoo>* leaked = new NaggyMock<MockFoo>;
  Mock::AllowLeak(leaked);
  EXPECT_CALL(*leaked, DoThis());
  leaked->DoThis();
}

Gennadiy Civil's avatar
 
Gennadiy Civil committed
408
TEST(NaggyMockTest, MoveOnlyConstructor) {
Abseil Team's avatar
Abseil Team committed
409
  NaggyMock<MockBaz> naggy_baz(MockBaz::MoveOnly{});
Gennadiy Civil's avatar
 
Gennadiy Civil committed
410
411
}

zhanyong.wan's avatar
zhanyong.wan committed
412
// Tests that NaggyMock<Mock> compiles where Mock is a user-defined
Abseil Team's avatar
Abseil Team committed
413
// class (as opposed to ::testing::Mock).
zhanyong.wan's avatar
zhanyong.wan committed
414
415
416
417
418
419
TEST(NaggyMockTest, AcceptsClassNamedMock) {
  NaggyMock< ::Mock> naggy;
  EXPECT_CALL(naggy, DoThis());
  naggy.DoThis();
}

Abseil Team's avatar
Abseil Team committed
420
TEST(NaggyMockTest, IsNaggyInDestructor) {
Abseil Team's avatar
Abseil Team committed
421
422
  const std::string saved_flag = GMOCK_FLAG_GET(verbose);
  GMOCK_FLAG_SET(verbose, "warning");
Abseil Team's avatar
Abseil Team committed
423
424
425
426
427
428
429
430
431
432
  CaptureStdout();

  {
    NaggyMock<CallsMockMethodInDestructor> naggy_on_destroy;
    // Don't add an expectation for the call before the mock goes out of scope.
  }

  EXPECT_THAT(GetCapturedStdout(),
              HasSubstr("Uninteresting mock function call"));

Abseil Team's avatar
Abseil Team committed
433
  GMOCK_FLAG_SET(verbose, saved_flag);
Abseil Team's avatar
Abseil Team committed
434
435
}

436
437
TEST(NaggyMockTest, IsNaggy_IsNice_IsStrict) {
  NaggyMock<MockFoo> naggy_foo;
438
  EXPECT_TRUE(Mock::IsNaggy(&naggy_foo));
439
440
441
442
  EXPECT_FALSE(Mock::IsNice(&naggy_foo));
  EXPECT_FALSE(Mock::IsStrict(&naggy_foo));
}

443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
// Tests that a strict mock allows expected calls.
TEST(StrictMockTest, AllowsExpectedCall) {
  StrictMock<MockFoo> strict_foo;

  EXPECT_CALL(strict_foo, DoThis());
  strict_foo.DoThis();
}

// Tests that an unexpected call on a strict mock fails.
TEST(StrictMockTest, UnexpectedCallFails) {
  StrictMock<MockFoo> strict_foo;

  EXPECT_CALL(strict_foo, DoThis()).Times(0);
  EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),
                          "called more times than expected");
}

// Tests that an uninteresting call on a strict mock fails.
TEST(StrictMockTest, UninterestingCallFails) {
  StrictMock<MockFoo> strict_foo;

  EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),
                          "Uninteresting mock function call");
}

// Tests that an uninteresting call on a strict mock fails, even if
// the call deletes the mock object.
TEST(StrictMockTest, UninterestingCallFailsAfterDeath) {
  StrictMock<MockFoo>* const strict_foo = new StrictMock<MockFoo>;

  ON_CALL(*strict_foo, DoThis())
      .WillByDefault(Invoke(strict_foo, &MockFoo::Delete));

  EXPECT_NONFATAL_FAILURE(strict_foo->DoThis(),
                          "Uninteresting mock function call");
}

// Tests that StrictMock works with a mock class that has a
// non-default constructor.
TEST(StrictMockTest, NonDefaultConstructor) {
  StrictMock<MockBar> strict_bar("hi");
  EXPECT_EQ("hi", strict_bar.str());

  EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
                          "Uninteresting mock function call");
}

// Tests that StrictMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(StrictMockTest, NonDefaultConstructor10) {
  StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f',
                                 "g", "h", true, false);
  EXPECT_EQ("abcdefghTF", strict_bar.str());

  EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
                          "Uninteresting mock function call");
}

501
502
503
504
505
506
507
TEST(StrictMockTest, AllowLeak) {
  StrictMock<MockFoo>* leaked = new StrictMock<MockFoo>;
  Mock::AllowLeak(leaked);
  EXPECT_CALL(*leaked, DoThis());
  leaked->DoThis();
}

Gennadiy Civil's avatar
 
Gennadiy Civil committed
508
TEST(StrictMockTest, MoveOnlyConstructor) {
Abseil Team's avatar
Abseil Team committed
509
  StrictMock<MockBaz> strict_baz(MockBaz::MoveOnly{});
Gennadiy Civil's avatar
 
Gennadiy Civil committed
510
511
}

512
// Tests that StrictMock<Mock> compiles where Mock is a user-defined
Abseil Team's avatar
Abseil Team committed
513
// class (as opposed to ::testing::Mock).
514
TEST(StrictMockTest, AcceptsClassNamedMock) {
515
516
517
  StrictMock< ::Mock> strict;
  EXPECT_CALL(strict, DoThis());
  strict.DoThis();
518
519
}

Abseil Team's avatar
Abseil Team committed
520
521
522
523
524
525
526
527
528
529
TEST(StrictMockTest, IsStrictInDestructor) {
  EXPECT_NONFATAL_FAILURE(
      {
        StrictMock<CallsMockMethodInDestructor> strict_on_destroy;
        // Don't add an expectation for the call before the mock goes out of
        // scope.
      },
      "Uninteresting mock function call");
}

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

537
538
}  // namespace gmock_nice_strict_test
}  // namespace testing