cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
gtest_pred_impl_unittest.cc
Go to the documentation of this file.
1// Copyright 2006, 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// Regression test for gtest_pred_impl.h
31//
32// This file is generated by a script and quite long. If you intend to
33// learn how Google Test works by reading its unit tests, read
34// gtest_unittest.cc instead.
35//
36// This is intended as a regression test for the Google Test predicate
37// assertions. We compile it as part of the gtest_unittest target
38// only to keep the implementation tidy and compact, as it is quite
39// involved to set up the stage for testing Google Test using Google
40// Test itself.
41//
42// Currently, gtest_unittest takes ~11 seconds to run in the testing
43// daemon. In the future, if it grows too large and needs much more
44// time to finish, we should consider separating this file into a
45// stand-alone regression test.
46
47#include <iostream>
48#include <ostream>
49
50#include "gtest/gtest-spi.h"
51#include "gtest/gtest.h"
52
53// A user-defined data type.
54struct Bool {
55 explicit Bool(int val) : value(val != 0) {}
56
57 bool operator>(int n) const { return value > Bool(n).value; }
58
59 Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
60
61 bool operator==(const Bool& rhs) const { return value == rhs.value; }
62
63 bool value;
64};
65
66// Enables Bool to be used in assertions.
67std::ostream& operator<<(std::ostream& os, const Bool& x) {
68 return os << (x.value ? "true" : "false");
69}
70
71// Sample functions/functors for testing unary predicate assertions.
72
73// A unary predicate function.
74template <typename T1>
75bool PredFunction1(T1 v1) {
76 return v1 > 0;
77}
78
79// The following two functions are needed because a compiler doesn't have
80// a context yet to know which template function must be instantiated.
81bool PredFunction1Int(int v1) { return v1 > 0; }
82bool PredFunction1Bool(Bool v1) { return v1 > 0; }
83
84// A unary predicate functor.
86 template <typename T1>
87 bool operator()(const T1& v1) {
88 return v1 > 0;
89 }
90};
91
92// A unary predicate-formatter function.
93template <typename T1>
94testing::AssertionResult PredFormatFunction1(const char* e1, const T1& v1) {
96
98 << e1 << " is expected to be positive, but evaluates to " << v1 << ".";
99}
100
101// A unary predicate-formatter functor.
103 template <typename T1>
104 testing::AssertionResult operator()(const char* e1, const T1& v1) const {
105 return PredFormatFunction1(e1, v1);
106 }
107};
108
109// Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
110
112 protected:
113 void SetUp() override {
114 expected_to_finish_ = true;
115 finished_ = false;
116 n1_ = 0;
117 }
118
119 void TearDown() override {
120 // Verifies that each of the predicate's arguments was evaluated
121 // exactly once.
122 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
123 "exactly once.";
124
125 // Verifies that the control flow in the test function is expected.
127 FAIL() << "The predicate assertion unexpectedly aborted the test.";
128 } else if (!expected_to_finish_ && finished_) {
129 FAIL() << "The failed predicate assertion didn't abort the test "
130 "as expected.";
131 }
132 }
133
134 // true if and only if the test function is expected to run to finish.
136
137 // true if and only if the test function did run to finish.
138 static bool finished_;
139
140 static int n1_;
141};
142
146
151
152// Tests a successful EXPECT_PRED1 where the
153// predicate-formatter is a function on a built-in type (int).
154TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
156 finished_ = true;
157}
158
159// Tests a successful EXPECT_PRED1 where the
160// predicate-formatter is a function on a user-defined type (Bool).
161TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
163 finished_ = true;
164}
165
166// Tests a successful EXPECT_PRED1 where the
167// predicate-formatter is a functor on a built-in type (int).
168TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
169 EXPECT_PRED1(PredFunctor1(), ++n1_);
170 finished_ = true;
171}
172
173// Tests a successful EXPECT_PRED1 where the
174// predicate-formatter is a functor on a user-defined type (Bool).
175TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
176 EXPECT_PRED1(PredFunctor1(), Bool(++n1_));
177 finished_ = true;
178}
179
180// Tests a failed EXPECT_PRED1 where the
181// predicate-formatter is a function on a built-in type (int).
182TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
184 { // NOLINT
186 finished_ = true;
187 },
188 "");
189}
190
191// Tests a failed EXPECT_PRED1 where the
192// predicate-formatter is a function on a user-defined type (Bool).
193TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
195 { // NOLINT
197 finished_ = true;
198 },
199 "");
200}
201
202// Tests a failed EXPECT_PRED1 where the
203// predicate-formatter is a functor on a built-in type (int).
204TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
206 { // NOLINT
207 EXPECT_PRED1(PredFunctor1(), n1_++);
208 finished_ = true;
209 },
210 "");
211}
212
213// Tests a failed EXPECT_PRED1 where the
214// predicate-formatter is a functor on a user-defined type (Bool).
215TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
217 { // NOLINT
218 EXPECT_PRED1(PredFunctor1(), Bool(n1_++));
219 finished_ = true;
220 },
221 "");
222}
223
224// Tests a successful ASSERT_PRED1 where the
225// predicate-formatter is a function on a built-in type (int).
226TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
228 finished_ = true;
229}
230
231// Tests a successful ASSERT_PRED1 where the
232// predicate-formatter is a function on a user-defined type (Bool).
233TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
235 finished_ = true;
236}
237
238// Tests a successful ASSERT_PRED1 where the
239// predicate-formatter is a functor on a built-in type (int).
240TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
241 ASSERT_PRED1(PredFunctor1(), ++n1_);
242 finished_ = true;
243}
244
245// Tests a successful ASSERT_PRED1 where the
246// predicate-formatter is a functor on a user-defined type (Bool).
247TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
248 ASSERT_PRED1(PredFunctor1(), Bool(++n1_));
249 finished_ = true;
250}
251
252// Tests a failed ASSERT_PRED1 where the
253// predicate-formatter is a function on a built-in type (int).
254TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
255 expected_to_finish_ = false;
257 { // NOLINT
259 finished_ = true;
260 },
261 "");
262}
263
264// Tests a failed ASSERT_PRED1 where the
265// predicate-formatter is a function on a user-defined type (Bool).
266TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
267 expected_to_finish_ = false;
269 { // NOLINT
271 finished_ = true;
272 },
273 "");
274}
275
276// Tests a failed ASSERT_PRED1 where the
277// predicate-formatter is a functor on a built-in type (int).
278TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
279 expected_to_finish_ = false;
281 { // NOLINT
282 ASSERT_PRED1(PredFunctor1(), n1_++);
283 finished_ = true;
284 },
285 "");
286}
287
288// Tests a failed ASSERT_PRED1 where the
289// predicate-formatter is a functor on a user-defined type (Bool).
290TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
291 expected_to_finish_ = false;
293 { // NOLINT
294 ASSERT_PRED1(PredFunctor1(), Bool(n1_++));
295 finished_ = true;
296 },
297 "");
298}
299
300// Tests a successful EXPECT_PRED_FORMAT1 where the
301// predicate-formatter is a function on a built-in type (int).
302TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
304 finished_ = true;
305}
306
307// Tests a successful EXPECT_PRED_FORMAT1 where the
308// predicate-formatter is a function on a user-defined type (Bool).
309TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
311 finished_ = true;
312}
313
314// Tests a successful EXPECT_PRED_FORMAT1 where the
315// predicate-formatter is a functor on a built-in type (int).
316TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
318 finished_ = true;
319}
320
321// Tests a successful EXPECT_PRED_FORMAT1 where the
322// predicate-formatter is a functor on a user-defined type (Bool).
323TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
325 finished_ = true;
326}
327
328// Tests a failed EXPECT_PRED_FORMAT1 where the
329// predicate-formatter is a function on a built-in type (int).
330TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
332 { // NOLINT
334 finished_ = true;
335 },
336 "");
337}
338
339// Tests a failed EXPECT_PRED_FORMAT1 where the
340// predicate-formatter is a function on a user-defined type (Bool).
341TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
343 { // NOLINT
345 finished_ = true;
346 },
347 "");
348}
349
350// Tests a failed EXPECT_PRED_FORMAT1 where the
351// predicate-formatter is a functor on a built-in type (int).
352TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
354 { // NOLINT
356 finished_ = true;
357 },
358 "");
359}
360
361// Tests a failed EXPECT_PRED_FORMAT1 where the
362// predicate-formatter is a functor on a user-defined type (Bool).
363TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
365 { // NOLINT
367 finished_ = true;
368 },
369 "");
370}
371
372// Tests a successful ASSERT_PRED_FORMAT1 where the
373// predicate-formatter is a function on a built-in type (int).
374TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
376 finished_ = true;
377}
378
379// Tests a successful ASSERT_PRED_FORMAT1 where the
380// predicate-formatter is a function on a user-defined type (Bool).
381TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
383 finished_ = true;
384}
385
386// Tests a successful ASSERT_PRED_FORMAT1 where the
387// predicate-formatter is a functor on a built-in type (int).
388TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
390 finished_ = true;
391}
392
393// Tests a successful ASSERT_PRED_FORMAT1 where the
394// predicate-formatter is a functor on a user-defined type (Bool).
395TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
397 finished_ = true;
398}
399
400// Tests a failed ASSERT_PRED_FORMAT1 where the
401// predicate-formatter is a function on a built-in type (int).
402TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
403 expected_to_finish_ = false;
405 { // NOLINT
407 finished_ = true;
408 },
409 "");
410}
411
412// Tests a failed ASSERT_PRED_FORMAT1 where the
413// predicate-formatter is a function on a user-defined type (Bool).
414TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
415 expected_to_finish_ = false;
417 { // NOLINT
419 finished_ = true;
420 },
421 "");
422}
423
424// Tests a failed ASSERT_PRED_FORMAT1 where the
425// predicate-formatter is a functor on a built-in type (int).
426TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
427 expected_to_finish_ = false;
429 { // NOLINT
431 finished_ = true;
432 },
433 "");
434}
435
436// Tests a failed ASSERT_PRED_FORMAT1 where the
437// predicate-formatter is a functor on a user-defined type (Bool).
438TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
439 expected_to_finish_ = false;
441 { // NOLINT
443 finished_ = true;
444 },
445 "");
446}
447// Sample functions/functors for testing binary predicate assertions.
448
449// A binary predicate function.
450template <typename T1, typename T2>
451bool PredFunction2(T1 v1, T2 v2) {
452 return v1 + v2 > 0;
453}
454
455// The following two functions are needed because a compiler doesn't have
456// a context yet to know which template function must be instantiated.
457bool PredFunction2Int(int v1, int v2) { return v1 + v2 > 0; }
458bool PredFunction2Bool(Bool v1, Bool v2) { return v1 + v2 > 0; }
459
460// A binary predicate functor.
462 template <typename T1, typename T2>
463 bool operator()(const T1& v1, const T2& v2) {
464 return v1 + v2 > 0;
465 }
466};
467
468// A binary predicate-formatter function.
469template <typename T1, typename T2>
470testing::AssertionResult PredFormatFunction2(const char* e1, const char* e2,
471 const T1& v1, const T2& v2) {
472 if (PredFunction2(v1, v2)) return testing::AssertionSuccess();
473
475 << e1 << " + " << e2
476 << " is expected to be positive, but evaluates to " << v1 + v2 << ".";
477}
478
479// A binary predicate-formatter functor.
481 template <typename T1, typename T2>
482 testing::AssertionResult operator()(const char* e1, const char* e2,
483 const T1& v1, const T2& v2) const {
484 return PredFormatFunction2(e1, e2, v1, v2);
485 }
486};
487
488// Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
489
491 protected:
492 void SetUp() override {
493 expected_to_finish_ = true;
494 finished_ = false;
495 n1_ = n2_ = 0;
496 }
497
498 void TearDown() override {
499 // Verifies that each of the predicate's arguments was evaluated
500 // exactly once.
501 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
502 "exactly once.";
503 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
504 "exactly once.";
505
506 // Verifies that the control flow in the test function is expected.
508 FAIL() << "The predicate assertion unexpectedly aborted the test.";
509 } else if (!expected_to_finish_ && finished_) {
510 FAIL() << "The failed predicate assertion didn't abort the test "
511 "as expected.";
512 }
513 }
514
515 // true if and only if the test function is expected to run to finish.
517
518 // true if and only if the test function did run to finish.
519 static bool finished_;
520
521 static int n1_;
522 static int n2_;
523};
524
529
534
535// Tests a successful EXPECT_PRED2 where the
536// predicate-formatter is a function on a built-in type (int).
537TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
538 EXPECT_PRED2(PredFunction2Int, ++n1_, ++n2_);
539 finished_ = true;
540}
541
542// Tests a successful EXPECT_PRED2 where the
543// predicate-formatter is a function on a user-defined type (Bool).
544TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
545 EXPECT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
546 finished_ = true;
547}
548
549// Tests a successful EXPECT_PRED2 where the
550// predicate-formatter is a functor on a built-in type (int).
551TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
552 EXPECT_PRED2(PredFunctor2(), ++n1_, ++n2_);
553 finished_ = true;
554}
555
556// Tests a successful EXPECT_PRED2 where the
557// predicate-formatter is a functor on a user-defined type (Bool).
558TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
559 EXPECT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
560 finished_ = true;
561}
562
563// Tests a failed EXPECT_PRED2 where the
564// predicate-formatter is a function on a built-in type (int).
565TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
567 { // NOLINT
568 EXPECT_PRED2(PredFunction2Int, n1_++, n2_++);
569 finished_ = true;
570 },
571 "");
572}
573
574// Tests a failed EXPECT_PRED2 where the
575// predicate-formatter is a function on a user-defined type (Bool).
576TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
578 { // NOLINT
579 EXPECT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
580 finished_ = true;
581 },
582 "");
583}
584
585// Tests a failed EXPECT_PRED2 where the
586// predicate-formatter is a functor on a built-in type (int).
587TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
589 { // NOLINT
590 EXPECT_PRED2(PredFunctor2(), n1_++, n2_++);
591 finished_ = true;
592 },
593 "");
594}
595
596// Tests a failed EXPECT_PRED2 where the
597// predicate-formatter is a functor on a user-defined type (Bool).
598TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
600 { // NOLINT
601 EXPECT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
602 finished_ = true;
603 },
604 "");
605}
606
607// Tests a successful ASSERT_PRED2 where the
608// predicate-formatter is a function on a built-in type (int).
609TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
610 ASSERT_PRED2(PredFunction2Int, ++n1_, ++n2_);
611 finished_ = true;
612}
613
614// Tests a successful ASSERT_PRED2 where the
615// predicate-formatter is a function on a user-defined type (Bool).
616TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
617 ASSERT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
618 finished_ = true;
619}
620
621// Tests a successful ASSERT_PRED2 where the
622// predicate-formatter is a functor on a built-in type (int).
623TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
624 ASSERT_PRED2(PredFunctor2(), ++n1_, ++n2_);
625 finished_ = true;
626}
627
628// Tests a successful ASSERT_PRED2 where the
629// predicate-formatter is a functor on a user-defined type (Bool).
630TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
631 ASSERT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
632 finished_ = true;
633}
634
635// Tests a failed ASSERT_PRED2 where the
636// predicate-formatter is a function on a built-in type (int).
637TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
638 expected_to_finish_ = false;
640 { // NOLINT
641 ASSERT_PRED2(PredFunction2Int, n1_++, n2_++);
642 finished_ = true;
643 },
644 "");
645}
646
647// Tests a failed ASSERT_PRED2 where the
648// predicate-formatter is a function on a user-defined type (Bool).
649TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
650 expected_to_finish_ = false;
652 { // NOLINT
653 ASSERT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
654 finished_ = true;
655 },
656 "");
657}
658
659// Tests a failed ASSERT_PRED2 where the
660// predicate-formatter is a functor on a built-in type (int).
661TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
662 expected_to_finish_ = false;
664 { // NOLINT
665 ASSERT_PRED2(PredFunctor2(), n1_++, n2_++);
666 finished_ = true;
667 },
668 "");
669}
670
671// Tests a failed ASSERT_PRED2 where the
672// predicate-formatter is a functor on a user-defined type (Bool).
673TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
674 expected_to_finish_ = false;
676 { // NOLINT
677 ASSERT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
678 finished_ = true;
679 },
680 "");
681}
682
683// Tests a successful EXPECT_PRED_FORMAT2 where the
684// predicate-formatter is a function on a built-in type (int).
685TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
687 finished_ = true;
688}
689
690// Tests a successful EXPECT_PRED_FORMAT2 where the
691// predicate-formatter is a function on a user-defined type (Bool).
692TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
694 finished_ = true;
695}
696
697// Tests a successful EXPECT_PRED_FORMAT2 where the
698// predicate-formatter is a functor on a built-in type (int).
699TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
701 finished_ = true;
702}
703
704// Tests a successful EXPECT_PRED_FORMAT2 where the
705// predicate-formatter is a functor on a user-defined type (Bool).
706TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
708 finished_ = true;
709}
710
711// Tests a failed EXPECT_PRED_FORMAT2 where the
712// predicate-formatter is a function on a built-in type (int).
713TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
715 { // NOLINT
717 finished_ = true;
718 },
719 "");
720}
721
722// Tests a failed EXPECT_PRED_FORMAT2 where the
723// predicate-formatter is a function on a user-defined type (Bool).
724TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
726 { // NOLINT
728 finished_ = true;
729 },
730 "");
731}
732
733// Tests a failed EXPECT_PRED_FORMAT2 where the
734// predicate-formatter is a functor on a built-in type (int).
735TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
737 { // NOLINT
739 finished_ = true;
740 },
741 "");
742}
743
744// Tests a failed EXPECT_PRED_FORMAT2 where the
745// predicate-formatter is a functor on a user-defined type (Bool).
746TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
748 { // NOLINT
750 finished_ = true;
751 },
752 "");
753}
754
755// Tests a successful ASSERT_PRED_FORMAT2 where the
756// predicate-formatter is a function on a built-in type (int).
757TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
759 finished_ = true;
760}
761
762// Tests a successful ASSERT_PRED_FORMAT2 where the
763// predicate-formatter is a function on a user-defined type (Bool).
764TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
766 finished_ = true;
767}
768
769// Tests a successful ASSERT_PRED_FORMAT2 where the
770// predicate-formatter is a functor on a built-in type (int).
771TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
773 finished_ = true;
774}
775
776// Tests a successful ASSERT_PRED_FORMAT2 where the
777// predicate-formatter is a functor on a user-defined type (Bool).
778TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
780 finished_ = true;
781}
782
783// Tests a failed ASSERT_PRED_FORMAT2 where the
784// predicate-formatter is a function on a built-in type (int).
785TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
786 expected_to_finish_ = false;
788 { // NOLINT
790 finished_ = true;
791 },
792 "");
793}
794
795// Tests a failed ASSERT_PRED_FORMAT2 where the
796// predicate-formatter is a function on a user-defined type (Bool).
797TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
798 expected_to_finish_ = false;
800 { // NOLINT
802 finished_ = true;
803 },
804 "");
805}
806
807// Tests a failed ASSERT_PRED_FORMAT2 where the
808// predicate-formatter is a functor on a built-in type (int).
809TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
810 expected_to_finish_ = false;
812 { // NOLINT
814 finished_ = true;
815 },
816 "");
817}
818
819// Tests a failed ASSERT_PRED_FORMAT2 where the
820// predicate-formatter is a functor on a user-defined type (Bool).
821TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
822 expected_to_finish_ = false;
824 { // NOLINT
826 finished_ = true;
827 },
828 "");
829}
830// Sample functions/functors for testing ternary predicate assertions.
831
832// A ternary predicate function.
833template <typename T1, typename T2, typename T3>
834bool PredFunction3(T1 v1, T2 v2, T3 v3) {
835 return v1 + v2 + v3 > 0;
836}
837
838// The following two functions are needed because a compiler doesn't have
839// a context yet to know which template function must be instantiated.
840bool PredFunction3Int(int v1, int v2, int v3) { return v1 + v2 + v3 > 0; }
841bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) { return v1 + v2 + v3 > 0; }
842
843// A ternary predicate functor.
845 template <typename T1, typename T2, typename T3>
846 bool operator()(const T1& v1, const T2& v2, const T3& v3) {
847 return v1 + v2 + v3 > 0;
848 }
849};
850
851// A ternary predicate-formatter function.
852template <typename T1, typename T2, typename T3>
853testing::AssertionResult PredFormatFunction3(const char* e1, const char* e2,
854 const char* e3, const T1& v1,
855 const T2& v2, const T3& v3) {
856 if (PredFunction3(v1, v2, v3)) return testing::AssertionSuccess();
857
859 << e1 << " + " << e2 << " + " << e3
860 << " is expected to be positive, but evaluates to " << v1 + v2 + v3
861 << ".";
862}
863
864// A ternary predicate-formatter functor.
866 template <typename T1, typename T2, typename T3>
867 testing::AssertionResult operator()(const char* e1, const char* e2,
868 const char* e3, const T1& v1,
869 const T2& v2, const T3& v3) const {
870 return PredFormatFunction3(e1, e2, e3, v1, v2, v3);
871 }
872};
873
874// Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
875
877 protected:
878 void SetUp() override {
879 expected_to_finish_ = true;
880 finished_ = false;
881 n1_ = n2_ = n3_ = 0;
882 }
883
884 void TearDown() override {
885 // Verifies that each of the predicate's arguments was evaluated
886 // exactly once.
887 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
888 "exactly once.";
889 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
890 "exactly once.";
891 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
892 "exactly once.";
893
894 // Verifies that the control flow in the test function is expected.
896 FAIL() << "The predicate assertion unexpectedly aborted the test.";
897 } else if (!expected_to_finish_ && finished_) {
898 FAIL() << "The failed predicate assertion didn't abort the test "
899 "as expected.";
900 }
901 }
902
903 // true if and only if the test function is expected to run to finish.
905
906 // true if and only if the test function did run to finish.
907 static bool finished_;
908
909 static int n1_;
910 static int n2_;
911 static int n3_;
912};
913
919
924
925// Tests a successful EXPECT_PRED3 where the
926// predicate-formatter is a function on a built-in type (int).
927TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
928 EXPECT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
929 finished_ = true;
930}
931
932// Tests a successful EXPECT_PRED3 where the
933// predicate-formatter is a function on a user-defined type (Bool).
934TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
935 EXPECT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
936 finished_ = true;
937}
938
939// Tests a successful EXPECT_PRED3 where the
940// predicate-formatter is a functor on a built-in type (int).
941TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
942 EXPECT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
943 finished_ = true;
944}
945
946// Tests a successful EXPECT_PRED3 where the
947// predicate-formatter is a functor on a user-defined type (Bool).
948TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
949 EXPECT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
950 finished_ = true;
951}
952
953// Tests a failed EXPECT_PRED3 where the
954// predicate-formatter is a function on a built-in type (int).
955TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
957 { // NOLINT
958 EXPECT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
959 finished_ = true;
960 },
961 "");
962}
963
964// Tests a failed EXPECT_PRED3 where the
965// predicate-formatter is a function on a user-defined type (Bool).
966TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
968 { // NOLINT
969 EXPECT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
970 finished_ = true;
971 },
972 "");
973}
974
975// Tests a failed EXPECT_PRED3 where the
976// predicate-formatter is a functor on a built-in type (int).
977TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
979 { // NOLINT
980 EXPECT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
981 finished_ = true;
982 },
983 "");
984}
985
986// Tests a failed EXPECT_PRED3 where the
987// predicate-formatter is a functor on a user-defined type (Bool).
988TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
990 { // NOLINT
991 EXPECT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
992 finished_ = true;
993 },
994 "");
995}
996
997// Tests a successful ASSERT_PRED3 where the
998// predicate-formatter is a function on a built-in type (int).
999TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
1000 ASSERT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
1001 finished_ = true;
1002}
1003
1004// Tests a successful ASSERT_PRED3 where the
1005// predicate-formatter is a function on a user-defined type (Bool).
1006TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
1007 ASSERT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
1008 finished_ = true;
1009}
1010
1011// Tests a successful ASSERT_PRED3 where the
1012// predicate-formatter is a functor on a built-in type (int).
1013TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
1014 ASSERT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
1015 finished_ = true;
1016}
1017
1018// Tests a successful ASSERT_PRED3 where the
1019// predicate-formatter is a functor on a user-defined type (Bool).
1020TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
1021 ASSERT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
1022 finished_ = true;
1023}
1024
1025// Tests a failed ASSERT_PRED3 where the
1026// predicate-formatter is a function on a built-in type (int).
1027TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
1028 expected_to_finish_ = false;
1030 { // NOLINT
1031 ASSERT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
1032 finished_ = true;
1033 },
1034 "");
1035}
1036
1037// Tests a failed ASSERT_PRED3 where the
1038// predicate-formatter is a function on a user-defined type (Bool).
1039TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
1040 expected_to_finish_ = false;
1042 { // NOLINT
1043 ASSERT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
1044 finished_ = true;
1045 },
1046 "");
1047}
1048
1049// Tests a failed ASSERT_PRED3 where the
1050// predicate-formatter is a functor on a built-in type (int).
1051TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
1052 expected_to_finish_ = false;
1054 { // NOLINT
1055 ASSERT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
1056 finished_ = true;
1057 },
1058 "");
1059}
1060
1061// Tests a failed ASSERT_PRED3 where the
1062// predicate-formatter is a functor on a user-defined type (Bool).
1063TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
1064 expected_to_finish_ = false;
1066 { // NOLINT
1067 ASSERT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
1068 finished_ = true;
1069 },
1070 "");
1071}
1072
1073// Tests a successful EXPECT_PRED_FORMAT3 where the
1074// predicate-formatter is a function on a built-in type (int).
1075TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1076 EXPECT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1077 finished_ = true;
1078}
1079
1080// Tests a successful EXPECT_PRED_FORMAT3 where the
1081// predicate-formatter is a function on a user-defined type (Bool).
1082TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1084 Bool(++n3_));
1085 finished_ = true;
1086}
1087
1088// Tests a successful EXPECT_PRED_FORMAT3 where the
1089// predicate-formatter is a functor on a built-in type (int).
1090TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1091 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1092 finished_ = true;
1093}
1094
1095// Tests a successful EXPECT_PRED_FORMAT3 where the
1096// predicate-formatter is a functor on a user-defined type (Bool).
1097TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1099 Bool(++n3_));
1100 finished_ = true;
1101}
1102
1103// Tests a failed EXPECT_PRED_FORMAT3 where the
1104// predicate-formatter is a function on a built-in type (int).
1105TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1107 { // NOLINT
1108 EXPECT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1109 finished_ = true;
1110 },
1111 "");
1112}
1113
1114// Tests a failed EXPECT_PRED_FORMAT3 where the
1115// predicate-formatter is a function on a user-defined type (Bool).
1116TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1118 { // NOLINT
1120 Bool(n3_++));
1121 finished_ = true;
1122 },
1123 "");
1124}
1125
1126// Tests a failed EXPECT_PRED_FORMAT3 where the
1127// predicate-formatter is a functor on a built-in type (int).
1128TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1130 { // NOLINT
1131 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1132 finished_ = true;
1133 },
1134 "");
1135}
1136
1137// Tests a failed EXPECT_PRED_FORMAT3 where the
1138// predicate-formatter is a functor on a user-defined type (Bool).
1139TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1141 { // NOLINT
1143 Bool(n3_++));
1144 finished_ = true;
1145 },
1146 "");
1147}
1148
1149// Tests a successful ASSERT_PRED_FORMAT3 where the
1150// predicate-formatter is a function on a built-in type (int).
1151TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1152 ASSERT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1153 finished_ = true;
1154}
1155
1156// Tests a successful ASSERT_PRED_FORMAT3 where the
1157// predicate-formatter is a function on a user-defined type (Bool).
1158TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1160 Bool(++n3_));
1161 finished_ = true;
1162}
1163
1164// Tests a successful ASSERT_PRED_FORMAT3 where the
1165// predicate-formatter is a functor on a built-in type (int).
1166TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1167 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1168 finished_ = true;
1169}
1170
1171// Tests a successful ASSERT_PRED_FORMAT3 where the
1172// predicate-formatter is a functor on a user-defined type (Bool).
1173TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1175 Bool(++n3_));
1176 finished_ = true;
1177}
1178
1179// Tests a failed ASSERT_PRED_FORMAT3 where the
1180// predicate-formatter is a function on a built-in type (int).
1181TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1182 expected_to_finish_ = false;
1184 { // NOLINT
1185 ASSERT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1186 finished_ = true;
1187 },
1188 "");
1189}
1190
1191// Tests a failed ASSERT_PRED_FORMAT3 where the
1192// predicate-formatter is a function on a user-defined type (Bool).
1193TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1194 expected_to_finish_ = false;
1196 { // NOLINT
1198 Bool(n3_++));
1199 finished_ = true;
1200 },
1201 "");
1202}
1203
1204// Tests a failed ASSERT_PRED_FORMAT3 where the
1205// predicate-formatter is a functor on a built-in type (int).
1206TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1207 expected_to_finish_ = false;
1209 { // NOLINT
1210 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1211 finished_ = true;
1212 },
1213 "");
1214}
1215
1216// Tests a failed ASSERT_PRED_FORMAT3 where the
1217// predicate-formatter is a functor on a user-defined type (Bool).
1218TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1219 expected_to_finish_ = false;
1221 { // NOLINT
1223 Bool(n3_++));
1224 finished_ = true;
1225 },
1226 "");
1227}
1228// Sample functions/functors for testing 4-ary predicate assertions.
1229
1230// A 4-ary predicate function.
1231template <typename T1, typename T2, typename T3, typename T4>
1232bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
1233 return v1 + v2 + v3 + v4 > 0;
1234}
1235
1236// The following two functions are needed because a compiler doesn't have
1237// a context yet to know which template function must be instantiated.
1238bool PredFunction4Int(int v1, int v2, int v3, int v4) {
1239 return v1 + v2 + v3 + v4 > 0;
1240}
1241bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
1242 return v1 + v2 + v3 + v4 > 0;
1243}
1244
1245// A 4-ary predicate functor.
1247 template <typename T1, typename T2, typename T3, typename T4>
1248 bool operator()(const T1& v1, const T2& v2, const T3& v3, const T4& v4) {
1249 return v1 + v2 + v3 + v4 > 0;
1250 }
1251};
1252
1253// A 4-ary predicate-formatter function.
1254template <typename T1, typename T2, typename T3, typename T4>
1255testing::AssertionResult PredFormatFunction4(const char* e1, const char* e2,
1256 const char* e3, const char* e4,
1257 const T1& v1, const T2& v2,
1258 const T3& v3, const T4& v4) {
1259 if (PredFunction4(v1, v2, v3, v4)) return testing::AssertionSuccess();
1260
1262 << e1 << " + " << e2 << " + " << e3 << " + " << e4
1263 << " is expected to be positive, but evaluates to "
1264 << v1 + v2 + v3 + v4 << ".";
1265}
1266
1267// A 4-ary predicate-formatter functor.
1269 template <typename T1, typename T2, typename T3, typename T4>
1270 testing::AssertionResult operator()(const char* e1, const char* e2,
1271 const char* e3, const char* e4,
1272 const T1& v1, const T2& v2, const T3& v3,
1273 const T4& v4) const {
1274 return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);
1275 }
1276};
1277
1278// Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
1279
1281 protected:
1282 void SetUp() override {
1283 expected_to_finish_ = true;
1284 finished_ = false;
1285 n1_ = n2_ = n3_ = n4_ = 0;
1286 }
1287
1288 void TearDown() override {
1289 // Verifies that each of the predicate's arguments was evaluated
1290 // exactly once.
1291 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1292 "exactly once.";
1293 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1294 "exactly once.";
1295 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1296 "exactly once.";
1297 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1298 "exactly once.";
1299
1300 // Verifies that the control flow in the test function is expected.
1302 FAIL() << "The predicate assertion unexpectedly aborted the test.";
1303 } else if (!expected_to_finish_ && finished_) {
1304 FAIL() << "The failed predicate assertion didn't abort the test "
1305 "as expected.";
1306 }
1307 }
1308
1309 // true if and only if the test function is expected to run to finish.
1311
1312 // true if and only if the test function did run to finish.
1313 static bool finished_;
1314
1315 static int n1_;
1316 static int n2_;
1317 static int n3_;
1318 static int n4_;
1319};
1320
1327
1332
1333// Tests a successful EXPECT_PRED4 where the
1334// predicate-formatter is a function on a built-in type (int).
1335TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1336 EXPECT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1337 finished_ = true;
1338}
1339
1340// Tests a successful EXPECT_PRED4 where the
1341// predicate-formatter is a function on a user-defined type (Bool).
1342TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
1343 EXPECT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1344 Bool(++n4_));
1345 finished_ = true;
1346}
1347
1348// Tests a successful EXPECT_PRED4 where the
1349// predicate-formatter is a functor on a built-in type (int).
1350TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1351 EXPECT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1352 finished_ = true;
1353}
1354
1355// Tests a successful EXPECT_PRED4 where the
1356// predicate-formatter is a functor on a user-defined type (Bool).
1357TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
1358 EXPECT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1359 Bool(++n4_));
1360 finished_ = true;
1361}
1362
1363// Tests a failed EXPECT_PRED4 where the
1364// predicate-formatter is a function on a built-in type (int).
1365TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1367 { // NOLINT
1368 EXPECT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1369 finished_ = true;
1370 },
1371 "");
1372}
1373
1374// Tests a failed EXPECT_PRED4 where the
1375// predicate-formatter is a function on a user-defined type (Bool).
1376TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
1378 { // NOLINT
1379 EXPECT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1380 Bool(n4_++));
1381 finished_ = true;
1382 },
1383 "");
1384}
1385
1386// Tests a failed EXPECT_PRED4 where the
1387// predicate-formatter is a functor on a built-in type (int).
1388TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1390 { // NOLINT
1391 EXPECT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1392 finished_ = true;
1393 },
1394 "");
1395}
1396
1397// Tests a failed EXPECT_PRED4 where the
1398// predicate-formatter is a functor on a user-defined type (Bool).
1399TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
1401 { // NOLINT
1402 EXPECT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1403 Bool(n4_++));
1404 finished_ = true;
1405 },
1406 "");
1407}
1408
1409// Tests a successful ASSERT_PRED4 where the
1410// predicate-formatter is a function on a built-in type (int).
1411TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1412 ASSERT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1413 finished_ = true;
1414}
1415
1416// Tests a successful ASSERT_PRED4 where the
1417// predicate-formatter is a function on a user-defined type (Bool).
1418TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
1419 ASSERT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1420 Bool(++n4_));
1421 finished_ = true;
1422}
1423
1424// Tests a successful ASSERT_PRED4 where the
1425// predicate-formatter is a functor on a built-in type (int).
1426TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1427 ASSERT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1428 finished_ = true;
1429}
1430
1431// Tests a successful ASSERT_PRED4 where the
1432// predicate-formatter is a functor on a user-defined type (Bool).
1433TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
1434 ASSERT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1435 Bool(++n4_));
1436 finished_ = true;
1437}
1438
1439// Tests a failed ASSERT_PRED4 where the
1440// predicate-formatter is a function on a built-in type (int).
1441TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1442 expected_to_finish_ = false;
1444 { // NOLINT
1445 ASSERT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1446 finished_ = true;
1447 },
1448 "");
1449}
1450
1451// Tests a failed ASSERT_PRED4 where the
1452// predicate-formatter is a function on a user-defined type (Bool).
1453TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
1454 expected_to_finish_ = false;
1456 { // NOLINT
1457 ASSERT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1458 Bool(n4_++));
1459 finished_ = true;
1460 },
1461 "");
1462}
1463
1464// Tests a failed ASSERT_PRED4 where the
1465// predicate-formatter is a functor on a built-in type (int).
1466TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1467 expected_to_finish_ = false;
1469 { // NOLINT
1470 ASSERT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1471 finished_ = true;
1472 },
1473 "");
1474}
1475
1476// Tests a failed ASSERT_PRED4 where the
1477// predicate-formatter is a functor on a user-defined type (Bool).
1478TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
1479 expected_to_finish_ = false;
1481 { // NOLINT
1482 ASSERT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1483 Bool(n4_++));
1484 finished_ = true;
1485 },
1486 "");
1487}
1488
1489// Tests a successful EXPECT_PRED_FORMAT4 where the
1490// predicate-formatter is a function on a built-in type (int).
1491TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1492 EXPECT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1493 finished_ = true;
1494}
1495
1496// Tests a successful EXPECT_PRED_FORMAT4 where the
1497// predicate-formatter is a function on a user-defined type (Bool).
1498TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1500 Bool(++n3_), Bool(++n4_));
1501 finished_ = true;
1502}
1503
1504// Tests a successful EXPECT_PRED_FORMAT4 where the
1505// predicate-formatter is a functor on a built-in type (int).
1506TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1507 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1508 finished_ = true;
1509}
1510
1511// Tests a successful EXPECT_PRED_FORMAT4 where the
1512// predicate-formatter is a functor on a user-defined type (Bool).
1513TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1515 Bool(++n3_), Bool(++n4_));
1516 finished_ = true;
1517}
1518
1519// Tests a failed EXPECT_PRED_FORMAT4 where the
1520// predicate-formatter is a function on a built-in type (int).
1521TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1523 { // NOLINT
1524 EXPECT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1525 finished_ = true;
1526 },
1527 "");
1528}
1529
1530// Tests a failed EXPECT_PRED_FORMAT4 where the
1531// predicate-formatter is a function on a user-defined type (Bool).
1532TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1534 { // NOLINT
1536 Bool(n3_++), Bool(n4_++));
1537 finished_ = true;
1538 },
1539 "");
1540}
1541
1542// Tests a failed EXPECT_PRED_FORMAT4 where the
1543// predicate-formatter is a functor on a built-in type (int).
1544TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1546 { // NOLINT
1547 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1548 finished_ = true;
1549 },
1550 "");
1551}
1552
1553// Tests a failed EXPECT_PRED_FORMAT4 where the
1554// predicate-formatter is a functor on a user-defined type (Bool).
1555TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1557 { // NOLINT
1559 Bool(n3_++), Bool(n4_++));
1560 finished_ = true;
1561 },
1562 "");
1563}
1564
1565// Tests a successful ASSERT_PRED_FORMAT4 where the
1566// predicate-formatter is a function on a built-in type (int).
1567TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1568 ASSERT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1569 finished_ = true;
1570}
1571
1572// Tests a successful ASSERT_PRED_FORMAT4 where the
1573// predicate-formatter is a function on a user-defined type (Bool).
1574TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1576 Bool(++n3_), Bool(++n4_));
1577 finished_ = true;
1578}
1579
1580// Tests a successful ASSERT_PRED_FORMAT4 where the
1581// predicate-formatter is a functor on a built-in type (int).
1582TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1583 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1584 finished_ = true;
1585}
1586
1587// Tests a successful ASSERT_PRED_FORMAT4 where the
1588// predicate-formatter is a functor on a user-defined type (Bool).
1589TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1591 Bool(++n3_), Bool(++n4_));
1592 finished_ = true;
1593}
1594
1595// Tests a failed ASSERT_PRED_FORMAT4 where the
1596// predicate-formatter is a function on a built-in type (int).
1597TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1598 expected_to_finish_ = false;
1600 { // NOLINT
1601 ASSERT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1602 finished_ = true;
1603 },
1604 "");
1605}
1606
1607// Tests a failed ASSERT_PRED_FORMAT4 where the
1608// predicate-formatter is a function on a user-defined type (Bool).
1609TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1610 expected_to_finish_ = false;
1612 { // NOLINT
1614 Bool(n3_++), Bool(n4_++));
1615 finished_ = true;
1616 },
1617 "");
1618}
1619
1620// Tests a failed ASSERT_PRED_FORMAT4 where the
1621// predicate-formatter is a functor on a built-in type (int).
1622TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1623 expected_to_finish_ = false;
1625 { // NOLINT
1626 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1627 finished_ = true;
1628 },
1629 "");
1630}
1631
1632// Tests a failed ASSERT_PRED_FORMAT4 where the
1633// predicate-formatter is a functor on a user-defined type (Bool).
1634TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1635 expected_to_finish_ = false;
1637 { // NOLINT
1639 Bool(n3_++), Bool(n4_++));
1640 finished_ = true;
1641 },
1642 "");
1643}
1644// Sample functions/functors for testing 5-ary predicate assertions.
1645
1646// A 5-ary predicate function.
1647template <typename T1, typename T2, typename T3, typename T4, typename T5>
1648bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
1649 return v1 + v2 + v3 + v4 + v5 > 0;
1650}
1651
1652// The following two functions are needed because a compiler doesn't have
1653// a context yet to know which template function must be instantiated.
1654bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
1655 return v1 + v2 + v3 + v4 + v5 > 0;
1656}
1657bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
1658 return v1 + v2 + v3 + v4 + v5 > 0;
1659}
1660
1661// A 5-ary predicate functor.
1663 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1664 bool operator()(const T1& v1, const T2& v2, const T3& v3, const T4& v4,
1665 const T5& v5) {
1666 return v1 + v2 + v3 + v4 + v5 > 0;
1667 }
1668};
1669
1670// A 5-ary predicate-formatter function.
1671template <typename T1, typename T2, typename T3, typename T4, typename T5>
1672testing::AssertionResult PredFormatFunction5(const char* e1, const char* e2,
1673 const char* e3, const char* e4,
1674 const char* e5, const T1& v1,
1675 const T2& v2, const T3& v3,
1676 const T4& v4, const T5& v5) {
1677 if (PredFunction5(v1, v2, v3, v4, v5)) return testing::AssertionSuccess();
1678
1680 << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
1681 << " is expected to be positive, but evaluates to "
1682 << v1 + v2 + v3 + v4 + v5 << ".";
1683}
1684
1685// A 5-ary predicate-formatter functor.
1687 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1688 testing::AssertionResult operator()(const char* e1, const char* e2,
1689 const char* e3, const char* e4,
1690 const char* e5, const T1& v1,
1691 const T2& v2, const T3& v3, const T4& v4,
1692 const T5& v5) const {
1693 return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);
1694 }
1695};
1696
1697// Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
1698
1700 protected:
1701 void SetUp() override {
1702 expected_to_finish_ = true;
1703 finished_ = false;
1704 n1_ = n2_ = n3_ = n4_ = n5_ = 0;
1705 }
1706
1707 void TearDown() override {
1708 // Verifies that each of the predicate's arguments was evaluated
1709 // exactly once.
1710 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1711 "exactly once.";
1712 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1713 "exactly once.";
1714 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1715 "exactly once.";
1716 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1717 "exactly once.";
1718 EXPECT_EQ(1, n5_) << "The predicate assertion didn't evaluate argument 6 "
1719 "exactly once.";
1720
1721 // Verifies that the control flow in the test function is expected.
1723 FAIL() << "The predicate assertion unexpectedly aborted the test.";
1724 } else if (!expected_to_finish_ && finished_) {
1725 FAIL() << "The failed predicate assertion didn't abort the test "
1726 "as expected.";
1727 }
1728 }
1729
1730 // true if and only if the test function is expected to run to finish.
1732
1733 // true if and only if the test function did run to finish.
1734 static bool finished_;
1735
1736 static int n1_;
1737 static int n2_;
1738 static int n3_;
1739 static int n4_;
1740 static int n5_;
1741};
1742
1750
1755
1756// Tests a successful EXPECT_PRED5 where the
1757// predicate-formatter is a function on a built-in type (int).
1758TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1759 EXPECT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1760 finished_ = true;
1761}
1762
1763// Tests a successful EXPECT_PRED5 where the
1764// predicate-formatter is a function on a user-defined type (Bool).
1765TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
1766 EXPECT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1767 Bool(++n4_), Bool(++n5_));
1768 finished_ = true;
1769}
1770
1771// Tests a successful EXPECT_PRED5 where the
1772// predicate-formatter is a functor on a built-in type (int).
1773TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1774 EXPECT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1775 finished_ = true;
1776}
1777
1778// Tests a successful EXPECT_PRED5 where the
1779// predicate-formatter is a functor on a user-defined type (Bool).
1780TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
1781 EXPECT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1782 Bool(++n4_), Bool(++n5_));
1783 finished_ = true;
1784}
1785
1786// Tests a failed EXPECT_PRED5 where the
1787// predicate-formatter is a function on a built-in type (int).
1788TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1790 { // NOLINT
1791 EXPECT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1792 finished_ = true;
1793 },
1794 "");
1795}
1796
1797// Tests a failed EXPECT_PRED5 where the
1798// predicate-formatter is a function on a user-defined type (Bool).
1799TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
1801 { // NOLINT
1802 EXPECT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1803 Bool(n4_++), Bool(n5_++));
1804 finished_ = true;
1805 },
1806 "");
1807}
1808
1809// Tests a failed EXPECT_PRED5 where the
1810// predicate-formatter is a functor on a built-in type (int).
1811TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1813 { // NOLINT
1814 EXPECT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1815 finished_ = true;
1816 },
1817 "");
1818}
1819
1820// Tests a failed EXPECT_PRED5 where the
1821// predicate-formatter is a functor on a user-defined type (Bool).
1822TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
1824 { // NOLINT
1825 EXPECT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1826 Bool(n4_++), Bool(n5_++));
1827 finished_ = true;
1828 },
1829 "");
1830}
1831
1832// Tests a successful ASSERT_PRED5 where the
1833// predicate-formatter is a function on a built-in type (int).
1834TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1835 ASSERT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1836 finished_ = true;
1837}
1838
1839// Tests a successful ASSERT_PRED5 where the
1840// predicate-formatter is a function on a user-defined type (Bool).
1841TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
1842 ASSERT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1843 Bool(++n4_), Bool(++n5_));
1844 finished_ = true;
1845}
1846
1847// Tests a successful ASSERT_PRED5 where the
1848// predicate-formatter is a functor on a built-in type (int).
1849TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1850 ASSERT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1851 finished_ = true;
1852}
1853
1854// Tests a successful ASSERT_PRED5 where the
1855// predicate-formatter is a functor on a user-defined type (Bool).
1856TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
1857 ASSERT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1858 Bool(++n4_), Bool(++n5_));
1859 finished_ = true;
1860}
1861
1862// Tests a failed ASSERT_PRED5 where the
1863// predicate-formatter is a function on a built-in type (int).
1864TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1865 expected_to_finish_ = false;
1867 { // NOLINT
1868 ASSERT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1869 finished_ = true;
1870 },
1871 "");
1872}
1873
1874// Tests a failed ASSERT_PRED5 where the
1875// predicate-formatter is a function on a user-defined type (Bool).
1876TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
1877 expected_to_finish_ = false;
1879 { // NOLINT
1880 ASSERT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1881 Bool(n4_++), Bool(n5_++));
1882 finished_ = true;
1883 },
1884 "");
1885}
1886
1887// Tests a failed ASSERT_PRED5 where the
1888// predicate-formatter is a functor on a built-in type (int).
1889TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1890 expected_to_finish_ = false;
1892 { // NOLINT
1893 ASSERT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1894 finished_ = true;
1895 },
1896 "");
1897}
1898
1899// Tests a failed ASSERT_PRED5 where the
1900// predicate-formatter is a functor on a user-defined type (Bool).
1901TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
1902 expected_to_finish_ = false;
1904 { // NOLINT
1905 ASSERT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1906 Bool(n4_++), Bool(n5_++));
1907 finished_ = true;
1908 },
1909 "");
1910}
1911
1912// Tests a successful EXPECT_PRED_FORMAT5 where the
1913// predicate-formatter is a function on a built-in type (int).
1914TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1915 EXPECT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1916 finished_ = true;
1917}
1918
1919// Tests a successful EXPECT_PRED_FORMAT5 where the
1920// predicate-formatter is a function on a user-defined type (Bool).
1921TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
1923 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1924 finished_ = true;
1925}
1926
1927// Tests a successful EXPECT_PRED_FORMAT5 where the
1928// predicate-formatter is a functor on a built-in type (int).
1929TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
1930 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1931 finished_ = true;
1932}
1933
1934// Tests a successful EXPECT_PRED_FORMAT5 where the
1935// predicate-formatter is a functor on a user-defined type (Bool).
1936TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
1938 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1939 finished_ = true;
1940}
1941
1942// Tests a failed EXPECT_PRED_FORMAT5 where the
1943// predicate-formatter is a function on a built-in type (int).
1944TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
1946 { // NOLINT
1947 EXPECT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
1948 n5_++);
1949 finished_ = true;
1950 },
1951 "");
1952}
1953
1954// Tests a failed EXPECT_PRED_FORMAT5 where the
1955// predicate-formatter is a function on a user-defined type (Bool).
1956TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
1958 { // NOLINT
1960 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1961 finished_ = true;
1962 },
1963 "");
1964}
1965
1966// Tests a failed EXPECT_PRED_FORMAT5 where the
1967// predicate-formatter is a functor on a built-in type (int).
1968TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
1970 { // NOLINT
1971 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
1972 n5_++);
1973 finished_ = true;
1974 },
1975 "");
1976}
1977
1978// Tests a failed EXPECT_PRED_FORMAT5 where the
1979// predicate-formatter is a functor on a user-defined type (Bool).
1980TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
1982 { // NOLINT
1984 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1985 finished_ = true;
1986 },
1987 "");
1988}
1989
1990// Tests a successful ASSERT_PRED_FORMAT5 where the
1991// predicate-formatter is a function on a built-in type (int).
1992TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1993 ASSERT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1994 finished_ = true;
1995}
1996
1997// Tests a successful ASSERT_PRED_FORMAT5 where the
1998// predicate-formatter is a function on a user-defined type (Bool).
1999TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
2001 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2002 finished_ = true;
2003}
2004
2005// Tests a successful ASSERT_PRED_FORMAT5 where the
2006// predicate-formatter is a functor on a built-in type (int).
2007TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
2008 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
2009 finished_ = true;
2010}
2011
2012// Tests a successful ASSERT_PRED_FORMAT5 where the
2013// predicate-formatter is a functor on a user-defined type (Bool).
2014TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
2016 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2017 finished_ = true;
2018}
2019
2020// Tests a failed ASSERT_PRED_FORMAT5 where the
2021// predicate-formatter is a function on a built-in type (int).
2022TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
2023 expected_to_finish_ = false;
2025 { // NOLINT
2026 ASSERT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
2027 n5_++);
2028 finished_ = true;
2029 },
2030 "");
2031}
2032
2033// Tests a failed ASSERT_PRED_FORMAT5 where the
2034// predicate-formatter is a function on a user-defined type (Bool).
2035TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
2036 expected_to_finish_ = false;
2038 { // NOLINT
2040 Bool(n3_++), Bool(n4_++), Bool(n5_++));
2041 finished_ = true;
2042 },
2043 "");
2044}
2045
2046// Tests a failed ASSERT_PRED_FORMAT5 where the
2047// predicate-formatter is a functor on a built-in type (int).
2048TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
2049 expected_to_finish_ = false;
2051 { // NOLINT
2052 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
2053 n5_++);
2054 finished_ = true;
2055 },
2056 "");
2057}
2058
2059// Tests a failed ASSERT_PRED_FORMAT5 where the
2060// predicate-formatter is a functor on a user-defined type (Bool).
2061TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
2062 expected_to_finish_ = false;
2064 { // NOLINT
2066 Bool(n3_++), Bool(n4_++), Bool(n5_++));
2067 finished_ = true;
2068 },
2069 "");
2070}
Definition gtest_pred_impl_unittest.cc:111
void SetUp() override
Definition gtest_pred_impl_unittest.cc:113
static int n1_
Definition gtest_pred_impl_unittest.cc:140
static bool finished_
Definition gtest_pred_impl_unittest.cc:138
void TearDown() override
Definition gtest_pred_impl_unittest.cc:119
static bool expected_to_finish_
Definition gtest_pred_impl_unittest.cc:135
Definition gtest_pred_impl_unittest.cc:490
void SetUp() override
Definition gtest_pred_impl_unittest.cc:492
static bool finished_
Definition gtest_pred_impl_unittest.cc:519
static bool expected_to_finish_
Definition gtest_pred_impl_unittest.cc:516
static int n2_
Definition gtest_pred_impl_unittest.cc:522
static int n1_
Definition gtest_pred_impl_unittest.cc:521
void TearDown() override
Definition gtest_pred_impl_unittest.cc:498
Definition gtest_pred_impl_unittest.cc:876
static int n2_
Definition gtest_pred_impl_unittest.cc:910
static bool expected_to_finish_
Definition gtest_pred_impl_unittest.cc:904
void SetUp() override
Definition gtest_pred_impl_unittest.cc:878
void TearDown() override
Definition gtest_pred_impl_unittest.cc:884
static bool finished_
Definition gtest_pred_impl_unittest.cc:907
static int n1_
Definition gtest_pred_impl_unittest.cc:909
static int n3_
Definition gtest_pred_impl_unittest.cc:911
Definition gtest_pred_impl_unittest.cc:1280
static int n3_
Definition gtest_pred_impl_unittest.cc:1317
static int n2_
Definition gtest_pred_impl_unittest.cc:1316
static bool expected_to_finish_
Definition gtest_pred_impl_unittest.cc:1310
static int n1_
Definition gtest_pred_impl_unittest.cc:1315
void SetUp() override
Definition gtest_pred_impl_unittest.cc:1282
static bool finished_
Definition gtest_pred_impl_unittest.cc:1313
void TearDown() override
Definition gtest_pred_impl_unittest.cc:1288
static int n4_
Definition gtest_pred_impl_unittest.cc:1318
Definition gtest_pred_impl_unittest.cc:1699
static int n1_
Definition gtest_pred_impl_unittest.cc:1736
static bool finished_
Definition gtest_pred_impl_unittest.cc:1734
static int n2_
Definition gtest_pred_impl_unittest.cc:1737
static int n4_
Definition gtest_pred_impl_unittest.cc:1739
static int n3_
Definition gtest_pred_impl_unittest.cc:1738
void SetUp() override
Definition gtest_pred_impl_unittest.cc:1701
static int n5_
Definition gtest_pred_impl_unittest.cc:1740
static bool expected_to_finish_
Definition gtest_pred_impl_unittest.cc:1731
void TearDown() override
Definition gtest_pred_impl_unittest.cc:1707
Definition gtest.h:243
int x
Definition gmock-matchers-containers_test.cc:376
#define EXPECT_FATAL_FAILURE(statement, substr)
Definition gtest-spi.h:149
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Definition gtest-spi.h:217
#define TEST_F(test_fixture, test_name)
Definition gtest.h:2208
#define FAIL()
Definition gtest.h:1754
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1868
#define EXPECT_PRED_FORMAT1(pred_format, v1)
Definition gtest_pred_impl.h:108
#define EXPECT_PRED3(pred, v1, v2, v3)
Definition gtest_pred_impl.h:184
#define EXPECT_PRED2(pred, v1, v2)
Definition gtest_pred_impl.h:145
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
Definition gtest_pred_impl.h:227
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
Definition gtest_pred_impl.h:223
#define ASSERT_PRED_FORMAT1(pred_format, v1)
Definition gtest_pred_impl.h:111
#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3)
Definition gtest_pred_impl.h:186
#define ASSERT_PRED2(pred, v1, v2)
Definition gtest_pred_impl.h:149
#define EXPECT_PRED4(pred, v1, v2, v3, v4)
Definition gtest_pred_impl.h:225
#define EXPECT_PRED1(pred, v1)
Definition gtest_pred_impl.h:110
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3)
Definition gtest_pred_impl.h:182
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:268
#define ASSERT_PRED1(pred, v1)
Definition gtest_pred_impl.h:113
#define ASSERT_PRED3(pred, v1, v2, v3)
Definition gtest_pred_impl.h:188
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:272
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2)
Definition gtest_pred_impl.h:147
#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:270
#define ASSERT_PRED4(pred, v1, v2, v3, v4)
Definition gtest_pred_impl.h:229
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
Definition gtest_pred_impl.h:143
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5)
Definition gtest_pred_impl.h:274
Predicate4Test ASSERT_PRED4Test
Definition gtest_pred_impl_unittest.cc:1331
testing::AssertionResult PredFormatFunction5(const char *e1, const char *e2, const char *e3, const char *e4, const char *e5, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
Definition gtest_pred_impl_unittest.cc:1672
bool PredFunction1Int(int v1)
Definition gtest_pred_impl_unittest.cc:81
bool PredFunction4Int(int v1, int v2, int v3, int v4)
Definition gtest_pred_impl_unittest.cc:1238
Predicate1Test ASSERT_PRED1Test
Definition gtest_pred_impl_unittest.cc:150
Predicate3Test EXPECT_PRED3Test
Definition gtest_pred_impl_unittest.cc:922
Predicate2Test ASSERT_PRED2Test
Definition gtest_pred_impl_unittest.cc:533
bool PredFunction1Bool(Bool v1)
Definition gtest_pred_impl_unittest.cc:82
Predicate2Test EXPECT_PRED2Test
Definition gtest_pred_impl_unittest.cc:532
Predicate4Test EXPECT_PRED_FORMAT4Test
Definition gtest_pred_impl_unittest.cc:1328
bool PredFunction3Int(int v1, int v2, int v3)
Definition gtest_pred_impl_unittest.cc:840
Predicate3Test EXPECT_PRED_FORMAT3Test
Definition gtest_pred_impl_unittest.cc:920
Predicate1Test EXPECT_PRED_FORMAT1Test
Definition gtest_pred_impl_unittest.cc:147
bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4)
Definition gtest_pred_impl_unittest.cc:1241
std::ostream & operator<<(std::ostream &os, const Bool &x)
Definition gtest_pred_impl_unittest.cc:67
Predicate3Test ASSERT_PRED3Test
Definition gtest_pred_impl_unittest.cc:923
bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4)
Definition gtest_pred_impl_unittest.cc:1232
bool PredFunction2(T1 v1, T2 v2)
Definition gtest_pred_impl_unittest.cc:451
bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5)
Definition gtest_pred_impl_unittest.cc:1657
Predicate1Test ASSERT_PRED_FORMAT1Test
Definition gtest_pred_impl_unittest.cc:148
bool PredFunction3(T1 v1, T2 v2, T3 v3)
Definition gtest_pred_impl_unittest.cc:834
bool PredFunction2Int(int v1, int v2)
Definition gtest_pred_impl_unittest.cc:457
Predicate2Test EXPECT_PRED_FORMAT2Test
Definition gtest_pred_impl_unittest.cc:530
Predicate5Test ASSERT_PRED5Test
Definition gtest_pred_impl_unittest.cc:1754
Predicate2Test ASSERT_PRED_FORMAT2Test
Definition gtest_pred_impl_unittest.cc:531
Predicate5Test EXPECT_PRED5Test
Definition gtest_pred_impl_unittest.cc:1753
testing::AssertionResult PredFormatFunction4(const char *e1, const char *e2, const char *e3, const char *e4, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
Definition gtest_pred_impl_unittest.cc:1255
bool PredFunction1(T1 v1)
Definition gtest_pred_impl_unittest.cc:75
bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5)
Definition gtest_pred_impl_unittest.cc:1648
bool PredFunction2Bool(Bool v1, Bool v2)
Definition gtest_pred_impl_unittest.cc:458
Predicate4Test EXPECT_PRED4Test
Definition gtest_pred_impl_unittest.cc:1330
testing::AssertionResult PredFormatFunction3(const char *e1, const char *e2, const char *e3, const T1 &v1, const T2 &v2, const T3 &v3)
Definition gtest_pred_impl_unittest.cc:853
Predicate4Test ASSERT_PRED_FORMAT4Test
Definition gtest_pred_impl_unittest.cc:1329
bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5)
Definition gtest_pred_impl_unittest.cc:1654
Predicate3Test ASSERT_PRED_FORMAT3Test
Definition gtest_pred_impl_unittest.cc:921
testing::AssertionResult PredFormatFunction2(const char *e1, const char *e2, const T1 &v1, const T2 &v2)
Definition gtest_pred_impl_unittest.cc:470
Predicate5Test ASSERT_PRED_FORMAT5Test
Definition gtest_pred_impl_unittest.cc:1752
Predicate1Test EXPECT_PRED1Test
Definition gtest_pred_impl_unittest.cc:149
Predicate5Test EXPECT_PRED_FORMAT5Test
Definition gtest_pred_impl_unittest.cc:1751
testing::AssertionResult PredFormatFunction1(const char *e1, const T1 &v1)
Definition gtest_pred_impl_unittest.cc:94
bool PredFunction3Bool(Bool v1, Bool v2, Bool v3)
Definition gtest_pred_impl_unittest.cc:841
AssertionResult AssertionFailure()
Definition gtest-assertion-result.cc:69
AssertionResult AssertionSuccess()
Definition gtest-assertion-result.cc:66
Definition gtest_pred_impl_unittest.cc:54
Bool(int val)
Definition gtest_pred_impl_unittest.cc:55
bool value
Definition gtest_pred_impl_unittest.cc:63
Bool operator+(const Bool &rhs) const
Definition gtest_pred_impl_unittest.cc:59
bool operator>(int n) const
Definition gtest_pred_impl_unittest.cc:57
bool operator==(const Bool &rhs) const
Definition gtest_pred_impl_unittest.cc:61
Definition gtest_pred_impl_unittest.cc:102
testing::AssertionResult operator()(const char *e1, const T1 &v1) const
Definition gtest_pred_impl_unittest.cc:104
Definition gtest_pred_impl_unittest.cc:480
testing::AssertionResult operator()(const char *e1, const char *e2, const T1 &v1, const T2 &v2) const
Definition gtest_pred_impl_unittest.cc:482
Definition gtest_pred_impl_unittest.cc:865
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const T1 &v1, const T2 &v2, const T3 &v3) const
Definition gtest_pred_impl_unittest.cc:867
Definition gtest_pred_impl_unittest.cc:1268
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const char *e4, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) const
Definition gtest_pred_impl_unittest.cc:1270
Definition gtest_pred_impl_unittest.cc:1686
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const char *e4, const char *e5, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5) const
Definition gtest_pred_impl_unittest.cc:1688
Definition gtest_pred_impl_unittest.cc:85
bool operator()(const T1 &v1)
Definition gtest_pred_impl_unittest.cc:87
Definition gtest_pred_impl_unittest.cc:461
bool operator()(const T1 &v1, const T2 &v2)
Definition gtest_pred_impl_unittest.cc:463
Definition gtest_pred_impl_unittest.cc:844
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3)
Definition gtest_pred_impl_unittest.cc:846
Definition gtest_pred_impl_unittest.cc:1246
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
Definition gtest_pred_impl_unittest.cc:1248
Definition gtest_pred_impl_unittest.cc:1662
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
Definition gtest_pred_impl_unittest.cc:1664