blob: 2ea76b0e760e5155addcdabb88b0da20c2db0321 [file] [log] [blame]
shiqiane35fdd92008-12-10 05:08:54 +00001// Copyright 2007, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Author: wan@google.com (Zhanyong Wan)
31
32// Google Mock - a framework for writing C++ mock classes.
33//
34// This file tests the internal utilities.
35
36#include <gmock/internal/gmock-internal-utils.h>
37#include <map>
38#include <string>
39#include <sstream>
40#include <vector>
41#include <gmock/gmock.h>
42#include <gmock/internal/gmock-port.h>
43#include <gtest/gtest.h>
44#include <gtest/gtest-spi.h>
45
46namespace testing {
47namespace internal {
48
49namespace {
50
51using ::std::tr1::tuple;
52
zhanyong.wance198ff2009-02-12 01:34:27 +000053TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsNoWord) {
54 EXPECT_EQ("", ConvertIdentifierNameToWords(""));
55 EXPECT_EQ("", ConvertIdentifierNameToWords("_"));
56 EXPECT_EQ("", ConvertIdentifierNameToWords("__"));
57}
58
59TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsDigits) {
60 EXPECT_EQ("1", ConvertIdentifierNameToWords("_1"));
61 EXPECT_EQ("2", ConvertIdentifierNameToWords("2_"));
62 EXPECT_EQ("34", ConvertIdentifierNameToWords("_34_"));
63 EXPECT_EQ("34 56", ConvertIdentifierNameToWords("_34_56"));
64}
65
66TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsCamelCaseWords) {
67 EXPECT_EQ("a big word", ConvertIdentifierNameToWords("ABigWord"));
68 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("FooBar"));
69 EXPECT_EQ("foo", ConvertIdentifierNameToWords("Foo_"));
70 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("_Foo_Bar_"));
71 EXPECT_EQ("foo and bar", ConvertIdentifierNameToWords("_Foo__And_Bar"));
72}
73
74TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContains_SeparatedWords) {
75 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("foo_bar"));
76 EXPECT_EQ("foo", ConvertIdentifierNameToWords("_foo_"));
77 EXPECT_EQ("foo bar", ConvertIdentifierNameToWords("_foo_bar_"));
78 EXPECT_EQ("foo and bar", ConvertIdentifierNameToWords("_foo__and_bar"));
79}
80
81TEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) {
82 EXPECT_EQ("foo bar 123", ConvertIdentifierNameToWords("Foo_bar123"));
83 EXPECT_EQ("chapter 11 section 1",
84 ConvertIdentifierNameToWords("_Chapter11Section_1_"));
85}
86
shiqiane35fdd92008-12-10 05:08:54 +000087// Tests that CompileAssertTypesEqual compiles when the type arguments are
88// equal.
89TEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {
90 CompileAssertTypesEqual<void, void>();
91 CompileAssertTypesEqual<int*, int*>();
92}
93
94// Tests that RemoveReference does not affect non-reference types.
95TEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {
96 CompileAssertTypesEqual<int, RemoveReference<int>::type>();
97 CompileAssertTypesEqual<const char, RemoveReference<const char>::type>();
98}
99
100// Tests that RemoveReference removes reference from reference types.
101TEST(RemoveReferenceTest, RemovesReference) {
102 CompileAssertTypesEqual<int, RemoveReference<int&>::type>();
103 CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>();
104}
105
106// Tests GMOCK_REMOVE_REFERENCE.
107
108template <typename T1, typename T2>
109void TestGMockRemoveReference() {
110 CompileAssertTypesEqual<T1, GMOCK_REMOVE_REFERENCE(T2)>();
111}
112
113TEST(RemoveReferenceTest, MacroVersion) {
114 TestGMockRemoveReference<int, int>();
115 TestGMockRemoveReference<const char, const char&>();
116}
117
118
119// Tests that RemoveConst does not affect non-const types.
120TEST(RemoveConstTest, DoesNotAffectNonConstType) {
121 CompileAssertTypesEqual<int, RemoveConst<int>::type>();
122 CompileAssertTypesEqual<char&, RemoveConst<char&>::type>();
123}
124
125// Tests that RemoveConst removes const from const types.
126TEST(RemoveConstTest, RemovesConst) {
127 CompileAssertTypesEqual<int, RemoveConst<const int>::type>();
128}
129
130// Tests GMOCK_REMOVE_CONST.
131
132template <typename T1, typename T2>
133void TestGMockRemoveConst() {
134 CompileAssertTypesEqual<T1, GMOCK_REMOVE_CONST(T2)>();
135}
136
137TEST(RemoveConstTest, MacroVersion) {
138 TestGMockRemoveConst<int, int>();
139 TestGMockRemoveConst<double&, double&>();
140 TestGMockRemoveConst<char, const char>();
141}
142
143// Tests that AddReference does not affect reference types.
144TEST(AddReferenceTest, DoesNotAffectReferenceType) {
145 CompileAssertTypesEqual<int&, AddReference<int&>::type>();
146 CompileAssertTypesEqual<const char&, AddReference<const char&>::type>();
147}
148
149// Tests that AddReference adds reference to non-reference types.
150TEST(AddReferenceTest, AddsReference) {
151 CompileAssertTypesEqual<int&, AddReference<int>::type>();
152 CompileAssertTypesEqual<const char&, AddReference<const char>::type>();
153}
154
155// Tests GMOCK_ADD_REFERENCE.
156
157template <typename T1, typename T2>
158void TestGMockAddReference() {
159 CompileAssertTypesEqual<T1, GMOCK_ADD_REFERENCE(T2)>();
160}
161
162TEST(AddReferenceTest, MacroVersion) {
163 TestGMockAddReference<int&, int>();
164 TestGMockAddReference<const char&, const char&>();
165}
166
167// Tests GMOCK_REFERENCE_TO_CONST.
168
169template <typename T1, typename T2>
170void TestGMockReferenceToConst() {
171 CompileAssertTypesEqual<T1, GMOCK_REFERENCE_TO_CONST(T2)>();
172}
173
174TEST(GMockReferenceToConstTest, Works) {
175 TestGMockReferenceToConst<const char&, char>();
176 TestGMockReferenceToConst<const int&, const int>();
177 TestGMockReferenceToConst<const double&, double>();
178 TestGMockReferenceToConst<const string&, const string&>();
179}
180
181TEST(PointeeOfTest, WorksForSmartPointers) {
182 CompileAssertTypesEqual<const char,
183 PointeeOf<internal::linked_ptr<const char> >::type>();
184}
185
186TEST(PointeeOfTest, WorksForRawPointers) {
187 CompileAssertTypesEqual<int, PointeeOf<int*>::type>();
188 CompileAssertTypesEqual<const char, PointeeOf<const char*>::type>();
189 CompileAssertTypesEqual<void, PointeeOf<void*>::type>();
190}
191
192TEST(GetRawPointerTest, WorksForSmartPointers) {
193 const char* const raw_p4 = new const char('a'); // NOLINT
194 const internal::linked_ptr<const char> p4(raw_p4);
195 EXPECT_EQ(raw_p4, GetRawPointer(p4));
196}
197
198TEST(GetRawPointerTest, WorksForRawPointers) {
199 int* p = NULL;
200 EXPECT_EQ(NULL, GetRawPointer(p));
201 int n = 1;
202 EXPECT_EQ(&n, GetRawPointer(&n));
203}
204
205class Base {};
206class Derived : public Base {};
207
208// Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant.
209TEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) {
210 GMOCK_COMPILE_ASSERT((ImplicitlyConvertible<int, int>::value), const_true);
211 GMOCK_COMPILE_ASSERT((!ImplicitlyConvertible<void*, int*>::value), const_false);
212}
213
214// Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can
215// be implicitly converted to T2.
216TEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) {
217 EXPECT_TRUE((ImplicitlyConvertible<int, double>::value));
218 EXPECT_TRUE((ImplicitlyConvertible<double, int>::value));
219 EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value));
220 EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value));
221 EXPECT_TRUE((ImplicitlyConvertible<Derived&, const Base&>::value));
222 EXPECT_TRUE((ImplicitlyConvertible<const Base, Base>::value));
223}
224
225// Tests that ImplicitlyConvertible<T1, T2>::value is false when T1
226// cannot be implicitly converted to T2.
227TEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) {
228 EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value));
229 EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value));
230 EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value));
231 EXPECT_FALSE((ImplicitlyConvertible<Base&, Derived&>::value));
232}
233
234// Tests that IsAProtocolMessage<T>::value is a compile-time constant.
235TEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {
236 GMOCK_COMPILE_ASSERT(IsAProtocolMessage<ProtocolMessage>::value, const_true);
237 GMOCK_COMPILE_ASSERT(!IsAProtocolMessage<int>::value, const_false);
238}
239
240// Tests that IsAProtocolMessage<T>::value is true when T is
241// ProtocolMessage or a sub-class of it.
242TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {
243 EXPECT_TRUE(IsAProtocolMessage<ProtocolMessage>::value);
244#if GMOCK_HAS_PROTOBUF_
245 EXPECT_TRUE(IsAProtocolMessage<const TestMessage>::value);
246#endif // GMOCK_HAS_PROTOBUF_
247}
248
249// Tests that IsAProtocolMessage<T>::value is false when T is neither
250// ProtocolMessage nor a sub-class of it.
251TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {
252 EXPECT_FALSE(IsAProtocolMessage<int>::value);
253 EXPECT_FALSE(IsAProtocolMessage<const Base>::value);
254}
255
256// Tests IsContainerTest.
257
258class NonContainer {};
259
260TEST(IsContainerTestTest, WorksForNonContainer) {
261 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0)));
262 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0)));
263 EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0)));
264}
265
266TEST(IsContainerTestTest, WorksForContainer) {
267 EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<std::vector<bool> >(0)));
268 EXPECT_EQ(sizeof(IsContainer), sizeof(IsContainerTest<std::map<int, double> >(0)));
269}
270
271// Tests the TupleMatches() template function.
272
273TEST(TupleMatchesTest, WorksForSize0) {
274 tuple<> matchers;
275 tuple<> values;
276
277 EXPECT_TRUE(TupleMatches(matchers, values));
278}
279
280TEST(TupleMatchesTest, WorksForSize1) {
281 tuple<Matcher<int> > matchers(Eq(1));
282 tuple<int> values1(1),
283 values2(2);
284
285 EXPECT_TRUE(TupleMatches(matchers, values1));
286 EXPECT_FALSE(TupleMatches(matchers, values2));
287}
288
289TEST(TupleMatchesTest, WorksForSize2) {
290 tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));
291 tuple<int, char> values1(1, 'a'),
292 values2(1, 'b'),
293 values3(2, 'a'),
294 values4(2, 'b');
295
296 EXPECT_TRUE(TupleMatches(matchers, values1));
297 EXPECT_FALSE(TupleMatches(matchers, values2));
298 EXPECT_FALSE(TupleMatches(matchers, values3));
299 EXPECT_FALSE(TupleMatches(matchers, values4));
300}
301
302TEST(TupleMatchesTest, WorksForSize5) {
303 tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<long>, // NOLINT
304 Matcher<string> >
305 matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
306 tuple<int, char, bool, long, string> // NOLINT
307 values1(1, 'a', true, 2L, "hi"),
308 values2(1, 'a', true, 2L, "hello"),
309 values3(2, 'a', true, 2L, "hi");
310
311 EXPECT_TRUE(TupleMatches(matchers, values1));
312 EXPECT_FALSE(TupleMatches(matchers, values2));
313 EXPECT_FALSE(TupleMatches(matchers, values3));
314}
315
316// Tests that Assert(true, ...) succeeds.
317TEST(AssertTest, SucceedsOnTrue) {
318 Assert(true, __FILE__, __LINE__, "This should succeed.");
319 Assert(true, __FILE__, __LINE__); // This should succeed too.
320}
321
322#ifdef GTEST_HAS_DEATH_TEST
323
324// Tests that Assert(false, ...) generates a fatal failure.
325TEST(AssertTest, FailsFatallyOnFalse) {
326 EXPECT_DEATH({ // NOLINT
327 Assert(false, __FILE__, __LINE__, "This should fail.");
328 }, "");
329
330 EXPECT_DEATH({ // NOLINT
331 Assert(false, __FILE__, __LINE__);
332 }, "");
333}
334
335#endif // GTEST_HAS_DEATH_TEST
336
337// Tests that Expect(true, ...) succeeds.
338TEST(ExpectTest, SucceedsOnTrue) {
339 Expect(true, __FILE__, __LINE__, "This should succeed.");
340 Expect(true, __FILE__, __LINE__); // This should succeed too.
341}
342
343// Tests that Expect(false, ...) generates a non-fatal failure.
344TEST(ExpectTest, FailsNonfatallyOnFalse) {
345 EXPECT_NONFATAL_FAILURE({ // NOLINT
346 Expect(false, __FILE__, __LINE__, "This should fail.");
347 }, "This should fail");
348
349 EXPECT_NONFATAL_FAILURE({ // NOLINT
350 Expect(false, __FILE__, __LINE__);
351 }, "Expectation failed");
352}
353
354// TODO(wan@google.com): find a way to re-enable these tests.
355#if 0
356
357// Tests the Log() function.
358
359// Verifies that Log() behaves correctly for the given verbosity level
360// and log severity.
361void TestLogWithSeverity(const string& verbosity, LogSeverity severity,
362 bool should_print) {
363 const string old_flag = GMOCK_FLAG(verbose);
364 GMOCK_FLAG(verbose) = verbosity;
365 CaptureTestStdout();
366 Log(severity, "Test log.\n", 0);
367 if (should_print) {
368 EXPECT_PRED2(RE::FullMatch,
369 GetCapturedTestStdout(),
370 severity == WARNING ?
371 "\nGMOCK WARNING:\nTest log\\.\nStack trace:\n[\\s\\S]*" :
372 "\nTest log\\.\nStack trace:\n[\\s\\S]*");
373 } else {
374 EXPECT_EQ("", GetCapturedTestStdout());
375 }
376 GMOCK_FLAG(verbose) = old_flag;
377}
378
379// Tests that when the stack_frames_to_skip parameter is negative,
380// Log() doesn't include the stack trace in the output.
381TEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {
382 GMOCK_FLAG(verbose) = kInfoVerbosity;
383 CaptureTestStdout();
384 Log(INFO, "Test log.\n", -1);
385 EXPECT_EQ("\nTest log.\n", GetCapturedTestStdout());
386}
387
388// Tests that in opt mode, a positive stack_frames_to_skip argument is
389// treated as 0.
390TEST(LogTest, NoSkippingStackFrameInOptMode) {
391 CaptureTestStdout();
392 Log(WARNING, "Test log.\n", 100);
393 const string log = GetCapturedTestStdout();
394#ifdef NDEBUG
395 // In opt mode, no stack frame should be skipped.
396 EXPECT_THAT(log, ContainsRegex("\nGMOCK WARNING:\n"
397 "Test log\\.\n"
398 "Stack trace:\n"
399 ".+"));
400#else
401 // In dbg mode, the stack frames should be skipped.
402 EXPECT_EQ("\nGMOCK WARNING:\n"
403 "Test log.\n"
404 "Stack trace:\n", log);
405#endif // NDEBUG
406}
407
408// Tests that all logs are printed when the value of the
409// --gmock_verbose flag is "info".
410TEST(LogTest, AllLogsArePrintedWhenVerbosityIsInfo) {
411 TestLogWithSeverity(kInfoVerbosity, INFO, true);
412 TestLogWithSeverity(kInfoVerbosity, WARNING, true);
413}
414
415// Tests that only warnings are printed when the value of the
416// --gmock_verbose flag is "warning".
417TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsWarning) {
418 TestLogWithSeverity(kWarningVerbosity, INFO, false);
419 TestLogWithSeverity(kWarningVerbosity, WARNING, true);
420}
421
422// Tests that no logs are printed when the value of the
423// --gmock_verbose flag is "error".
424TEST(LogTest, NoLogsArePrintedWhenVerbosityIsError) {
425 TestLogWithSeverity(kErrorVerbosity, INFO, false);
426 TestLogWithSeverity(kErrorVerbosity, WARNING, false);
427}
428
429// Tests that only warnings are printed when the value of the
430// --gmock_verbose flag is invalid.
431TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) {
432 TestLogWithSeverity("invalid", INFO, false);
433 TestLogWithSeverity("invalid", WARNING, true);
434}
435
436#endif // 0
437
438TEST(TypeTraitsTest, true_type) {
439 EXPECT_TRUE(true_type::value);
440}
441
442TEST(TypeTraitsTest, false_type) {
443 EXPECT_FALSE(false_type::value);
444}
445
446TEST(TypeTraitsTest, is_reference) {
447 EXPECT_FALSE(is_reference<int>::value);
448 EXPECT_FALSE(is_reference<char*>::value);
449 EXPECT_TRUE(is_reference<const int&>::value);
450}
451
452TEST(TypeTraitsTest, is_pointer) {
453 EXPECT_FALSE(is_pointer<int>::value);
454 EXPECT_FALSE(is_pointer<char&>::value);
455 EXPECT_TRUE(is_pointer<const int*>::value);
456}
457
458TEST(TypeTraitsTest, type_equals) {
459 EXPECT_FALSE((type_equals<int, const int>::value));
460 EXPECT_FALSE((type_equals<int, int&>::value));
461 EXPECT_FALSE((type_equals<int, double>::value));
462 EXPECT_TRUE((type_equals<char, char>::value));
463}
464
465TEST(TypeTraitsTest, remove_reference) {
466 EXPECT_TRUE((type_equals<char, remove_reference<char&>::type>::value));
467 EXPECT_TRUE((type_equals<const int,
468 remove_reference<const int&>::type>::value));
469 EXPECT_TRUE((type_equals<int, remove_reference<int>::type>::value));
470 EXPECT_TRUE((type_equals<double*, remove_reference<double*>::type>::value));
471}
472
473// TODO(wan@google.com): find a way to re-enable these tests.
474#if 0
475
476// Verifies that Log() behaves correctly for the given verbosity level
477// and log severity.
478string GrabOutput(void(*logger)(), const char* verbosity) {
479 const string saved_flag = GMOCK_FLAG(verbose);
480 GMOCK_FLAG(verbose) = verbosity;
481 CaptureTestStdout();
482 logger();
483 GMOCK_FLAG(verbose) = saved_flag;
484 return GetCapturedTestStdout();
485}
486
487class DummyMock {
488 public:
489 MOCK_METHOD0(TestMethod, void());
490 MOCK_METHOD1(TestMethodArg, void(int dummy));
491};
492
493void ExpectCallLogger() {
494 DummyMock mock;
495 EXPECT_CALL(mock, TestMethod());
496 mock.TestMethod();
497};
498
499// Verifies that EXPECT_CALL logs if the --gmock_verbose flag is set to "info".
500TEST(ExpectCallTest, LogsWhenVerbosityIsInfo) {
501 EXPECT_THAT(GrabOutput(ExpectCallLogger, kInfoVerbosity),
502 HasSubstr("EXPECT_CALL(mock, TestMethod())"));
503}
504
505// Verifies that EXPECT_CALL doesn't log
506// if the --gmock_verbose flag is set to "warning".
507TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsWarning) {
508 EXPECT_EQ("", GrabOutput(ExpectCallLogger, kWarningVerbosity));
509}
510
511// Verifies that EXPECT_CALL doesn't log
512// if the --gmock_verbose flag is set to "error".
513TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsError) {
514 EXPECT_EQ("", GrabOutput(ExpectCallLogger, kErrorVerbosity));
515}
516
517void OnCallLogger() {
518 DummyMock mock;
519 ON_CALL(mock, TestMethod());
520};
521
522// Verifies that ON_CALL logs if the --gmock_verbose flag is set to "info".
523TEST(OnCallTest, LogsWhenVerbosityIsInfo) {
524 EXPECT_THAT(GrabOutput(OnCallLogger, kInfoVerbosity),
525 HasSubstr("ON_CALL(mock, TestMethod())"));
526}
527
528// Verifies that ON_CALL doesn't log
529// if the --gmock_verbose flag is set to "warning".
530TEST(OnCallTest, DoesNotLogWhenVerbosityIsWarning) {
531 EXPECT_EQ("", GrabOutput(OnCallLogger, kWarningVerbosity));
532}
533
534// Verifies that ON_CALL doesn't log if
535// the --gmock_verbose flag is set to "error".
536TEST(OnCallTest, DoesNotLogWhenVerbosityIsError) {
537 EXPECT_EQ("", GrabOutput(OnCallLogger, kErrorVerbosity));
538}
539
540void OnCallAnyArgumentLogger() {
541 DummyMock mock;
542 ON_CALL(mock, TestMethodArg(_));
543}
544
545// Verifies that ON_CALL prints provided _ argument.
546TEST(OnCallTest, LogsAnythingArgument) {
547 EXPECT_THAT(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity),
548 HasSubstr("ON_CALL(mock, TestMethodArg(_)"));
549}
550
551#endif // 0
552
553} // namespace
554} // namespace internal
555} // namespace testing