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.
50 #include "gtest/gtest-spi.h"
51 #include "gtest/gtest.h"
53 // A user-defined data type.
55 explicit Bool(int val) : value(val != 0) {}
57 bool operator>(int n) const { return value > Bool(n).value; }
59 Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
61 bool operator==(const Bool& rhs) const { return value == rhs.value; }
66 // Enables Bool to be used in assertions.
67 std::ostream& operator<<(std::ostream& os, const Bool& x) {
68 return os << (x.value ? "true" : "false");
71 // Sample functions/functors for testing unary predicate assertions.
73 // A unary predicate function.
74 template <typename T1>
75 bool PredFunction1(T1 v1) {
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.
81 bool PredFunction1Int(int v1) { return v1 > 0; }
82 bool PredFunction1Bool(Bool v1) { return v1 > 0; }
84 // A unary predicate functor.
86 template <typename T1>
87 bool operator()(const T1& v1) {
92 // A unary predicate-formatter function.
93 template <typename T1>
94 testing::AssertionResult PredFormatFunction1(const char* e1, const T1& v1) {
95 if (PredFunction1(v1)) return testing::AssertionSuccess();
97 return testing::AssertionFailure()
98 << e1 << " is expected to be positive, but evaluates to " << v1 << ".";
101 // A unary predicate-formatter functor.
102 struct PredFormatFunctor1 {
103 template <typename T1>
104 testing::AssertionResult operator()(const char* e1, const T1& v1) const {
105 return PredFormatFunction1(e1, v1);
109 // Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
111 class Predicate1Test : public testing::Test {
113 void SetUp() override {
114 expected_to_finish_ = true;
119 void TearDown() override {
120 // Verifies that each of the predicate's arguments was evaluated
122 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
125 // Verifies that the control flow in the test function is expected.
126 if (expected_to_finish_ && !finished_) {
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 "
134 // true if and only if the test function is expected to run to finish.
135 static bool expected_to_finish_;
137 // true if and only if the test function did run to finish.
138 static bool finished_;
143 bool Predicate1Test::expected_to_finish_;
144 bool Predicate1Test::finished_;
145 int Predicate1Test::n1_;
147 typedef Predicate1Test EXPECT_PRED_FORMAT1Test;
148 typedef Predicate1Test ASSERT_PRED_FORMAT1Test;
149 typedef Predicate1Test EXPECT_PRED1Test;
150 typedef Predicate1Test ASSERT_PRED1Test;
152 // Tests a successful EXPECT_PRED1 where the
153 // predicate-formatter is a function on a built-in type (int).
154 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
155 EXPECT_PRED1(PredFunction1Int, ++n1_);
159 // Tests a successful EXPECT_PRED1 where the
160 // predicate-formatter is a function on a user-defined type (Bool).
161 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
162 EXPECT_PRED1(PredFunction1Bool, Bool(++n1_));
166 // Tests a successful EXPECT_PRED1 where the
167 // predicate-formatter is a functor on a built-in type (int).
168 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
169 EXPECT_PRED1(PredFunctor1(), ++n1_);
173 // Tests a successful EXPECT_PRED1 where the
174 // predicate-formatter is a functor on a user-defined type (Bool).
175 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
176 EXPECT_PRED1(PredFunctor1(), Bool(++n1_));
180 // Tests a failed EXPECT_PRED1 where the
181 // predicate-formatter is a function on a built-in type (int).
182 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
183 EXPECT_NONFATAL_FAILURE(
185 EXPECT_PRED1(PredFunction1Int, n1_++);
191 // Tests a failed EXPECT_PRED1 where the
192 // predicate-formatter is a function on a user-defined type (Bool).
193 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
194 EXPECT_NONFATAL_FAILURE(
196 EXPECT_PRED1(PredFunction1Bool, Bool(n1_++));
202 // Tests a failed EXPECT_PRED1 where the
203 // predicate-formatter is a functor on a built-in type (int).
204 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
205 EXPECT_NONFATAL_FAILURE(
207 EXPECT_PRED1(PredFunctor1(), n1_++);
213 // Tests a failed EXPECT_PRED1 where the
214 // predicate-formatter is a functor on a user-defined type (Bool).
215 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
216 EXPECT_NONFATAL_FAILURE(
218 EXPECT_PRED1(PredFunctor1(), Bool(n1_++));
224 // Tests a successful ASSERT_PRED1 where the
225 // predicate-formatter is a function on a built-in type (int).
226 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
227 ASSERT_PRED1(PredFunction1Int, ++n1_);
231 // Tests a successful ASSERT_PRED1 where the
232 // predicate-formatter is a function on a user-defined type (Bool).
233 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
234 ASSERT_PRED1(PredFunction1Bool, Bool(++n1_));
238 // Tests a successful ASSERT_PRED1 where the
239 // predicate-formatter is a functor on a built-in type (int).
240 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
241 ASSERT_PRED1(PredFunctor1(), ++n1_);
245 // Tests a successful ASSERT_PRED1 where the
246 // predicate-formatter is a functor on a user-defined type (Bool).
247 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
248 ASSERT_PRED1(PredFunctor1(), Bool(++n1_));
252 // Tests a failed ASSERT_PRED1 where the
253 // predicate-formatter is a function on a built-in type (int).
254 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
255 expected_to_finish_ = false;
256 EXPECT_FATAL_FAILURE(
258 ASSERT_PRED1(PredFunction1Int, n1_++);
264 // Tests a failed ASSERT_PRED1 where the
265 // predicate-formatter is a function on a user-defined type (Bool).
266 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
267 expected_to_finish_ = false;
268 EXPECT_FATAL_FAILURE(
270 ASSERT_PRED1(PredFunction1Bool, Bool(n1_++));
276 // Tests a failed ASSERT_PRED1 where the
277 // predicate-formatter is a functor on a built-in type (int).
278 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
279 expected_to_finish_ = false;
280 EXPECT_FATAL_FAILURE(
282 ASSERT_PRED1(PredFunctor1(), n1_++);
288 // Tests a failed ASSERT_PRED1 where the
289 // predicate-formatter is a functor on a user-defined type (Bool).
290 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
291 expected_to_finish_ = false;
292 EXPECT_FATAL_FAILURE(
294 ASSERT_PRED1(PredFunctor1(), Bool(n1_++));
300 // Tests a successful EXPECT_PRED_FORMAT1 where the
301 // predicate-formatter is a function on a built-in type (int).
302 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
303 EXPECT_PRED_FORMAT1(PredFormatFunction1, ++n1_);
307 // Tests a successful EXPECT_PRED_FORMAT1 where the
308 // predicate-formatter is a function on a user-defined type (Bool).
309 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
310 EXPECT_PRED_FORMAT1(PredFormatFunction1, Bool(++n1_));
314 // Tests a successful EXPECT_PRED_FORMAT1 where the
315 // predicate-formatter is a functor on a built-in type (int).
316 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
317 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), ++n1_);
321 // Tests a successful EXPECT_PRED_FORMAT1 where the
322 // predicate-formatter is a functor on a user-defined type (Bool).
323 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
324 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), Bool(++n1_));
328 // Tests a failed EXPECT_PRED_FORMAT1 where the
329 // predicate-formatter is a function on a built-in type (int).
330 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
331 EXPECT_NONFATAL_FAILURE(
333 EXPECT_PRED_FORMAT1(PredFormatFunction1, n1_++);
339 // Tests a failed EXPECT_PRED_FORMAT1 where the
340 // predicate-formatter is a function on a user-defined type (Bool).
341 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
342 EXPECT_NONFATAL_FAILURE(
344 EXPECT_PRED_FORMAT1(PredFormatFunction1, Bool(n1_++));
350 // Tests a failed EXPECT_PRED_FORMAT1 where the
351 // predicate-formatter is a functor on a built-in type (int).
352 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
353 EXPECT_NONFATAL_FAILURE(
355 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), n1_++);
361 // Tests a failed EXPECT_PRED_FORMAT1 where the
362 // predicate-formatter is a functor on a user-defined type (Bool).
363 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
364 EXPECT_NONFATAL_FAILURE(
366 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), Bool(n1_++));
372 // Tests a successful ASSERT_PRED_FORMAT1 where the
373 // predicate-formatter is a function on a built-in type (int).
374 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
375 ASSERT_PRED_FORMAT1(PredFormatFunction1, ++n1_);
379 // Tests a successful ASSERT_PRED_FORMAT1 where the
380 // predicate-formatter is a function on a user-defined type (Bool).
381 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
382 ASSERT_PRED_FORMAT1(PredFormatFunction1, Bool(++n1_));
386 // Tests a successful ASSERT_PRED_FORMAT1 where the
387 // predicate-formatter is a functor on a built-in type (int).
388 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
389 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), ++n1_);
393 // Tests a successful ASSERT_PRED_FORMAT1 where the
394 // predicate-formatter is a functor on a user-defined type (Bool).
395 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
396 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), Bool(++n1_));
400 // Tests a failed ASSERT_PRED_FORMAT1 where the
401 // predicate-formatter is a function on a built-in type (int).
402 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
403 expected_to_finish_ = false;
404 EXPECT_FATAL_FAILURE(
406 ASSERT_PRED_FORMAT1(PredFormatFunction1, n1_++);
412 // Tests a failed ASSERT_PRED_FORMAT1 where the
413 // predicate-formatter is a function on a user-defined type (Bool).
414 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
415 expected_to_finish_ = false;
416 EXPECT_FATAL_FAILURE(
418 ASSERT_PRED_FORMAT1(PredFormatFunction1, Bool(n1_++));
424 // Tests a failed ASSERT_PRED_FORMAT1 where the
425 // predicate-formatter is a functor on a built-in type (int).
426 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
427 expected_to_finish_ = false;
428 EXPECT_FATAL_FAILURE(
430 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), n1_++);
436 // Tests a failed ASSERT_PRED_FORMAT1 where the
437 // predicate-formatter is a functor on a user-defined type (Bool).
438 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
439 expected_to_finish_ = false;
440 EXPECT_FATAL_FAILURE(
442 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), Bool(n1_++));
447 // Sample functions/functors for testing binary predicate assertions.
449 // A binary predicate function.
450 template <typename T1, typename T2>
451 bool PredFunction2(T1 v1, T2 v2) {
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.
457 bool PredFunction2Int(int v1, int v2) { return v1 + v2 > 0; }
458 bool PredFunction2Bool(Bool v1, Bool v2) { return v1 + v2 > 0; }
460 // A binary predicate functor.
461 struct PredFunctor2 {
462 template <typename T1, typename T2>
463 bool operator()(const T1& v1, const T2& v2) {
468 // A binary predicate-formatter function.
469 template <typename T1, typename T2>
470 testing::AssertionResult PredFormatFunction2(const char* e1, const char* e2,
471 const T1& v1, const T2& v2) {
472 if (PredFunction2(v1, v2)) return testing::AssertionSuccess();
474 return testing::AssertionFailure()
476 << " is expected to be positive, but evaluates to " << v1 + v2 << ".";
479 // A binary predicate-formatter functor.
480 struct PredFormatFunctor2 {
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);
488 // Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
490 class Predicate2Test : public testing::Test {
492 void SetUp() override {
493 expected_to_finish_ = true;
498 void TearDown() override {
499 // Verifies that each of the predicate's arguments was evaluated
501 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
503 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
506 // Verifies that the control flow in the test function is expected.
507 if (expected_to_finish_ && !finished_) {
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 "
515 // true if and only if the test function is expected to run to finish.
516 static bool expected_to_finish_;
518 // true if and only if the test function did run to finish.
519 static bool finished_;
525 bool Predicate2Test::expected_to_finish_;
526 bool Predicate2Test::finished_;
527 int Predicate2Test::n1_;
528 int Predicate2Test::n2_;
530 typedef Predicate2Test EXPECT_PRED_FORMAT2Test;
531 typedef Predicate2Test ASSERT_PRED_FORMAT2Test;
532 typedef Predicate2Test EXPECT_PRED2Test;
533 typedef Predicate2Test ASSERT_PRED2Test;
535 // Tests a successful EXPECT_PRED2 where the
536 // predicate-formatter is a function on a built-in type (int).
537 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
538 EXPECT_PRED2(PredFunction2Int, ++n1_, ++n2_);
542 // Tests a successful EXPECT_PRED2 where the
543 // predicate-formatter is a function on a user-defined type (Bool).
544 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
545 EXPECT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
549 // Tests a successful EXPECT_PRED2 where the
550 // predicate-formatter is a functor on a built-in type (int).
551 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
552 EXPECT_PRED2(PredFunctor2(), ++n1_, ++n2_);
556 // Tests a successful EXPECT_PRED2 where the
557 // predicate-formatter is a functor on a user-defined type (Bool).
558 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
559 EXPECT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
563 // Tests a failed EXPECT_PRED2 where the
564 // predicate-formatter is a function on a built-in type (int).
565 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
566 EXPECT_NONFATAL_FAILURE(
568 EXPECT_PRED2(PredFunction2Int, n1_++, n2_++);
574 // Tests a failed EXPECT_PRED2 where the
575 // predicate-formatter is a function on a user-defined type (Bool).
576 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
577 EXPECT_NONFATAL_FAILURE(
579 EXPECT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
585 // Tests a failed EXPECT_PRED2 where the
586 // predicate-formatter is a functor on a built-in type (int).
587 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
588 EXPECT_NONFATAL_FAILURE(
590 EXPECT_PRED2(PredFunctor2(), n1_++, n2_++);
596 // Tests a failed EXPECT_PRED2 where the
597 // predicate-formatter is a functor on a user-defined type (Bool).
598 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
599 EXPECT_NONFATAL_FAILURE(
601 EXPECT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
607 // Tests a successful ASSERT_PRED2 where the
608 // predicate-formatter is a function on a built-in type (int).
609 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
610 ASSERT_PRED2(PredFunction2Int, ++n1_, ++n2_);
614 // Tests a successful ASSERT_PRED2 where the
615 // predicate-formatter is a function on a user-defined type (Bool).
616 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
617 ASSERT_PRED2(PredFunction2Bool, Bool(++n1_), Bool(++n2_));
621 // Tests a successful ASSERT_PRED2 where the
622 // predicate-formatter is a functor on a built-in type (int).
623 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
624 ASSERT_PRED2(PredFunctor2(), ++n1_, ++n2_);
628 // Tests a successful ASSERT_PRED2 where the
629 // predicate-formatter is a functor on a user-defined type (Bool).
630 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
631 ASSERT_PRED2(PredFunctor2(), Bool(++n1_), Bool(++n2_));
635 // Tests a failed ASSERT_PRED2 where the
636 // predicate-formatter is a function on a built-in type (int).
637 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
638 expected_to_finish_ = false;
639 EXPECT_FATAL_FAILURE(
641 ASSERT_PRED2(PredFunction2Int, n1_++, n2_++);
647 // Tests a failed ASSERT_PRED2 where the
648 // predicate-formatter is a function on a user-defined type (Bool).
649 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
650 expected_to_finish_ = false;
651 EXPECT_FATAL_FAILURE(
653 ASSERT_PRED2(PredFunction2Bool, Bool(n1_++), Bool(n2_++));
659 // Tests a failed ASSERT_PRED2 where the
660 // predicate-formatter is a functor on a built-in type (int).
661 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
662 expected_to_finish_ = false;
663 EXPECT_FATAL_FAILURE(
665 ASSERT_PRED2(PredFunctor2(), n1_++, n2_++);
671 // Tests a failed ASSERT_PRED2 where the
672 // predicate-formatter is a functor on a user-defined type (Bool).
673 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
674 expected_to_finish_ = false;
675 EXPECT_FATAL_FAILURE(
677 ASSERT_PRED2(PredFunctor2(), Bool(n1_++), Bool(n2_++));
683 // Tests a successful EXPECT_PRED_FORMAT2 where the
684 // predicate-formatter is a function on a built-in type (int).
685 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
686 EXPECT_PRED_FORMAT2(PredFormatFunction2, ++n1_, ++n2_);
690 // Tests a successful EXPECT_PRED_FORMAT2 where the
691 // predicate-formatter is a function on a user-defined type (Bool).
692 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
693 EXPECT_PRED_FORMAT2(PredFormatFunction2, Bool(++n1_), Bool(++n2_));
697 // Tests a successful EXPECT_PRED_FORMAT2 where the
698 // predicate-formatter is a functor on a built-in type (int).
699 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
700 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), ++n1_, ++n2_);
704 // Tests a successful EXPECT_PRED_FORMAT2 where the
705 // predicate-formatter is a functor on a user-defined type (Bool).
706 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
707 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), Bool(++n1_), Bool(++n2_));
711 // Tests a failed EXPECT_PRED_FORMAT2 where the
712 // predicate-formatter is a function on a built-in type (int).
713 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
714 EXPECT_NONFATAL_FAILURE(
716 EXPECT_PRED_FORMAT2(PredFormatFunction2, n1_++, n2_++);
722 // Tests a failed EXPECT_PRED_FORMAT2 where the
723 // predicate-formatter is a function on a user-defined type (Bool).
724 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
725 EXPECT_NONFATAL_FAILURE(
727 EXPECT_PRED_FORMAT2(PredFormatFunction2, Bool(n1_++), Bool(n2_++));
733 // Tests a failed EXPECT_PRED_FORMAT2 where the
734 // predicate-formatter is a functor on a built-in type (int).
735 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
736 EXPECT_NONFATAL_FAILURE(
738 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), n1_++, n2_++);
744 // Tests a failed EXPECT_PRED_FORMAT2 where the
745 // predicate-formatter is a functor on a user-defined type (Bool).
746 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
747 EXPECT_NONFATAL_FAILURE(
749 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), Bool(n1_++), Bool(n2_++));
755 // Tests a successful ASSERT_PRED_FORMAT2 where the
756 // predicate-formatter is a function on a built-in type (int).
757 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
758 ASSERT_PRED_FORMAT2(PredFormatFunction2, ++n1_, ++n2_);
762 // Tests a successful ASSERT_PRED_FORMAT2 where the
763 // predicate-formatter is a function on a user-defined type (Bool).
764 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
765 ASSERT_PRED_FORMAT2(PredFormatFunction2, Bool(++n1_), Bool(++n2_));
769 // Tests a successful ASSERT_PRED_FORMAT2 where the
770 // predicate-formatter is a functor on a built-in type (int).
771 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
772 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), ++n1_, ++n2_);
776 // Tests a successful ASSERT_PRED_FORMAT2 where the
777 // predicate-formatter is a functor on a user-defined type (Bool).
778 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
779 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), Bool(++n1_), Bool(++n2_));
783 // Tests a failed ASSERT_PRED_FORMAT2 where the
784 // predicate-formatter is a function on a built-in type (int).
785 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
786 expected_to_finish_ = false;
787 EXPECT_FATAL_FAILURE(
789 ASSERT_PRED_FORMAT2(PredFormatFunction2, n1_++, n2_++);
795 // Tests a failed ASSERT_PRED_FORMAT2 where the
796 // predicate-formatter is a function on a user-defined type (Bool).
797 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
798 expected_to_finish_ = false;
799 EXPECT_FATAL_FAILURE(
801 ASSERT_PRED_FORMAT2(PredFormatFunction2, Bool(n1_++), Bool(n2_++));
807 // Tests a failed ASSERT_PRED_FORMAT2 where the
808 // predicate-formatter is a functor on a built-in type (int).
809 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
810 expected_to_finish_ = false;
811 EXPECT_FATAL_FAILURE(
813 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), n1_++, n2_++);
819 // Tests a failed ASSERT_PRED_FORMAT2 where the
820 // predicate-formatter is a functor on a user-defined type (Bool).
821 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
822 expected_to_finish_ = false;
823 EXPECT_FATAL_FAILURE(
825 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), Bool(n1_++), Bool(n2_++));
830 // Sample functions/functors for testing ternary predicate assertions.
832 // A ternary predicate function.
833 template <typename T1, typename T2, typename T3>
834 bool PredFunction3(T1 v1, T2 v2, T3 v3) {
835 return v1 + v2 + v3 > 0;
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.
840 bool PredFunction3Int(int v1, int v2, int v3) { return v1 + v2 + v3 > 0; }
841 bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) { return v1 + v2 + v3 > 0; }
843 // A ternary predicate functor.
844 struct PredFunctor3 {
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;
851 // A ternary predicate-formatter function.
852 template <typename T1, typename T2, typename T3>
853 testing::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();
858 return testing::AssertionFailure()
859 << e1 << " + " << e2 << " + " << e3
860 << " is expected to be positive, but evaluates to " << v1 + v2 + v3
864 // A ternary predicate-formatter functor.
865 struct PredFormatFunctor3 {
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);
874 // Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
876 class Predicate3Test : public testing::Test {
878 void SetUp() override {
879 expected_to_finish_ = true;
884 void TearDown() override {
885 // Verifies that each of the predicate's arguments was evaluated
887 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
889 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
891 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
894 // Verifies that the control flow in the test function is expected.
895 if (expected_to_finish_ && !finished_) {
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 "
903 // true if and only if the test function is expected to run to finish.
904 static bool expected_to_finish_;
906 // true if and only if the test function did run to finish.
907 static bool finished_;
914 bool Predicate3Test::expected_to_finish_;
915 bool Predicate3Test::finished_;
916 int Predicate3Test::n1_;
917 int Predicate3Test::n2_;
918 int Predicate3Test::n3_;
920 typedef Predicate3Test EXPECT_PRED_FORMAT3Test;
921 typedef Predicate3Test ASSERT_PRED_FORMAT3Test;
922 typedef Predicate3Test EXPECT_PRED3Test;
923 typedef Predicate3Test ASSERT_PRED3Test;
925 // Tests a successful EXPECT_PRED3 where the
926 // predicate-formatter is a function on a built-in type (int).
927 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
928 EXPECT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
932 // Tests a successful EXPECT_PRED3 where the
933 // predicate-formatter is a function on a user-defined type (Bool).
934 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
935 EXPECT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
939 // Tests a successful EXPECT_PRED3 where the
940 // predicate-formatter is a functor on a built-in type (int).
941 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
942 EXPECT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
946 // Tests a successful EXPECT_PRED3 where the
947 // predicate-formatter is a functor on a user-defined type (Bool).
948 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
949 EXPECT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
953 // Tests a failed EXPECT_PRED3 where the
954 // predicate-formatter is a function on a built-in type (int).
955 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
956 EXPECT_NONFATAL_FAILURE(
958 EXPECT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
964 // Tests a failed EXPECT_PRED3 where the
965 // predicate-formatter is a function on a user-defined type (Bool).
966 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
967 EXPECT_NONFATAL_FAILURE(
969 EXPECT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
975 // Tests a failed EXPECT_PRED3 where the
976 // predicate-formatter is a functor on a built-in type (int).
977 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
978 EXPECT_NONFATAL_FAILURE(
980 EXPECT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
986 // Tests a failed EXPECT_PRED3 where the
987 // predicate-formatter is a functor on a user-defined type (Bool).
988 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
989 EXPECT_NONFATAL_FAILURE(
991 EXPECT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
997 // Tests a successful ASSERT_PRED3 where the
998 // predicate-formatter is a function on a built-in type (int).
999 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
1000 ASSERT_PRED3(PredFunction3Int, ++n1_, ++n2_, ++n3_);
1004 // Tests a successful ASSERT_PRED3 where the
1005 // predicate-formatter is a function on a user-defined type (Bool).
1006 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
1007 ASSERT_PRED3(PredFunction3Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_));
1011 // Tests a successful ASSERT_PRED3 where the
1012 // predicate-formatter is a functor on a built-in type (int).
1013 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
1014 ASSERT_PRED3(PredFunctor3(), ++n1_, ++n2_, ++n3_);
1018 // Tests a successful ASSERT_PRED3 where the
1019 // predicate-formatter is a functor on a user-defined type (Bool).
1020 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
1021 ASSERT_PRED3(PredFunctor3(), Bool(++n1_), Bool(++n2_), Bool(++n3_));
1025 // Tests a failed ASSERT_PRED3 where the
1026 // predicate-formatter is a function on a built-in type (int).
1027 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
1028 expected_to_finish_ = false;
1029 EXPECT_FATAL_FAILURE(
1031 ASSERT_PRED3(PredFunction3Int, n1_++, n2_++, n3_++);
1037 // Tests a failed ASSERT_PRED3 where the
1038 // predicate-formatter is a function on a user-defined type (Bool).
1039 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
1040 expected_to_finish_ = false;
1041 EXPECT_FATAL_FAILURE(
1043 ASSERT_PRED3(PredFunction3Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++));
1049 // Tests a failed ASSERT_PRED3 where the
1050 // predicate-formatter is a functor on a built-in type (int).
1051 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
1052 expected_to_finish_ = false;
1053 EXPECT_FATAL_FAILURE(
1055 ASSERT_PRED3(PredFunctor3(), n1_++, n2_++, n3_++);
1061 // Tests a failed ASSERT_PRED3 where the
1062 // predicate-formatter is a functor on a user-defined type (Bool).
1063 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
1064 expected_to_finish_ = false;
1065 EXPECT_FATAL_FAILURE(
1067 ASSERT_PRED3(PredFunctor3(), Bool(n1_++), Bool(n2_++), Bool(n3_++));
1073 // Tests a successful EXPECT_PRED_FORMAT3 where the
1074 // predicate-formatter is a function on a built-in type (int).
1075 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1076 EXPECT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1080 // Tests a successful EXPECT_PRED_FORMAT3 where the
1081 // predicate-formatter is a function on a user-defined type (Bool).
1082 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1083 EXPECT_PRED_FORMAT3(PredFormatFunction3, Bool(++n1_), Bool(++n2_),
1088 // Tests a successful EXPECT_PRED_FORMAT3 where the
1089 // predicate-formatter is a functor on a built-in type (int).
1090 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1091 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1095 // Tests a successful EXPECT_PRED_FORMAT3 where the
1096 // predicate-formatter is a functor on a user-defined type (Bool).
1097 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1098 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), Bool(++n1_), Bool(++n2_),
1103 // Tests a failed EXPECT_PRED_FORMAT3 where the
1104 // predicate-formatter is a function on a built-in type (int).
1105 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1106 EXPECT_NONFATAL_FAILURE(
1108 EXPECT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1114 // Tests a failed EXPECT_PRED_FORMAT3 where the
1115 // predicate-formatter is a function on a user-defined type (Bool).
1116 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1117 EXPECT_NONFATAL_FAILURE(
1119 EXPECT_PRED_FORMAT3(PredFormatFunction3, Bool(n1_++), Bool(n2_++),
1126 // Tests a failed EXPECT_PRED_FORMAT3 where the
1127 // predicate-formatter is a functor on a built-in type (int).
1128 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1129 EXPECT_NONFATAL_FAILURE(
1131 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1137 // Tests a failed EXPECT_PRED_FORMAT3 where the
1138 // predicate-formatter is a functor on a user-defined type (Bool).
1139 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1140 EXPECT_NONFATAL_FAILURE(
1142 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), Bool(n1_++), Bool(n2_++),
1149 // Tests a successful ASSERT_PRED_FORMAT3 where the
1150 // predicate-formatter is a function on a built-in type (int).
1151 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1152 ASSERT_PRED_FORMAT3(PredFormatFunction3, ++n1_, ++n2_, ++n3_);
1156 // Tests a successful ASSERT_PRED_FORMAT3 where the
1157 // predicate-formatter is a function on a user-defined type (Bool).
1158 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1159 ASSERT_PRED_FORMAT3(PredFormatFunction3, Bool(++n1_), Bool(++n2_),
1164 // Tests a successful ASSERT_PRED_FORMAT3 where the
1165 // predicate-formatter is a functor on a built-in type (int).
1166 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1167 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), ++n1_, ++n2_, ++n3_);
1171 // Tests a successful ASSERT_PRED_FORMAT3 where the
1172 // predicate-formatter is a functor on a user-defined type (Bool).
1173 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1174 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), Bool(++n1_), Bool(++n2_),
1179 // Tests a failed ASSERT_PRED_FORMAT3 where the
1180 // predicate-formatter is a function on a built-in type (int).
1181 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1182 expected_to_finish_ = false;
1183 EXPECT_FATAL_FAILURE(
1185 ASSERT_PRED_FORMAT3(PredFormatFunction3, n1_++, n2_++, n3_++);
1191 // Tests a failed ASSERT_PRED_FORMAT3 where the
1192 // predicate-formatter is a function on a user-defined type (Bool).
1193 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1194 expected_to_finish_ = false;
1195 EXPECT_FATAL_FAILURE(
1197 ASSERT_PRED_FORMAT3(PredFormatFunction3, Bool(n1_++), Bool(n2_++),
1204 // Tests a failed ASSERT_PRED_FORMAT3 where the
1205 // predicate-formatter is a functor on a built-in type (int).
1206 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1207 expected_to_finish_ = false;
1208 EXPECT_FATAL_FAILURE(
1210 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), n1_++, n2_++, n3_++);
1216 // Tests a failed ASSERT_PRED_FORMAT3 where the
1217 // predicate-formatter is a functor on a user-defined type (Bool).
1218 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1219 expected_to_finish_ = false;
1220 EXPECT_FATAL_FAILURE(
1222 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), Bool(n1_++), Bool(n2_++),
1228 // Sample functions/functors for testing 4-ary predicate assertions.
1230 // A 4-ary predicate function.
1231 template <typename T1, typename T2, typename T3, typename T4>
1232 bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
1233 return v1 + v2 + v3 + v4 > 0;
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.
1238 bool PredFunction4Int(int v1, int v2, int v3, int v4) {
1239 return v1 + v2 + v3 + v4 > 0;
1241 bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
1242 return v1 + v2 + v3 + v4 > 0;
1245 // A 4-ary predicate functor.
1246 struct PredFunctor4 {
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;
1253 // A 4-ary predicate-formatter function.
1254 template <typename T1, typename T2, typename T3, typename T4>
1255 testing::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();
1261 return testing::AssertionFailure()
1262 << e1 << " + " << e2 << " + " << e3 << " + " << e4
1263 << " is expected to be positive, but evaluates to "
1264 << v1 + v2 + v3 + v4 << ".";
1267 // A 4-ary predicate-formatter functor.
1268 struct PredFormatFunctor4 {
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);
1278 // Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
1280 class Predicate4Test : public testing::Test {
1282 void SetUp() override {
1283 expected_to_finish_ = true;
1285 n1_ = n2_ = n3_ = n4_ = 0;
1288 void TearDown() override {
1289 // Verifies that each of the predicate's arguments was evaluated
1291 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1293 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1295 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1297 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1300 // Verifies that the control flow in the test function is expected.
1301 if (expected_to_finish_ && !finished_) {
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 "
1309 // true if and only if the test function is expected to run to finish.
1310 static bool expected_to_finish_;
1312 // true if and only if the test function did run to finish.
1313 static bool finished_;
1321 bool Predicate4Test::expected_to_finish_;
1322 bool Predicate4Test::finished_;
1323 int Predicate4Test::n1_;
1324 int Predicate4Test::n2_;
1325 int Predicate4Test::n3_;
1326 int Predicate4Test::n4_;
1328 typedef Predicate4Test EXPECT_PRED_FORMAT4Test;
1329 typedef Predicate4Test ASSERT_PRED_FORMAT4Test;
1330 typedef Predicate4Test EXPECT_PRED4Test;
1331 typedef Predicate4Test ASSERT_PRED4Test;
1333 // Tests a successful EXPECT_PRED4 where the
1334 // predicate-formatter is a function on a built-in type (int).
1335 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1336 EXPECT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1340 // Tests a successful EXPECT_PRED4 where the
1341 // predicate-formatter is a function on a user-defined type (Bool).
1342 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
1343 EXPECT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1348 // Tests a successful EXPECT_PRED4 where the
1349 // predicate-formatter is a functor on a built-in type (int).
1350 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1351 EXPECT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1355 // Tests a successful EXPECT_PRED4 where the
1356 // predicate-formatter is a functor on a user-defined type (Bool).
1357 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
1358 EXPECT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1363 // Tests a failed EXPECT_PRED4 where the
1364 // predicate-formatter is a function on a built-in type (int).
1365 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1366 EXPECT_NONFATAL_FAILURE(
1368 EXPECT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1374 // Tests a failed EXPECT_PRED4 where the
1375 // predicate-formatter is a function on a user-defined type (Bool).
1376 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
1377 EXPECT_NONFATAL_FAILURE(
1379 EXPECT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1386 // Tests a failed EXPECT_PRED4 where the
1387 // predicate-formatter is a functor on a built-in type (int).
1388 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1389 EXPECT_NONFATAL_FAILURE(
1391 EXPECT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1397 // Tests a failed EXPECT_PRED4 where the
1398 // predicate-formatter is a functor on a user-defined type (Bool).
1399 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
1400 EXPECT_NONFATAL_FAILURE(
1402 EXPECT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1409 // Tests a successful ASSERT_PRED4 where the
1410 // predicate-formatter is a function on a built-in type (int).
1411 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1412 ASSERT_PRED4(PredFunction4Int, ++n1_, ++n2_, ++n3_, ++n4_);
1416 // Tests a successful ASSERT_PRED4 where the
1417 // predicate-formatter is a function on a user-defined type (Bool).
1418 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
1419 ASSERT_PRED4(PredFunction4Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1424 // Tests a successful ASSERT_PRED4 where the
1425 // predicate-formatter is a functor on a built-in type (int).
1426 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1427 ASSERT_PRED4(PredFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1431 // Tests a successful ASSERT_PRED4 where the
1432 // predicate-formatter is a functor on a user-defined type (Bool).
1433 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
1434 ASSERT_PRED4(PredFunctor4(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1439 // Tests a failed ASSERT_PRED4 where the
1440 // predicate-formatter is a function on a built-in type (int).
1441 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1442 expected_to_finish_ = false;
1443 EXPECT_FATAL_FAILURE(
1445 ASSERT_PRED4(PredFunction4Int, n1_++, n2_++, n3_++, n4_++);
1451 // Tests a failed ASSERT_PRED4 where the
1452 // predicate-formatter is a function on a user-defined type (Bool).
1453 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
1454 expected_to_finish_ = false;
1455 EXPECT_FATAL_FAILURE(
1457 ASSERT_PRED4(PredFunction4Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1464 // Tests a failed ASSERT_PRED4 where the
1465 // predicate-formatter is a functor on a built-in type (int).
1466 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1467 expected_to_finish_ = false;
1468 EXPECT_FATAL_FAILURE(
1470 ASSERT_PRED4(PredFunctor4(), n1_++, n2_++, n3_++, n4_++);
1476 // Tests a failed ASSERT_PRED4 where the
1477 // predicate-formatter is a functor on a user-defined type (Bool).
1478 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
1479 expected_to_finish_ = false;
1480 EXPECT_FATAL_FAILURE(
1482 ASSERT_PRED4(PredFunctor4(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1489 // Tests a successful EXPECT_PRED_FORMAT4 where the
1490 // predicate-formatter is a function on a built-in type (int).
1491 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1492 EXPECT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1496 // Tests a successful EXPECT_PRED_FORMAT4 where the
1497 // predicate-formatter is a function on a user-defined type (Bool).
1498 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1499 EXPECT_PRED_FORMAT4(PredFormatFunction4, Bool(++n1_), Bool(++n2_),
1500 Bool(++n3_), Bool(++n4_));
1504 // Tests a successful EXPECT_PRED_FORMAT4 where the
1505 // predicate-formatter is a functor on a built-in type (int).
1506 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1507 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1511 // Tests a successful EXPECT_PRED_FORMAT4 where the
1512 // predicate-formatter is a functor on a user-defined type (Bool).
1513 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1514 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), Bool(++n1_), Bool(++n2_),
1515 Bool(++n3_), Bool(++n4_));
1519 // Tests a failed EXPECT_PRED_FORMAT4 where the
1520 // predicate-formatter is a function on a built-in type (int).
1521 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1522 EXPECT_NONFATAL_FAILURE(
1524 EXPECT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1530 // Tests a failed EXPECT_PRED_FORMAT4 where the
1531 // predicate-formatter is a function on a user-defined type (Bool).
1532 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1533 EXPECT_NONFATAL_FAILURE(
1535 EXPECT_PRED_FORMAT4(PredFormatFunction4, Bool(n1_++), Bool(n2_++),
1536 Bool(n3_++), Bool(n4_++));
1542 // Tests a failed EXPECT_PRED_FORMAT4 where the
1543 // predicate-formatter is a functor on a built-in type (int).
1544 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1545 EXPECT_NONFATAL_FAILURE(
1547 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1553 // Tests a failed EXPECT_PRED_FORMAT4 where the
1554 // predicate-formatter is a functor on a user-defined type (Bool).
1555 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1556 EXPECT_NONFATAL_FAILURE(
1558 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), Bool(n1_++), Bool(n2_++),
1559 Bool(n3_++), Bool(n4_++));
1565 // Tests a successful ASSERT_PRED_FORMAT4 where the
1566 // predicate-formatter is a function on a built-in type (int).
1567 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1568 ASSERT_PRED_FORMAT4(PredFormatFunction4, ++n1_, ++n2_, ++n3_, ++n4_);
1572 // Tests a successful ASSERT_PRED_FORMAT4 where the
1573 // predicate-formatter is a function on a user-defined type (Bool).
1574 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1575 ASSERT_PRED_FORMAT4(PredFormatFunction4, Bool(++n1_), Bool(++n2_),
1576 Bool(++n3_), Bool(++n4_));
1580 // Tests a successful ASSERT_PRED_FORMAT4 where the
1581 // predicate-formatter is a functor on a built-in type (int).
1582 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1583 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), ++n1_, ++n2_, ++n3_, ++n4_);
1587 // Tests a successful ASSERT_PRED_FORMAT4 where the
1588 // predicate-formatter is a functor on a user-defined type (Bool).
1589 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1590 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), Bool(++n1_), Bool(++n2_),
1591 Bool(++n3_), Bool(++n4_));
1595 // Tests a failed ASSERT_PRED_FORMAT4 where the
1596 // predicate-formatter is a function on a built-in type (int).
1597 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1598 expected_to_finish_ = false;
1599 EXPECT_FATAL_FAILURE(
1601 ASSERT_PRED_FORMAT4(PredFormatFunction4, n1_++, n2_++, n3_++, n4_++);
1607 // Tests a failed ASSERT_PRED_FORMAT4 where the
1608 // predicate-formatter is a function on a user-defined type (Bool).
1609 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1610 expected_to_finish_ = false;
1611 EXPECT_FATAL_FAILURE(
1613 ASSERT_PRED_FORMAT4(PredFormatFunction4, Bool(n1_++), Bool(n2_++),
1614 Bool(n3_++), Bool(n4_++));
1620 // Tests a failed ASSERT_PRED_FORMAT4 where the
1621 // predicate-formatter is a functor on a built-in type (int).
1622 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1623 expected_to_finish_ = false;
1624 EXPECT_FATAL_FAILURE(
1626 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), n1_++, n2_++, n3_++, n4_++);
1632 // Tests a failed ASSERT_PRED_FORMAT4 where the
1633 // predicate-formatter is a functor on a user-defined type (Bool).
1634 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1635 expected_to_finish_ = false;
1636 EXPECT_FATAL_FAILURE(
1638 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), Bool(n1_++), Bool(n2_++),
1639 Bool(n3_++), Bool(n4_++));
1644 // Sample functions/functors for testing 5-ary predicate assertions.
1646 // A 5-ary predicate function.
1647 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1648 bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
1649 return v1 + v2 + v3 + v4 + v5 > 0;
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.
1654 bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
1655 return v1 + v2 + v3 + v4 + v5 > 0;
1657 bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
1658 return v1 + v2 + v3 + v4 + v5 > 0;
1661 // A 5-ary predicate functor.
1662 struct PredFunctor5 {
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,
1666 return v1 + v2 + v3 + v4 + v5 > 0;
1670 // A 5-ary predicate-formatter function.
1671 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1672 testing::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();
1679 return testing::AssertionFailure()
1680 << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
1681 << " is expected to be positive, but evaluates to "
1682 << v1 + v2 + v3 + v4 + v5 << ".";
1685 // A 5-ary predicate-formatter functor.
1686 struct PredFormatFunctor5 {
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);
1697 // Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
1699 class Predicate5Test : public testing::Test {
1701 void SetUp() override {
1702 expected_to_finish_ = true;
1704 n1_ = n2_ = n3_ = n4_ = n5_ = 0;
1707 void TearDown() override {
1708 // Verifies that each of the predicate's arguments was evaluated
1710 EXPECT_EQ(1, n1_) << "The predicate assertion didn't evaluate argument 2 "
1712 EXPECT_EQ(1, n2_) << "The predicate assertion didn't evaluate argument 3 "
1714 EXPECT_EQ(1, n3_) << "The predicate assertion didn't evaluate argument 4 "
1716 EXPECT_EQ(1, n4_) << "The predicate assertion didn't evaluate argument 5 "
1718 EXPECT_EQ(1, n5_) << "The predicate assertion didn't evaluate argument 6 "
1721 // Verifies that the control flow in the test function is expected.
1722 if (expected_to_finish_ && !finished_) {
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 "
1730 // true if and only if the test function is expected to run to finish.
1731 static bool expected_to_finish_;
1733 // true if and only if the test function did run to finish.
1734 static bool finished_;
1743 bool Predicate5Test::expected_to_finish_;
1744 bool Predicate5Test::finished_;
1745 int Predicate5Test::n1_;
1746 int Predicate5Test::n2_;
1747 int Predicate5Test::n3_;
1748 int Predicate5Test::n4_;
1749 int Predicate5Test::n5_;
1751 typedef Predicate5Test EXPECT_PRED_FORMAT5Test;
1752 typedef Predicate5Test ASSERT_PRED_FORMAT5Test;
1753 typedef Predicate5Test EXPECT_PRED5Test;
1754 typedef Predicate5Test ASSERT_PRED5Test;
1756 // Tests a successful EXPECT_PRED5 where the
1757 // predicate-formatter is a function on a built-in type (int).
1758 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1759 EXPECT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1763 // Tests a successful EXPECT_PRED5 where the
1764 // predicate-formatter is a function on a user-defined type (Bool).
1765 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
1766 EXPECT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1767 Bool(++n4_), Bool(++n5_));
1771 // Tests a successful EXPECT_PRED5 where the
1772 // predicate-formatter is a functor on a built-in type (int).
1773 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1774 EXPECT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1778 // Tests a successful EXPECT_PRED5 where the
1779 // predicate-formatter is a functor on a user-defined type (Bool).
1780 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
1781 EXPECT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1782 Bool(++n4_), Bool(++n5_));
1786 // Tests a failed EXPECT_PRED5 where the
1787 // predicate-formatter is a function on a built-in type (int).
1788 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1789 EXPECT_NONFATAL_FAILURE(
1791 EXPECT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1797 // Tests a failed EXPECT_PRED5 where the
1798 // predicate-formatter is a function on a user-defined type (Bool).
1799 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
1800 EXPECT_NONFATAL_FAILURE(
1802 EXPECT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1803 Bool(n4_++), Bool(n5_++));
1809 // Tests a failed EXPECT_PRED5 where the
1810 // predicate-formatter is a functor on a built-in type (int).
1811 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1812 EXPECT_NONFATAL_FAILURE(
1814 EXPECT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1820 // Tests a failed EXPECT_PRED5 where the
1821 // predicate-formatter is a functor on a user-defined type (Bool).
1822 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
1823 EXPECT_NONFATAL_FAILURE(
1825 EXPECT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1826 Bool(n4_++), Bool(n5_++));
1832 // Tests a successful ASSERT_PRED5 where the
1833 // predicate-formatter is a function on a built-in type (int).
1834 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
1835 ASSERT_PRED5(PredFunction5Int, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1839 // Tests a successful ASSERT_PRED5 where the
1840 // predicate-formatter is a function on a user-defined type (Bool).
1841 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
1842 ASSERT_PRED5(PredFunction5Bool, Bool(++n1_), Bool(++n2_), Bool(++n3_),
1843 Bool(++n4_), Bool(++n5_));
1847 // Tests a successful ASSERT_PRED5 where the
1848 // predicate-formatter is a functor on a built-in type (int).
1849 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
1850 ASSERT_PRED5(PredFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1854 // Tests a successful ASSERT_PRED5 where the
1855 // predicate-formatter is a functor on a user-defined type (Bool).
1856 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
1857 ASSERT_PRED5(PredFunctor5(), Bool(++n1_), Bool(++n2_), Bool(++n3_),
1858 Bool(++n4_), Bool(++n5_));
1862 // Tests a failed ASSERT_PRED5 where the
1863 // predicate-formatter is a function on a built-in type (int).
1864 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
1865 expected_to_finish_ = false;
1866 EXPECT_FATAL_FAILURE(
1868 ASSERT_PRED5(PredFunction5Int, n1_++, n2_++, n3_++, n4_++, n5_++);
1874 // Tests a failed ASSERT_PRED5 where the
1875 // predicate-formatter is a function on a user-defined type (Bool).
1876 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
1877 expected_to_finish_ = false;
1878 EXPECT_FATAL_FAILURE(
1880 ASSERT_PRED5(PredFunction5Bool, Bool(n1_++), Bool(n2_++), Bool(n3_++),
1881 Bool(n4_++), Bool(n5_++));
1887 // Tests a failed ASSERT_PRED5 where the
1888 // predicate-formatter is a functor on a built-in type (int).
1889 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
1890 expected_to_finish_ = false;
1891 EXPECT_FATAL_FAILURE(
1893 ASSERT_PRED5(PredFunctor5(), n1_++, n2_++, n3_++, n4_++, n5_++);
1899 // Tests a failed ASSERT_PRED5 where the
1900 // predicate-formatter is a functor on a user-defined type (Bool).
1901 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
1902 expected_to_finish_ = false;
1903 EXPECT_FATAL_FAILURE(
1905 ASSERT_PRED5(PredFunctor5(), Bool(n1_++), Bool(n2_++), Bool(n3_++),
1906 Bool(n4_++), Bool(n5_++));
1912 // Tests a successful EXPECT_PRED_FORMAT5 where the
1913 // predicate-formatter is a function on a built-in type (int).
1914 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1915 EXPECT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1919 // Tests a successful EXPECT_PRED_FORMAT5 where the
1920 // predicate-formatter is a function on a user-defined type (Bool).
1921 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
1922 EXPECT_PRED_FORMAT5(PredFormatFunction5, Bool(++n1_), Bool(++n2_),
1923 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1927 // Tests a successful EXPECT_PRED_FORMAT5 where the
1928 // predicate-formatter is a functor on a built-in type (int).
1929 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
1930 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1934 // Tests a successful EXPECT_PRED_FORMAT5 where the
1935 // predicate-formatter is a functor on a user-defined type (Bool).
1936 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
1937 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), Bool(++n1_), Bool(++n2_),
1938 Bool(++n3_), Bool(++n4_), Bool(++n5_));
1942 // Tests a failed EXPECT_PRED_FORMAT5 where the
1943 // predicate-formatter is a function on a built-in type (int).
1944 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
1945 EXPECT_NONFATAL_FAILURE(
1947 EXPECT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
1954 // Tests a failed EXPECT_PRED_FORMAT5 where the
1955 // predicate-formatter is a function on a user-defined type (Bool).
1956 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
1957 EXPECT_NONFATAL_FAILURE(
1959 EXPECT_PRED_FORMAT5(PredFormatFunction5, Bool(n1_++), Bool(n2_++),
1960 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1966 // Tests a failed EXPECT_PRED_FORMAT5 where the
1967 // predicate-formatter is a functor on a built-in type (int).
1968 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
1969 EXPECT_NONFATAL_FAILURE(
1971 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
1978 // Tests a failed EXPECT_PRED_FORMAT5 where the
1979 // predicate-formatter is a functor on a user-defined type (Bool).
1980 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
1981 EXPECT_NONFATAL_FAILURE(
1983 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), Bool(n1_++), Bool(n2_++),
1984 Bool(n3_++), Bool(n4_++), Bool(n5_++));
1990 // Tests a successful ASSERT_PRED_FORMAT5 where the
1991 // predicate-formatter is a function on a built-in type (int).
1992 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
1993 ASSERT_PRED_FORMAT5(PredFormatFunction5, ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
1997 // Tests a successful ASSERT_PRED_FORMAT5 where the
1998 // predicate-formatter is a function on a user-defined type (Bool).
1999 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
2000 ASSERT_PRED_FORMAT5(PredFormatFunction5, Bool(++n1_), Bool(++n2_),
2001 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2005 // Tests a successful ASSERT_PRED_FORMAT5 where the
2006 // predicate-formatter is a functor on a built-in type (int).
2007 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
2008 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), ++n1_, ++n2_, ++n3_, ++n4_, ++n5_);
2012 // Tests a successful ASSERT_PRED_FORMAT5 where the
2013 // predicate-formatter is a functor on a user-defined type (Bool).
2014 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
2015 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), Bool(++n1_), Bool(++n2_),
2016 Bool(++n3_), Bool(++n4_), Bool(++n5_));
2020 // Tests a failed ASSERT_PRED_FORMAT5 where the
2021 // predicate-formatter is a function on a built-in type (int).
2022 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
2023 expected_to_finish_ = false;
2024 EXPECT_FATAL_FAILURE(
2026 ASSERT_PRED_FORMAT5(PredFormatFunction5, n1_++, n2_++, n3_++, n4_++,
2033 // Tests a failed ASSERT_PRED_FORMAT5 where the
2034 // predicate-formatter is a function on a user-defined type (Bool).
2035 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
2036 expected_to_finish_ = false;
2037 EXPECT_FATAL_FAILURE(
2039 ASSERT_PRED_FORMAT5(PredFormatFunction5, Bool(n1_++), Bool(n2_++),
2040 Bool(n3_++), Bool(n4_++), Bool(n5_++));
2046 // Tests a failed ASSERT_PRED_FORMAT5 where the
2047 // predicate-formatter is a functor on a built-in type (int).
2048 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
2049 expected_to_finish_ = false;
2050 EXPECT_FATAL_FAILURE(
2052 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), n1_++, n2_++, n3_++, n4_++,
2059 // Tests a failed ASSERT_PRED_FORMAT5 where the
2060 // predicate-formatter is a functor on a user-defined type (Bool).
2061 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
2062 expected_to_finish_ = false;
2063 EXPECT_FATAL_FAILURE(
2065 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), Bool(n1_++), Bool(n2_++),
2066 Bool(n3_++), Bool(n4_++), Bool(n5_++));