1 // Copyright 2006, Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
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
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.
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.
30 // Regression test for gtest_pred_impl.h
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.
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
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.
49 #include "gtest/gtest-spi.h"
50 #include "gtest/gtest.h"
52 // A user-defined data type.
54 explicit Bool(int val) : value(val != 0) {}
56 bool operator>(int n) const { return value > Bool(n).value; }
58 Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
60 bool operator==(const Bool& rhs) const { return value == rhs.value; }
65 // Enables Bool to be used in assertions.
66 std::ostream& operator<<(std::ostream& os, const Bool& x) {
67 return os << (x.value ? "true" : "false");
70 // Sample functions/functors for testing unary predicate assertions.
72 // A unary predicate function.
73 template <typename T1>
74 bool PredFunction1(T1 v1) {
78 // The following two functions are needed because a compiler doesn't have
79 // a context yet to know which template function must be instantiated.
80 bool PredFunction1Int(int v1) { return v1 > 0; }
81 bool PredFunction1Bool(Bool v1) { return v1 > 0; }
83 // A unary predicate functor.
85 template <typename T1>
86 bool operator()(const T1& v1) {
91 // A unary predicate-formatter function.
92 template <typename T1>
93 testing::AssertionResult PredFormatFunction1(const char* e1, const T1& v1) {
94 if (PredFunction1(v1)) return testing::AssertionSuccess();
96 return testing::AssertionFailure()
97 << e1 << " is expected to be positive, but evaluates to " << v1 << ".";
100 // A unary predicate-formatter functor.
101 struct PredFormatFunctor1 {
102 template <typename T1>
103 testing::AssertionResult operator()(const char* e1, const T1& v1) const {
104 return PredFormatFunction1(e1, v1);
108 // Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
110 class Predicate1Test : public testing::Test {
112 void SetUp() override {
113 expected_to_finish_ = true;
118 void TearDown() override {
119 // Verifies that each of the predicate's arguments was evaluated
121 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
124 // Verifies that the control flow in the test function is expected.
125 if (expected_to_finish_ && !finished_) {
126 FAIL() << "The predicate assertion unexpectedly aborted the test.";
127 } else if (!expected_to_finish_ && finished_) {
128 FAIL() << "The failed predicate assertion didn't abort the test "
133 // true if and only if the test function is expected to run to finish.
134 static bool expected_to_finish_;
136 // true if and only if the test function did run to finish.
137 static bool finished_;
142 bool Predicate1Test::expected_to_finish_;
143 bool Predicate1Test::finished_;
144 int Predicate1Test::n1_;
146 typedef Predicate1Test EXPECT_PRED_FORMAT1Test;
147 typedef Predicate1Test ASSERT_PRED_FORMAT1Test;
148 typedef Predicate1Test EXPECT_PRED1Test;
149 typedef Predicate1Test ASSERT_PRED1Test;
151 // Tests a successful EXPECT_PRED1 where the
152 // predicate-formatter is a function on a built-in type (int).
153 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
154 EXPECT_PRED1(PredFunction1Int, ++n1_);
158 // Tests a successful EXPECT_PRED1 where the
159 // predicate-formatter is a function on a user-defined type (Bool).
160 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
161 EXPECT_PRED1(PredFunction1Bool, Bool(++n1_));
165 // Tests a successful EXPECT_PRED1 where the
166 // predicate-formatter is a functor on a built-in type (int).
167 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
168 EXPECT_PRED1(PredFunctor1(), ++n1_);
172 // Tests a successful EXPECT_PRED1 where the
173 // predicate-formatter is a functor on a user-defined type (Bool).
174 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
175 EXPECT_PRED1(PredFunctor1(), Bool(++n1_));
179 // Tests a failed EXPECT_PRED1 where the
180 // predicate-formatter is a function on a built-in type (int).
181 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
182 EXPECT_NONFATAL_FAILURE(
184 EXPECT_PRED1(PredFunction1Int, n1_++);
190 // Tests a failed EXPECT_PRED1 where the
191 // predicate-formatter is a function on a user-defined type (Bool).
192 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
193 EXPECT_NONFATAL_FAILURE(
195 EXPECT_PRED1(PredFunction1Bool, Bool(n1_++));
201 // Tests a failed EXPECT_PRED1 where the
202 // predicate-formatter is a functor on a built-in type (int).
203 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
204 EXPECT_NONFATAL_FAILURE(
206 EXPECT_PRED1(PredFunctor1(), n1_++);
212 // Tests a failed EXPECT_PRED1 where the
213 // predicate-formatter is a functor on a user-defined type (Bool).
214 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
215 EXPECT_NONFATAL_FAILURE(
217 EXPECT_PRED1(PredFunctor1(), Bool(n1_++));
223 // Tests a successful ASSERT_PRED1 where the
224 // predicate-formatter is a function on a built-in type (int).
225 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
226 ASSERT_PRED1(PredFunction1Int, ++n1_);
230 // Tests a successful ASSERT_PRED1 where the
231 // predicate-formatter is a function on a user-defined type (Bool).
232 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
233 ASSERT_PRED1(PredFunction1Bool, Bool(++n1_));
237 // Tests a successful ASSERT_PRED1 where the
238 // predicate-formatter is a functor on a built-in type (int).
239 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
240 ASSERT_PRED1(PredFunctor1(), ++n1_);
244 // Tests a successful ASSERT_PRED1 where the
245 // predicate-formatter is a functor on a user-defined type (Bool).
246 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
247 ASSERT_PRED1(PredFunctor1(), Bool(++n1_));
251 // Tests a failed ASSERT_PRED1 where the
252 // predicate-formatter is a function on a built-in type (int).
253 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
254 expected_to_finish_ = false;
255 EXPECT_FATAL_FAILURE(
257 ASSERT_PRED1(PredFunction1Int, n1_++);
263 // Tests a failed ASSERT_PRED1 where the
264 // predicate-formatter is a function on a user-defined type (Bool).
265 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
266 expected_to_finish_ = false;
267 EXPECT_FATAL_FAILURE(
269 ASSERT_PRED1(PredFunction1Bool, Bool(n1_++));
275 // Tests a failed ASSERT_PRED1 where the
276 // predicate-formatter is a functor on a built-in type (int).
277 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
278 expected_to_finish_ = false;
279 EXPECT_FATAL_FAILURE(
281 ASSERT_PRED1(PredFunctor1(), n1_++);
287 // Tests a failed ASSERT_PRED1 where the
288 // predicate-formatter is a functor on a user-defined type (Bool).
289 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
290 expected_to_finish_ = false;
291 EXPECT_FATAL_FAILURE(
293 ASSERT_PRED1(PredFunctor1(), Bool(n1_++));
299 // Tests a successful EXPECT_PRED_FORMAT1 where the
300 // predicate-formatter is a function on a built-in type (int).
301 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
302 EXPECT_PRED_FORMAT1(PredFormatFunction1, ++n1_);
306 // Tests a successful EXPECT_PRED_FORMAT1 where the
307 // predicate-formatter is a function on a user-defined type (Bool).
308 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
309 EXPECT_PRED_FORMAT1(PredFormatFunction1, Bool(++n1_));
313 // Tests a successful EXPECT_PRED_FORMAT1 where the
314 // predicate-formatter is a functor on a built-in type (int).
315 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
316 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), ++n1_);
320 // Tests a successful EXPECT_PRED_FORMAT1 where the
321 // predicate-formatter is a functor on a user-defined type (Bool).
322 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
323 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), Bool(++n1_));
327 // Tests a failed EXPECT_PRED_FORMAT1 where the
328 // predicate-formatter is a function on a built-in type (int).
329 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
330 EXPECT_NONFATAL_FAILURE(
332 EXPECT_PRED_FORMAT1(PredFormatFunction1, n1_++);
338 // Tests a failed EXPECT_PRED_FORMAT1 where the
339 // predicate-formatter is a function on a user-defined type (Bool).
340 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
341 EXPECT_NONFATAL_FAILURE(
343 EXPECT_PRED_FORMAT1(PredFormatFunction1, Bool(n1_++));
349 // Tests a failed EXPECT_PRED_FORMAT1 where the
350 // predicate-formatter is a functor on a built-in type (int).
351 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
352 EXPECT_NONFATAL_FAILURE(
354 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), n1_++);
360 // Tests a failed EXPECT_PRED_FORMAT1 where the
361 // predicate-formatter is a functor on a user-defined type (Bool).
362 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
363 EXPECT_NONFATAL_FAILURE(
365 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), Bool(n1_++));
371 // Tests a successful ASSERT_PRED_FORMAT1 where the
372 // predicate-formatter is a function on a built-in type (int).
373 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
374 ASSERT_PRED_FORMAT1(PredFormatFunction1, ++n1_);
378 // Tests a successful ASSERT_PRED_FORMAT1 where the
379 // predicate-formatter is a function on a user-defined type (Bool).
380 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
381 ASSERT_PRED_FORMAT1(PredFormatFunction1, Bool(++n1_));
385 // Tests a successful ASSERT_PRED_FORMAT1 where the
386 // predicate-formatter is a functor on a built-in type (int).
387 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
388 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), ++n1_);
392 // Tests a successful ASSERT_PRED_FORMAT1 where the
393 // predicate-formatter is a functor on a user-defined type (Bool).
394 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
395 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), Bool(++n1_));
399 // Tests a failed ASSERT_PRED_FORMAT1 where the
400 // predicate-formatter is a function on a built-in type (int).
401 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
402 expected_to_finish_ = false;
403 EXPECT_FATAL_FAILURE(
405 ASSERT_PRED_FORMAT1(PredFormatFunction1, n1_++);
411 // Tests a failed ASSERT_PRED_FORMAT1 where the
412 // predicate-formatter is a function on a user-defined type (Bool).
413 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
414 expected_to_finish_ = false;
415 EXPECT_FATAL_FAILURE(
417 ASSERT_PRED_FORMAT1(PredFormatFunction1, Bool(n1_++));
423 // Tests a failed ASSERT_PRED_FORMAT1 where the
424 // predicate-formatter is a functor on a built-in type (int).
425 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
426 expected_to_finish_ = false;
427 EXPECT_FATAL_FAILURE(
429 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), n1_++);
435 // Tests a failed ASSERT_PRED_FORMAT1 where the
436 // predicate-formatter is a functor on a user-defined type (Bool).
437 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
438 expected_to_finish_ = false;
439 EXPECT_FATAL_FAILURE(
441 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), Bool(n1_++));
446 // Sample functions/functors for testing binary predicate assertions.
448 // A binary predicate function.
449 template <typename T1, typename T2>
450 bool PredFunction2(T1 v1, T2 v2) {
454 // The following two functions are needed because a compiler doesn't have
455 // a context yet to know which template function must be instantiated.
456 bool PredFunction2Int(int v1, int v2) { return v1 + v2 > 0; }
457 bool PredFunction2Bool(Bool v1, Bool v2) { return v1 + v2 > 0; }
459 // A binary predicate functor.
460 struct PredFunctor2 {
461 template <typename T1, typename T2>
462 bool operator()(const T1& v1, const T2& v2) {
467 // A binary predicate-formatter function.
468 template <typename T1, typename T2>
469 testing::AssertionResult PredFormatFunction2(const char* e1, const char* e2,
470 const T1& v1, const T2& v2) {
471 if (PredFunction2(v1, v2)) return testing::AssertionSuccess();
473 return testing::AssertionFailure()
475 << " is expected to be positive, but evaluates to " << v1 + v2 << ".";
478 // A binary predicate-formatter functor.
479 struct PredFormatFunctor2 {
480 template <typename T1, typename T2>
481 testing::AssertionResult operator()(const char* e1, const char* e2,
482 const T1& v1, const T2& v2) const {
483 return PredFormatFunction2(e1, e2, v1, v2);
487 // Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
489 class Predicate2Test : public testing::Test {
491 void SetUp() override {
492 expected_to_finish_ = true;
497 void TearDown() override {
498 // Verifies that each of the predicate's arguments was evaluated
500 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
502 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
505 // Verifies that the control flow in the test function is expected.
506 if (expected_to_finish_ && !finished_) {
507 FAIL() << "The predicate assertion unexpectedly aborted the test.";
508 } else if (!expected_to_finish_ && finished_) {
509 FAIL() << "The failed predicate assertion didn't abort the test "
514 // true if and only if the test function is expected to run to finish.
515 static bool expected_to_finish_;
517 // true if and only if the test function did run to finish.
518 static bool finished_;
524 bool Predicate2Test::expected_to_finish_;
525 bool Predicate2Test::finished_;
526 int Predicate2Test::n1_;
527 int Predicate2Test::n2_;
529 typedef Predicate2Test EXPECT_PRED_FORMAT2Test;
530 typedef Predicate2Test ASSERT_PRED_FORMAT2Test;
531 typedef Predicate2Test EXPECT_PRED2Test;
532 typedef Predicate2Test ASSERT_PRED2Test;
534 // Tests a successful EXPECT_PRED2 where the
535 // predicate-formatter is a function on a built-in type (int).
536 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
537 EXPECT_PRED2(PredFunction2Int, ++n1_, ++n2_);
541 // Tests a successful EXPECT_PRED2 where the
542 // predicate-formatter is a function on a user-defined type (Bool).
543 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
544 EXPECT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
548 // Tests a successful EXPECT_PRED2 where the
549 // predicate-formatter is a functor on a built-in type (int).
550 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
551 EXPECT_PRED2(PredFunctor2(), ++n1_, ++n2_);
555 // Tests a successful EXPECT_PRED2 where the
556 // predicate-formatter is a functor on a user-defined type (Bool).
557 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
558 EXPECT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
562 // Tests a failed EXPECT_PRED2 where the
563 // predicate-formatter is a function on a built-in type (int).
564 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
565 EXPECT_NONFATAL_FAILURE(
567 EXPECT_PRED2(PredFunction2Int, n1_++, n2_++);
573 // Tests a failed EXPECT_PRED2 where the
574 // predicate-formatter is a function on a user-defined type (Bool).
575 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
576 EXPECT_NONFATAL_FAILURE(
578 EXPECT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
584 // Tests a failed EXPECT_PRED2 where the
585 // predicate-formatter is a functor on a built-in type (int).
586 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
587 EXPECT_NONFATAL_FAILURE(
589 EXPECT_PRED2(PredFunctor2(), n1_++, n2_++);
595 // Tests a failed EXPECT_PRED2 where the
596 // predicate-formatter is a functor on a user-defined type (Bool).
597 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
598 EXPECT_NONFATAL_FAILURE(
600 EXPECT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
606 // Tests a successful ASSERT_PRED2 where the
607 // predicate-formatter is a function on a built-in type (int).
608 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
609 ASSERT_PRED2(PredFunction2Int, ++n1_, ++n2_);
613 // Tests a successful ASSERT_PRED2 where the
614 // predicate-formatter is a function on a user-defined type (Bool).
615 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
616 ASSERT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
620 // Tests a successful ASSERT_PRED2 where the
621 // predicate-formatter is a functor on a built-in type (int).
622 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
623 ASSERT_PRED2(PredFunctor2(), ++n1_, ++n2_);
627 // Tests a successful ASSERT_PRED2 where the
628 // predicate-formatter is a functor on a user-defined type (Bool).
629 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
630 ASSERT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
634 // Tests a failed ASSERT_PRED2 where the
635 // predicate-formatter is a function on a built-in type (int).
636 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
637 expected_to_finish_ = false;
638 EXPECT_FATAL_FAILURE(
640 ASSERT_PRED2(PredFunction2Int, n1_++, n2_++);
646 // Tests a failed ASSERT_PRED2 where the
647 // predicate-formatter is a function on a user-defined type (Bool).
648 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
649 expected_to_finish_ = false;
650 EXPECT_FATAL_FAILURE(
652 ASSERT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
658 // Tests a failed ASSERT_PRED2 where the
659 // predicate-formatter is a functor on a built-in type (int).
660 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
661 expected_to_finish_ = false;
662 EXPECT_FATAL_FAILURE(
664 ASSERT_PRED2(PredFunctor2(), n1_++, n2_++);
670 // Tests a failed ASSERT_PRED2 where the
671 // predicate-formatter is a functor on a user-defined type (Bool).
672 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
673 expected_to_finish_ = false;
674 EXPECT_FATAL_FAILURE(
676 ASSERT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
682 // Tests a successful EXPECT_PRED_FORMAT2 where the
683 // predicate-formatter is a function on a built-in type (int).
684 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
685 EXPECT_PRED_FORMAT2(PredFormatFunction2, ++n1_, ++n2_);
689 // Tests a successful EXPECT_PRED_FORMAT2 where the
690 // predicate-formatter is a function on a user-defined type (Bool).
691 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
692 EXPECT_PRED_FORMAT2(PredFormatFunction2, Bool(++n1_), Bool(++n2_));
696 // Tests a successful EXPECT_PRED_FORMAT2 where the
697 // predicate-formatter is a functor on a built-in type (int).
698 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
699 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), ++n1_, ++n2_);
703 // Tests a successful EXPECT_PRED_FORMAT2 where the
704 // predicate-formatter is a functor on a user-defined type (Bool).
705 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
706 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), Bool(++n1_), Bool(++n2_));
710 // Tests a failed EXPECT_PRED_FORMAT2 where the
711 // predicate-formatter is a function on a built-in type (int).
712 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
713 EXPECT_NONFATAL_FAILURE(
715 EXPECT_PRED_FORMAT2(PredFormatFunction2, n1_++, n2_++);
721 // Tests a failed EXPECT_PRED_FORMAT2 where the
722 // predicate-formatter is a function on a user-defined type (Bool).
723 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
724 EXPECT_NONFATAL_FAILURE(
726 EXPECT_PRED_FORMAT2(PredFormatFunction2, Bool(n1_++), Bool(n2_++));
732 // Tests a failed EXPECT_PRED_FORMAT2 where the
733 // predicate-formatter is a functor on a built-in type (int).
734 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
735 EXPECT_NONFATAL_FAILURE(
737 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), n1_++, n2_++);
743 // Tests a failed EXPECT_PRED_FORMAT2 where the
744 // predicate-formatter is a functor on a user-defined type (Bool).
745 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
746 EXPECT_NONFATAL_FAILURE(
748 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), Bool(n1_++), Bool(n2_++));
754 // Tests a successful ASSERT_PRED_FORMAT2 where the
755 // predicate-formatter is a function on a built-in type (int).
756 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
757 ASSERT_PRED_FORMAT2(PredFormatFunction2, ++n1_, ++n2_);
761 // Tests a successful ASSERT_PRED_FORMAT2 where the
762 // predicate-formatter is a function on a user-defined type (Bool).
763 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
764 ASSERT_PRED_FORMAT2(PredFormatFunction2, Bool(++n1_), Bool(++n2_));
768 // Tests a successful ASSERT_PRED_FORMAT2 where the
769 // predicate-formatter is a functor on a built-in type (int).
770 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
771 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), ++n1_, ++n2_);
775 // Tests a successful ASSERT_PRED_FORMAT2 where the
776 // predicate-formatter is a functor on a user-defined type (Bool).
777 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
778 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), Bool(++n1_), Bool(++n2_));
782 // Tests a failed ASSERT_PRED_FORMAT2 where the
783 // predicate-formatter is a function on a built-in type (int).
784 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
785 expected_to_finish_ = false;
786 EXPECT_FATAL_FAILURE(
788 ASSERT_PRED_FORMAT2(PredFormatFunction2, n1_++, n2_++);
794 // Tests a failed ASSERT_PRED_FORMAT2 where the
795 // predicate-formatter is a function on a user-defined type (Bool).
796 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
797 expected_to_finish_ = false;
798 EXPECT_FATAL_FAILURE(
800 ASSERT_PRED_FORMAT2(PredFormatFunction2, Bool(n1_++), Bool(n2_++));
806 // Tests a failed ASSERT_PRED_FORMAT2 where the
807 // predicate-formatter is a functor on a built-in type (int).
808 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
809 expected_to_finish_ = false;
810 EXPECT_FATAL_FAILURE(
812 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), n1_++, n2_++);
818 // Tests a failed ASSERT_PRED_FORMAT2 where the
819 // predicate-formatter is a functor on a user-defined type (Bool).
820 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
821 expected_to_finish_ = false;
822 EXPECT_FATAL_FAILURE(
824 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), Bool(n1_++), Bool(n2_++));
829 // Sample functions/functors for testing ternary predicate assertions.
831 // A ternary predicate function.
832 template <typename T1, typename T2, typename T3>
833 bool PredFunction3(T1 v1, T2 v2, T3 v3) {
834 return v1 + v2 + v3 > 0;
837 // The following two functions are needed because a compiler doesn't have
838 // a context yet to know which template function must be instantiated.
839 bool PredFunction3Int(int v1, int v2, int v3) { return v1 + v2 + v3 > 0; }
840 bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) { return v1 + v2 + v3 > 0; }
842 // A ternary predicate functor.
843 struct PredFunctor3 {
844 template <typename T1, typename T2, typename T3>
845 bool operator()(const T1& v1, const T2& v2, const T3& v3) {
846 return v1 + v2 + v3 > 0;
850 // A ternary predicate-formatter function.
851 template <typename T1, typename T2, typename T3>
852 testing::AssertionResult PredFormatFunction3(const char* e1, const char* e2,
853 const char* e3, const T1& v1,
854 const T2& v2, const T3& v3) {
855 if (PredFunction3(v1, v2, v3)) return testing::AssertionSuccess();
857 return testing::AssertionFailure()
858 << e1 << " + " << e2 << " + " << e3
859 << " is expected to be positive, but evaluates to " << v1 + v2 + v3
863 // A ternary predicate-formatter functor.
864 struct PredFormatFunctor3 {
865 template <typename T1, typename T2, typename T3>
866 testing::AssertionResult operator()(const char* e1, const char* e2,
867 const char* e3, const T1& v1,
868 const T2& v2, const T3& v3) const {
869 return PredFormatFunction3(e1, e2, e3, v1, v2, v3);
873 // Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
875 class Predicate3Test : public testing::Test {
877 void SetUp() override {
878 expected_to_finish_ = true;
883 void TearDown() override {
884 // Verifies that each of the predicate's arguments was evaluated
886 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
888 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
890 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
893 // Verifies that the control flow in the test function is expected.
894 if (expected_to_finish_ && !finished_) {
895 FAIL() << "The predicate assertion unexpectedly aborted the test.";
896 } else if (!expected_to_finish_ && finished_) {
897 FAIL() << "The failed predicate assertion didn't abort the test "
902 // true if and only if the test function is expected to run to finish.
903 static bool expected_to_finish_;
905 // true if and only if the test function did run to finish.
906 static bool finished_;
913 bool Predicate3Test::expected_to_finish_;
914 bool Predicate3Test::finished_;
915 int Predicate3Test::n1_;
916 int Predicate3Test::n2_;
917 int Predicate3Test::n3_;
919 typedef Predicate3Test EXPECT_PRED_FORMAT3Test;
920 typedef Predicate3Test ASSERT_PRED_FORMAT3Test;
921 typedef Predicate3Test EXPECT_PRED3Test;
922 typedef Predicate3Test ASSERT_PRED3Test;
924 // Tests a successful EXPECT_PRED3 where the
925 // predicate-formatter is a function on a built-in type (int).
926 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
927 EXPECT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
931 // Tests a successful EXPECT_PRED3 where the
932 // predicate-formatter is a function on a user-defined type (Bool).
933 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
934 EXPECT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
938 // Tests a successful EXPECT_PRED3 where the
939 // predicate-formatter is a functor on a built-in type (int).
940 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
941 EXPECT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
945 // Tests a successful EXPECT_PRED3 where the
946 // predicate-formatter is a functor on a user-defined type (Bool).
947 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
948 EXPECT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
952 // Tests a failed EXPECT_PRED3 where the
953 // predicate-formatter is a function on a built-in type (int).
954 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
955 EXPECT_NONFATAL_FAILURE(
957 EXPECT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
963 // Tests a failed EXPECT_PRED3 where the
964 // predicate-formatter is a function on a user-defined type (Bool).
965 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
966 EXPECT_NONFATAL_FAILURE(
968 EXPECT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
974 // Tests a failed EXPECT_PRED3 where the
975 // predicate-formatter is a functor on a built-in type (int).
976 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
977 EXPECT_NONFATAL_FAILURE(
979 EXPECT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
985 // Tests a failed EXPECT_PRED3 where the
986 // predicate-formatter is a functor on a user-defined type (Bool).
987 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
988 EXPECT_NONFATAL_FAILURE(
990 EXPECT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
996 // Tests a successful ASSERT_PRED3 where the
997 // predicate-formatter is a function on a built-in type (int).
998 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
999 ASSERT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
1003 // Tests a successful ASSERT_PRED3 where the
1004 // predicate-formatter is a function on a user-defined type (Bool).
1005 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
1006 ASSERT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
1010 // Tests a successful ASSERT_PRED3 where the
1011 // predicate-formatter is a functor on a built-in type (int).
1012 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
1013 ASSERT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
1017 // Tests a successful ASSERT_PRED3 where the
1018 // predicate-formatter is a functor on a user-defined type (Bool).
1019 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
1020 ASSERT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
1024 // Tests a failed ASSERT_PRED3 where the
1025 // predicate-formatter is a function on a built-in type (int).
1026 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
1027 expected_to_finish_ = false;
1028 EXPECT_FATAL_FAILURE(
1030 ASSERT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
1036 // Tests a failed ASSERT_PRED3 where the
1037 // predicate-formatter is a function on a user-defined type (Bool).
1038 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
1039 expected_to_finish_ = false;
1040 EXPECT_FATAL_FAILURE(
1042 ASSERT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
1048 // Tests a failed ASSERT_PRED3 where the
1049 // predicate-formatter is a functor on a built-in type (int).
1050 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
1051 expected_to_finish_ = false;
1052 EXPECT_FATAL_FAILURE(
1054 ASSERT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
1060 // Tests a failed ASSERT_PRED3 where the
1061 // predicate-formatter is a functor on a user-defined type (Bool).
1062 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
1063 expected_to_finish_ = false;
1064 EXPECT_FATAL_FAILURE(
1066 ASSERT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
1072 // Tests a successful EXPECT_PRED_FORMAT3 where the
1073 // predicate-formatter is a function on a built-in type (int).
1074 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1075 EXPECT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1079 // Tests a successful EXPECT_PRED_FORMAT3 where the
1080 // predicate-formatter is a function on a user-defined type (Bool).
1081 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1082 EXPECT_PRED_FORMAT3(PredFormatFunction3, Bool(++n1_), Bool(++n2_),
1087 // Tests a successful EXPECT_PRED_FORMAT3 where the
1088 // predicate-formatter is a functor on a built-in type (int).
1089 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1090 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1094 // Tests a successful EXPECT_PRED_FORMAT3 where the
1095 // predicate-formatter is a functor on a user-defined type (Bool).
1096 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1097 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), Bool(++n1_), Bool(++n2_),
1102 // Tests a failed EXPECT_PRED_FORMAT3 where the
1103 // predicate-formatter is a function on a built-in type (int).
1104 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1105 EXPECT_NONFATAL_FAILURE(
1107 EXPECT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1113 // Tests a failed EXPECT_PRED_FORMAT3 where the
1114 // predicate-formatter is a function on a user-defined type (Bool).
1115 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1116 EXPECT_NONFATAL_FAILURE(
1118 EXPECT_PRED_FORMAT3(PredFormatFunction3, Bool(n1_++), Bool(n2_++),
1125 // Tests a failed EXPECT_PRED_FORMAT3 where the
1126 // predicate-formatter is a functor on a built-in type (int).
1127 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1128 EXPECT_NONFATAL_FAILURE(
1130 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1136 // Tests a failed EXPECT_PRED_FORMAT3 where the
1137 // predicate-formatter is a functor on a user-defined type (Bool).
1138 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1139 EXPECT_NONFATAL_FAILURE(
1141 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), Bool(n1_++), Bool(n2_++),
1148 // Tests a successful ASSERT_PRED_FORMAT3 where the
1149 // predicate-formatter is a function on a built-in type (int).
1150 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1151 ASSERT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1155 // Tests a successful ASSERT_PRED_FORMAT3 where the
1156 // predicate-formatter is a function on a user-defined type (Bool).
1157 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1158 ASSERT_PRED_FORMAT3(PredFormatFunction3, Bool(++n1_), Bool(++n2_),
1163 // Tests a successful ASSERT_PRED_FORMAT3 where the
1164 // predicate-formatter is a functor on a built-in type (int).
1165 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1166 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1170 // Tests a successful ASSERT_PRED_FORMAT3 where the
1171 // predicate-formatter is a functor on a user-defined type (Bool).
1172 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1173 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), Bool(++n1_), Bool(++n2_),
1178 // Tests a failed ASSERT_PRED_FORMAT3 where the
1179 // predicate-formatter is a function on a built-in type (int).
1180 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1181 expected_to_finish_ = false;
1182 EXPECT_FATAL_FAILURE(
1184 ASSERT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1190 // Tests a failed ASSERT_PRED_FORMAT3 where the
1191 // predicate-formatter is a function on a user-defined type (Bool).
1192 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1193 expected_to_finish_ = false;
1194 EXPECT_FATAL_FAILURE(
1196 ASSERT_PRED_FORMAT3(PredFormatFunction3, Bool(n1_++), Bool(n2_++),
1203 // Tests a failed ASSERT_PRED_FORMAT3 where the
1204 // predicate-formatter is a functor on a built-in type (int).
1205 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1206 expected_to_finish_ = false;
1207 EXPECT_FATAL_FAILURE(
1209 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1215 // Tests a failed ASSERT_PRED_FORMAT3 where the
1216 // predicate-formatter is a functor on a user-defined type (Bool).
1217 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1218 expected_to_finish_ = false;
1219 EXPECT_FATAL_FAILURE(
1221 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), Bool(n1_++), Bool(n2_++),
1227 // Sample functions/functors for testing 4-ary predicate assertions.
1229 // A 4-ary predicate function.
1230 template <typename T1, typename T2, typename T3, typename T4>
1231 bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
1232 return v1 + v2 + v3 + v4 > 0;
1235 // The following two functions are needed because a compiler doesn't have
1236 // a context yet to know which template function must be instantiated.
1237 bool PredFunction4Int(int v1, int v2, int v3, int v4) {
1238 return v1 + v2 + v3 + v4 > 0;
1240 bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
1241 return v1 + v2 + v3 + v4 > 0;
1244 // A 4-ary predicate functor.
1245 struct PredFunctor4 {
1246 template <typename T1, typename T2, typename T3, typename T4>
1247 bool operator()(const T1& v1, const T2& v2, const T3& v3, const T4& v4) {
1248 return v1 + v2 + v3 + v4 > 0;
1252 // A 4-ary predicate-formatter function.
1253 template <typename T1, typename T2, typename T3, typename T4>
1254 testing::AssertionResult PredFormatFunction4(const char* e1, const char* e2,
1255 const char* e3, const char* e4,
1256 const T1& v1, const T2& v2,
1257 const T3& v3, const T4& v4) {
1258 if (PredFunction4(v1, v2, v3, v4)) return testing::AssertionSuccess();
1260 return testing::AssertionFailure()
1261 << e1 << " + " << e2 << " + " << e3 << " + " << e4
1262 << " is expected to be positive, but evaluates to "
1263 << v1 + v2 + v3 + v4 << ".";
1266 // A 4-ary predicate-formatter functor.
1267 struct PredFormatFunctor4 {
1268 template <typename T1, typename T2, typename T3, typename T4>
1269 testing::AssertionResult operator()(const char* e1, const char* e2,
1270 const char* e3, const char* e4,
1271 const T1& v1, const T2& v2, const T3& v3,
1272 const T4& v4) const {
1273 return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);
1277 // Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
1279 class Predicate4Test : public testing::Test {
1281 void SetUp() override {
1282 expected_to_finish_ = true;
1284 n1_ = n2_ = n3_ = n4_ = 0;
1287 void TearDown() override {
1288 // Verifies that each of the predicate's arguments was evaluated
1290 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1292 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1294 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1296 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1299 // Verifies that the control flow in the test function is expected.
1300 if (expected_to_finish_ && !finished_) {
1301 FAIL() << "The predicate assertion unexpectedly aborted the test.";
1302 } else if (!expected_to_finish_ && finished_) {
1303 FAIL() << "The failed predicate assertion didn't abort the test "
1308 // true if and only if the test function is expected to run to finish.
1309 static bool expected_to_finish_;
1311 // true if and only if the test function did run to finish.
1312 static bool finished_;
1320 bool Predicate4Test::expected_to_finish_;
1321 bool Predicate4Test::finished_;
1322 int Predicate4Test::n1_;
1323 int Predicate4Test::n2_;
1324 int Predicate4Test::n3_;
1325 int Predicate4Test::n4_;
1327 typedef Predicate4Test EXPECT_PRED_FORMAT4Test;
1328 typedef Predicate4Test ASSERT_PRED_FORMAT4Test;
1329 typedef Predicate4Test EXPECT_PRED4Test;
1330 typedef Predicate4Test ASSERT_PRED4Test;
1332 // Tests a successful EXPECT_PRED4 where the
1333 // predicate-formatter is a function on a built-in type (int).
1334 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1335 EXPECT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1339 // Tests a successful EXPECT_PRED4 where the
1340 // predicate-formatter is a function on a user-defined type (Bool).
1341 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
1342 EXPECT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1347 // Tests a successful EXPECT_PRED4 where the
1348 // predicate-formatter is a functor on a built-in type (int).
1349 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1350 EXPECT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1354 // Tests a successful EXPECT_PRED4 where the
1355 // predicate-formatter is a functor on a user-defined type (Bool).
1356 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
1357 EXPECT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1362 // Tests a failed EXPECT_PRED4 where the
1363 // predicate-formatter is a function on a built-in type (int).
1364 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1365 EXPECT_NONFATAL_FAILURE(
1367 EXPECT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1373 // Tests a failed EXPECT_PRED4 where the
1374 // predicate-formatter is a function on a user-defined type (Bool).
1375 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
1376 EXPECT_NONFATAL_FAILURE(
1378 EXPECT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1385 // Tests a failed EXPECT_PRED4 where the
1386 // predicate-formatter is a functor on a built-in type (int).
1387 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1388 EXPECT_NONFATAL_FAILURE(
1390 EXPECT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1396 // Tests a failed EXPECT_PRED4 where the
1397 // predicate-formatter is a functor on a user-defined type (Bool).
1398 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
1399 EXPECT_NONFATAL_FAILURE(
1401 EXPECT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1408 // Tests a successful ASSERT_PRED4 where the
1409 // predicate-formatter is a function on a built-in type (int).
1410 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1411 ASSERT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1415 // Tests a successful ASSERT_PRED4 where the
1416 // predicate-formatter is a function on a user-defined type (Bool).
1417 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
1418 ASSERT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1423 // Tests a successful ASSERT_PRED4 where the
1424 // predicate-formatter is a functor on a built-in type (int).
1425 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1426 ASSERT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1430 // Tests a successful ASSERT_PRED4 where the
1431 // predicate-formatter is a functor on a user-defined type (Bool).
1432 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
1433 ASSERT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1438 // Tests a failed ASSERT_PRED4 where the
1439 // predicate-formatter is a function on a built-in type (int).
1440 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1441 expected_to_finish_ = false;
1442 EXPECT_FATAL_FAILURE(
1444 ASSERT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1450 // Tests a failed ASSERT_PRED4 where the
1451 // predicate-formatter is a function on a user-defined type (Bool).
1452 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
1453 expected_to_finish_ = false;
1454 EXPECT_FATAL_FAILURE(
1456 ASSERT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1463 // Tests a failed ASSERT_PRED4 where the
1464 // predicate-formatter is a functor on a built-in type (int).
1465 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1466 expected_to_finish_ = false;
1467 EXPECT_FATAL_FAILURE(
1469 ASSERT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1475 // Tests a failed ASSERT_PRED4 where the
1476 // predicate-formatter is a functor on a user-defined type (Bool).
1477 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
1478 expected_to_finish_ = false;
1479 EXPECT_FATAL_FAILURE(
1481 ASSERT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1488 // Tests a successful EXPECT_PRED_FORMAT4 where the
1489 // predicate-formatter is a function on a built-in type (int).
1490 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1491 EXPECT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1495 // Tests a successful EXPECT_PRED_FORMAT4 where the
1496 // predicate-formatter is a function on a user-defined type (Bool).
1497 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1498 EXPECT_PRED_FORMAT4(PredFormatFunction4, Bool(++n1_), Bool(++n2_),
1499 Bool(++n3_), Bool(++n4_));
1503 // Tests a successful EXPECT_PRED_FORMAT4 where the
1504 // predicate-formatter is a functor on a built-in type (int).
1505 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1506 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1510 // Tests a successful EXPECT_PRED_FORMAT4 where the
1511 // predicate-formatter is a functor on a user-defined type (Bool).
1512 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1513 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), Bool(++n1_), Bool(++n2_),
1514 Bool(++n3_), Bool(++n4_));
1518 // Tests a failed EXPECT_PRED_FORMAT4 where the
1519 // predicate-formatter is a function on a built-in type (int).
1520 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1521 EXPECT_NONFATAL_FAILURE(
1523 EXPECT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1529 // Tests a failed EXPECT_PRED_FORMAT4 where the
1530 // predicate-formatter is a function on a user-defined type (Bool).
1531 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1532 EXPECT_NONFATAL_FAILURE(
1534 EXPECT_PRED_FORMAT4(PredFormatFunction4, Bool(n1_++), Bool(n2_++),
1535 Bool(n3_++), Bool(n4_++));
1541 // Tests a failed EXPECT_PRED_FORMAT4 where the
1542 // predicate-formatter is a functor on a built-in type (int).
1543 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1544 EXPECT_NONFATAL_FAILURE(
1546 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1552 // Tests a failed EXPECT_PRED_FORMAT4 where the
1553 // predicate-formatter is a functor on a user-defined type (Bool).
1554 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1555 EXPECT_NONFATAL_FAILURE(
1557 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), Bool(n1_++), Bool(n2_++),
1558 Bool(n3_++), Bool(n4_++));
1564 // Tests a successful ASSERT_PRED_FORMAT4 where the
1565 // predicate-formatter is a function on a built-in type (int).
1566 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1567 ASSERT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1571 // Tests a successful ASSERT_PRED_FORMAT4 where the
1572 // predicate-formatter is a function on a user-defined type (Bool).
1573 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1574 ASSERT_PRED_FORMAT4(PredFormatFunction4, Bool(++n1_), Bool(++n2_),
1575 Bool(++n3_), Bool(++n4_));
1579 // Tests a successful ASSERT_PRED_FORMAT4 where the
1580 // predicate-formatter is a functor on a built-in type (int).
1581 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1582 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1586 // Tests a successful ASSERT_PRED_FORMAT4 where the
1587 // predicate-formatter is a functor on a user-defined type (Bool).
1588 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1589 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), Bool(++n1_), Bool(++n2_),
1590 Bool(++n3_), Bool(++n4_));
1594 // Tests a failed ASSERT_PRED_FORMAT4 where the
1595 // predicate-formatter is a function on a built-in type (int).
1596 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1597 expected_to_finish_ = false;
1598 EXPECT_FATAL_FAILURE(
1600 ASSERT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1606 // Tests a failed ASSERT_PRED_FORMAT4 where the
1607 // predicate-formatter is a function on a user-defined type (Bool).
1608 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1609 expected_to_finish_ = false;
1610 EXPECT_FATAL_FAILURE(
1612 ASSERT_PRED_FORMAT4(PredFormatFunction4, Bool(n1_++), Bool(n2_++),
1613 Bool(n3_++), Bool(n4_++));
1619 // Tests a failed ASSERT_PRED_FORMAT4 where the
1620 // predicate-formatter is a functor on a built-in type (int).
1621 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1622 expected_to_finish_ = false;
1623 EXPECT_FATAL_FAILURE(
1625 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1631 // Tests a failed ASSERT_PRED_FORMAT4 where the
1632 // predicate-formatter is a functor on a user-defined type (Bool).
1633 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1634 expected_to_finish_ = false;
1635 EXPECT_FATAL_FAILURE(
1637 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), Bool(n1_++), Bool(n2_++),
1638 Bool(n3_++), Bool(n4_++));
1643 // Sample functions/functors for testing 5-ary predicate assertions.
1645 // A 5-ary predicate function.
1646 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1647 bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
1648 return v1 + v2 + v3 + v4 + v5 > 0;
1651 // The following two functions are needed because a compiler doesn't have
1652 // a context yet to know which template function must be instantiated.
1653 bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
1654 return v1 + v2 + v3 + v4 + v5 > 0;
1656 bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
1657 return v1 + v2 + v3 + v4 + v5 > 0;
1660 // A 5-ary predicate functor.
1661 struct PredFunctor5 {
1662 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1663 bool operator()(const T1& v1, const T2& v2, const T3& v3, const T4& v4,
1665 return v1 + v2 + v3 + v4 + v5 > 0;
1669 // A 5-ary predicate-formatter function.
1670 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1671 testing::AssertionResult PredFormatFunction5(const char* e1, const char* e2,
1672 const char* e3, const char* e4,
1673 const char* e5, const T1& v1,
1674 const T2& v2, const T3& v3,
1675 const T4& v4, const T5& v5) {
1676 if (PredFunction5(v1, v2, v3, v4, v5)) return testing::AssertionSuccess();
1678 return testing::AssertionFailure()
1679 << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
1680 << " is expected to be positive, but evaluates to "
1681 << v1 + v2 + v3 + v4 + v5 << ".";
1684 // A 5-ary predicate-formatter functor.
1685 struct PredFormatFunctor5 {
1686 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1687 testing::AssertionResult operator()(const char* e1, const char* e2,
1688 const char* e3, const char* e4,
1689 const char* e5, const T1& v1,
1690 const T2& v2, const T3& v3, const T4& v4,
1691 const T5& v5) const {
1692 return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);
1696 // Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
1698 class Predicate5Test : public testing::Test {
1700 void SetUp() override {
1701 expected_to_finish_ = true;
1703 n1_ = n2_ = n3_ = n4_ = n5_ = 0;
1706 void TearDown() override {
1707 // Verifies that each of the predicate's arguments was evaluated
1709 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1711 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1713 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1715 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1717 EXPECT_EQ(1, n5_) << "The predicate assertion didn't evaluate argument 6 "
1720 // Verifies that the control flow in the test function is expected.
1721 if (expected_to_finish_ && !finished_) {
1722 FAIL() << "The predicate assertion unexpectedly aborted the test.";
1723 } else if (!expected_to_finish_ && finished_) {
1724 FAIL() << "The failed predicate assertion didn't abort the test "
1729 // true if and only if the test function is expected to run to finish.
1730 static bool expected_to_finish_;
1732 // true if and only if the test function did run to finish.
1733 static bool finished_;
1742 bool Predicate5Test::expected_to_finish_;
1743 bool Predicate5Test::finished_;
1744 int Predicate5Test::n1_;
1745 int Predicate5Test::n2_;
1746 int Predicate5Test::n3_;
1747 int Predicate5Test::n4_;
1748 int Predicate5Test::n5_;
1750 typedef Predicate5Test EXPECT_PRED_FORMAT5Test;
1751 typedef Predicate5Test ASSERT_PRED_FORMAT5Test;
1752 typedef Predicate5Test EXPECT_PRED5Test;
1753 typedef Predicate5Test ASSERT_PRED5Test;
1755 // Tests a successful EXPECT_PRED5 where the
1756 // predicate-formatter is a function on a built-in type (int).
1757 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1758 EXPECT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1762 // Tests a successful EXPECT_PRED5 where the
1763 // predicate-formatter is a function on a user-defined type (Bool).
1764 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
1765 EXPECT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1766 Bool(++n4_), Bool(++n5_));
1770 // Tests a successful EXPECT_PRED5 where the
1771 // predicate-formatter is a functor on a built-in type (int).
1772 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1773 EXPECT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1777 // Tests a successful EXPECT_PRED5 where the
1778 // predicate-formatter is a functor on a user-defined type (Bool).
1779 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
1780 EXPECT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1781 Bool(++n4_), Bool(++n5_));
1785 // Tests a failed EXPECT_PRED5 where the
1786 // predicate-formatter is a function on a built-in type (int).
1787 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1788 EXPECT_NONFATAL_FAILURE(
1790 EXPECT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1796 // Tests a failed EXPECT_PRED5 where the
1797 // predicate-formatter is a function on a user-defined type (Bool).
1798 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
1799 EXPECT_NONFATAL_FAILURE(
1801 EXPECT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1802 Bool(n4_++), Bool(n5_++));
1808 // Tests a failed EXPECT_PRED5 where the
1809 // predicate-formatter is a functor on a built-in type (int).
1810 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1811 EXPECT_NONFATAL_FAILURE(
1813 EXPECT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1819 // Tests a failed EXPECT_PRED5 where the
1820 // predicate-formatter is a functor on a user-defined type (Bool).
1821 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
1822 EXPECT_NONFATAL_FAILURE(
1824 EXPECT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1825 Bool(n4_++), Bool(n5_++));
1831 // Tests a successful ASSERT_PRED5 where the
1832 // predicate-formatter is a function on a built-in type (int).
1833 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1834 ASSERT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1838 // Tests a successful ASSERT_PRED5 where the
1839 // predicate-formatter is a function on a user-defined type (Bool).
1840 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
1841 ASSERT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1842 Bool(++n4_), Bool(++n5_));
1846 // Tests a successful ASSERT_PRED5 where the
1847 // predicate-formatter is a functor on a built-in type (int).
1848 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1849 ASSERT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1853 // Tests a successful ASSERT_PRED5 where the
1854 // predicate-formatter is a functor on a user-defined type (Bool).
1855 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
1856 ASSERT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1857 Bool(++n4_), Bool(++n5_));
1861 // Tests a failed ASSERT_PRED5 where the
1862 // predicate-formatter is a function on a built-in type (int).
1863 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1864 expected_to_finish_ = false;
1865 EXPECT_FATAL_FAILURE(
1867 ASSERT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1873 // Tests a failed ASSERT_PRED5 where the
1874 // predicate-formatter is a function on a user-defined type (Bool).
1875 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
1876 expected_to_finish_ = false;
1877 EXPECT_FATAL_FAILURE(
1879 ASSERT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1880 Bool(n4_++), Bool(n5_++));
1886 // Tests a failed ASSERT_PRED5 where the
1887 // predicate-formatter is a functor on a built-in type (int).
1888 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1889 expected_to_finish_ = false;
1890 EXPECT_FATAL_FAILURE(
1892 ASSERT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1898 // Tests a failed ASSERT_PRED5 where the
1899 // predicate-formatter is a functor on a user-defined type (Bool).
1900 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
1901 expected_to_finish_ = false;
1902 EXPECT_FATAL_FAILURE(
1904 ASSERT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1905 Bool(n4_++), Bool(n5_++));
1911 // Tests a successful EXPECT_PRED_FORMAT5 where the
1912 // predicate-formatter is a function on a built-in type (int).
1913 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1914 EXPECT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1918 // Tests a successful EXPECT_PRED_FORMAT5 where the
1919 // predicate-formatter is a function on a user-defined type (Bool).
1920 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
1921 EXPECT_PRED_FORMAT5(PredFormatFunction5, Bool(++n1_), Bool(++n2_),
1922 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1926 // Tests a successful EXPECT_PRED_FORMAT5 where the
1927 // predicate-formatter is a functor on a built-in type (int).
1928 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
1929 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1933 // Tests a successful EXPECT_PRED_FORMAT5 where the
1934 // predicate-formatter is a functor on a user-defined type (Bool).
1935 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
1936 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), Bool(++n1_), Bool(++n2_),
1937 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1941 // Tests a failed EXPECT_PRED_FORMAT5 where the
1942 // predicate-formatter is a function on a built-in type (int).
1943 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
1944 EXPECT_NONFATAL_FAILURE(
1946 EXPECT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
1953 // Tests a failed EXPECT_PRED_FORMAT5 where the
1954 // predicate-formatter is a function on a user-defined type (Bool).
1955 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
1956 EXPECT_NONFATAL_FAILURE(
1958 EXPECT_PRED_FORMAT5(PredFormatFunction5, Bool(n1_++), Bool(n2_++),
1959 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1965 // Tests a failed EXPECT_PRED_FORMAT5 where the
1966 // predicate-formatter is a functor on a built-in type (int).
1967 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
1968 EXPECT_NONFATAL_FAILURE(
1970 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
1977 // Tests a failed EXPECT_PRED_FORMAT5 where the
1978 // predicate-formatter is a functor on a user-defined type (Bool).
1979 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
1980 EXPECT_NONFATAL_FAILURE(
1982 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), Bool(n1_++), Bool(n2_++),
1983 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1989 // Tests a successful ASSERT_PRED_FORMAT5 where the
1990 // predicate-formatter is a function on a built-in type (int).
1991 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1992 ASSERT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1996 // Tests a successful ASSERT_PRED_FORMAT5 where the
1997 // predicate-formatter is a function on a user-defined type (Bool).
1998 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
1999 ASSERT_PRED_FORMAT5(PredFormatFunction5, Bool(++n1_), Bool(++n2_),
2000 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2004 // Tests a successful ASSERT_PRED_FORMAT5 where the
2005 // predicate-formatter is a functor on a built-in type (int).
2006 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
2007 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
2011 // Tests a successful ASSERT_PRED_FORMAT5 where the
2012 // predicate-formatter is a functor on a user-defined type (Bool).
2013 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
2014 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), Bool(++n1_), Bool(++n2_),
2015 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2019 // Tests a failed ASSERT_PRED_FORMAT5 where the
2020 // predicate-formatter is a function on a built-in type (int).
2021 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
2022 expected_to_finish_ = false;
2023 EXPECT_FATAL_FAILURE(
2025 ASSERT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
2032 // Tests a failed ASSERT_PRED_FORMAT5 where the
2033 // predicate-formatter is a function on a user-defined type (Bool).
2034 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
2035 expected_to_finish_ = false;
2036 EXPECT_FATAL_FAILURE(
2038 ASSERT_PRED_FORMAT5(PredFormatFunction5, Bool(n1_++), Bool(n2_++),
2039 Bool(n3_++), Bool(n4_++), Bool(n5_++));
2045 // Tests a failed ASSERT_PRED_FORMAT5 where the
2046 // predicate-formatter is a functor on a built-in type (int).
2047 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
2048 expected_to_finish_ = false;
2049 EXPECT_FATAL_FAILURE(
2051 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
2058 // Tests a failed ASSERT_PRED_FORMAT5 where the
2059 // predicate-formatter is a functor on a user-defined type (Bool).
2060 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
2061 expected_to_finish_ = false;
2062 EXPECT_FATAL_FAILURE(
2064 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), Bool(n1_++), Bool(n2_++),
2065 Bool(n3_++), Bool(n4_++), Bool(n5_++));