tesseract v5.3.3.20231005
gtest_pred_impl_unittest.cc
Go to the documentation of this file.
1// Copyright 2006, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30// This file is AUTOMATICALLY GENERATED on 11/05/2019 by command
31// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND!
32
33// Regression test for gtest_pred_impl.h
34//
35// This file is generated by a script and quite long. If you intend to
36// learn how Google Test works by reading its unit tests, read
37// gtest_unittest.cc instead.
38//
39// This is intended as a regression test for the Google Test predicate
40// assertions. We compile it as part of the gtest_unittest target
41// only to keep the implementation tidy and compact, as it is quite
42// involved to set up the stage for testing Google Test using Google
43// Test itself.
44//
45// Currently, gtest_unittest takes ~11 seconds to run in the testing
46// daemon. In the future, if it grows too large and needs much more
47// time to finish, we should consider separating this file into a
48// stand-alone regression test.
49
50#include <iostream>
51
52#include "gtest/gtest.h"
53#include "gtest/gtest-spi.h"
54
55// A user-defined data type.
56struct Bool {
57 explicit Bool(int val) : value(val != 0) {}
58
59 bool operator>(int n) const { return value > Bool(n).value; }
60
61 Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
62
63 bool operator==(const Bool& rhs) const { return value == rhs.value; }
64
65 bool value;
66};
67
68// Enables Bool to be used in assertions.
69std::ostream& operator<<(std::ostream& os, const Bool& x) {
70 return os << (x.value ? "true" : "false");
71}
72
73// Sample functions/functors for testing unary predicate assertions.
74
75// A unary predicate function.
76template <typename T1>
77bool PredFunction1(T1 v1) {
78 return v1 > 0;
79}
80
81// The following two functions are needed because a compiler doesn't have
82// a context yet to know which template function must be instantiated.
83bool PredFunction1Int(int v1) {
84 return v1 > 0;
85}
87 return v1 > 0;
88}
89
90// A unary predicate functor.
92 template <typename T1>
93 bool operator()(const T1& v1) {
94 return v1 > 0;
95 }
96};
97
98// A unary predicate-formatter function.
99template <typename T1>
100testing::AssertionResult PredFormatFunction1(const char* e1,
101 const T1& v1) {
102 if (PredFunction1(v1))
104
106 << e1
107 << " is expected to be positive, but evaluates to "
108 << v1 << ".";
109}
110
111// A unary predicate-formatter functor.
113 template <typename T1>
114 testing::AssertionResult operator()(const char* e1,
115 const T1& v1) const {
116 return PredFormatFunction1(e1, v1);
117 }
118};
119
120// Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
121
123 protected:
124 void SetUp() override {
125 expected_to_finish_ = true;
126 finished_ = false;
127 n1_ = 0;
128 }
129
130 void TearDown() override {
131 // Verifies that each of the predicate's arguments was evaluated
132 // exactly once.
133 EXPECT_EQ(1, n1_) <<
134 "The predicate assertion didn't evaluate argument 2 "
135 "exactly once.";
136
137 // Verifies that the control flow in the test function is expected.
139 FAIL() << "The predicate assertion unexpactedly aborted the test.";
140 } else if (!expected_to_finish_ && finished_) {
141 FAIL() << "The failed predicate assertion didn't abort the test "
142 "as expected.";
143 }
144 }
145
146 // true if and only if the test function is expected to run to finish.
148
149 // true if and only if the test function did run to finish.
150 static bool finished_;
151
152 static int n1_;
153};
154
158
163
164// Tests a successful EXPECT_PRED1 where the
165// predicate-formatter is a function on a built-in type (int).
166TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
168 ++n1_);
169 finished_ = true;
170}
171
172// Tests a successful EXPECT_PRED1 where the
173// predicate-formatter is a function on a user-defined type (Bool).
174TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
176 Bool(++n1_));
177 finished_ = true;
178}
179
180// Tests a successful EXPECT_PRED1 where the
181// predicate-formatter is a functor on a built-in type (int).
182TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
184 ++n1_);
185 finished_ = true;
186}
187
188// Tests a successful EXPECT_PRED1 where the
189// predicate-formatter is a functor on a user-defined type (Bool).
190TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
192 Bool(++n1_));
193 finished_ = true;
194}
195
196// Tests a failed EXPECT_PRED1 where the
197// predicate-formatter is a function on a built-in type (int).
198TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
199 EXPECT_NONFATAL_FAILURE({ // NOLINT
201 n1_++);
202 finished_ = true;
203 }, "");
204}
205
206// Tests a failed EXPECT_PRED1 where the
207// predicate-formatter is a function on a user-defined type (Bool).
208TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
209 EXPECT_NONFATAL_FAILURE({ // NOLINT
211 Bool(n1_++));
212 finished_ = true;
213 }, "");
214}
215
216// Tests a failed EXPECT_PRED1 where the
217// predicate-formatter is a functor on a built-in type (int).
218TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
219 EXPECT_NONFATAL_FAILURE({ // NOLINT
221 n1_++);
222 finished_ = true;
223 }, "");
224}
225
226// Tests a failed EXPECT_PRED1 where the
227// predicate-formatter is a functor on a user-defined type (Bool).
228TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
229 EXPECT_NONFATAL_FAILURE({ // NOLINT
231 Bool(n1_++));
232 finished_ = true;
233 }, "");
234}
235
236// Tests a successful ASSERT_PRED1 where the
237// predicate-formatter is a function on a built-in type (int).
238TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
240 ++n1_);
241 finished_ = true;
242}
243
244// Tests a successful ASSERT_PRED1 where the
245// predicate-formatter is a function on a user-defined type (Bool).
246TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
248 Bool(++n1_));
249 finished_ = true;
250}
251
252// Tests a successful ASSERT_PRED1 where the
253// predicate-formatter is a functor on a built-in type (int).
254TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
256 ++n1_);
257 finished_ = true;
258}
259
260// Tests a successful ASSERT_PRED1 where the
261// predicate-formatter is a functor on a user-defined type (Bool).
262TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
264 Bool(++n1_));
265 finished_ = true;
266}
267
268// Tests a failed ASSERT_PRED1 where the
269// predicate-formatter is a function on a built-in type (int).
270TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
271 expected_to_finish_ = false;
272 EXPECT_FATAL_FAILURE({ // NOLINT
274 n1_++);
275 finished_ = true;
276 }, "");
277}
278
279// Tests a failed ASSERT_PRED1 where the
280// predicate-formatter is a function on a user-defined type (Bool).
281TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
282 expected_to_finish_ = false;
283 EXPECT_FATAL_FAILURE({ // NOLINT
285 Bool(n1_++));
286 finished_ = true;
287 }, "");
288}
289
290// Tests a failed ASSERT_PRED1 where the
291// predicate-formatter is a functor on a built-in type (int).
292TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
293 expected_to_finish_ = false;
294 EXPECT_FATAL_FAILURE({ // NOLINT
296 n1_++);
297 finished_ = true;
298 }, "");
299}
300
301// Tests a failed ASSERT_PRED1 where the
302// predicate-formatter is a functor on a user-defined type (Bool).
303TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
304 expected_to_finish_ = false;
305 EXPECT_FATAL_FAILURE({ // NOLINT
307 Bool(n1_++));
308 finished_ = true;
309 }, "");
310}
311
312// Tests a successful EXPECT_PRED_FORMAT1 where the
313// predicate-formatter is a function on a built-in type (int).
314TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
316 ++n1_);
317 finished_ = true;
318}
319
320// Tests a successful EXPECT_PRED_FORMAT1 where the
321// predicate-formatter is a function on a user-defined type (Bool).
322TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
324 Bool(++n1_));
325 finished_ = true;
326}
327
328// Tests a successful EXPECT_PRED_FORMAT1 where the
329// predicate-formatter is a functor on a built-in type (int).
330TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
332 ++n1_);
333 finished_ = true;
334}
335
336// Tests a successful EXPECT_PRED_FORMAT1 where the
337// predicate-formatter is a functor on a user-defined type (Bool).
338TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
340 Bool(++n1_));
341 finished_ = true;
342}
343
344// Tests a failed EXPECT_PRED_FORMAT1 where the
345// predicate-formatter is a function on a built-in type (int).
346TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
347 EXPECT_NONFATAL_FAILURE({ // NOLINT
349 n1_++);
350 finished_ = true;
351 }, "");
352}
353
354// Tests a failed EXPECT_PRED_FORMAT1 where the
355// predicate-formatter is a function on a user-defined type (Bool).
356TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
357 EXPECT_NONFATAL_FAILURE({ // NOLINT
359 Bool(n1_++));
360 finished_ = true;
361 }, "");
362}
363
364// Tests a failed EXPECT_PRED_FORMAT1 where the
365// predicate-formatter is a functor on a built-in type (int).
366TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
367 EXPECT_NONFATAL_FAILURE({ // NOLINT
369 n1_++);
370 finished_ = true;
371 }, "");
372}
373
374// Tests a failed EXPECT_PRED_FORMAT1 where the
375// predicate-formatter is a functor on a user-defined type (Bool).
376TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
377 EXPECT_NONFATAL_FAILURE({ // NOLINT
379 Bool(n1_++));
380 finished_ = true;
381 }, "");
382}
383
384// Tests a successful ASSERT_PRED_FORMAT1 where the
385// predicate-formatter is a function on a built-in type (int).
386TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
388 ++n1_);
389 finished_ = true;
390}
391
392// Tests a successful ASSERT_PRED_FORMAT1 where the
393// predicate-formatter is a function on a user-defined type (Bool).
394TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
396 Bool(++n1_));
397 finished_ = true;
398}
399
400// Tests a successful ASSERT_PRED_FORMAT1 where the
401// predicate-formatter is a functor on a built-in type (int).
402TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
404 ++n1_);
405 finished_ = true;
406}
407
408// Tests a successful ASSERT_PRED_FORMAT1 where the
409// predicate-formatter is a functor on a user-defined type (Bool).
410TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
412 Bool(++n1_));
413 finished_ = true;
414}
415
416// Tests a failed ASSERT_PRED_FORMAT1 where the
417// predicate-formatter is a function on a built-in type (int).
418TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
419 expected_to_finish_ = false;
420 EXPECT_FATAL_FAILURE({ // NOLINT
422 n1_++);
423 finished_ = true;
424 }, "");
425}
426
427// Tests a failed ASSERT_PRED_FORMAT1 where the
428// predicate-formatter is a function on a user-defined type (Bool).
429TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
430 expected_to_finish_ = false;
431 EXPECT_FATAL_FAILURE({ // NOLINT
433 Bool(n1_++));
434 finished_ = true;
435 }, "");
436}
437
438// Tests a failed ASSERT_PRED_FORMAT1 where the
439// predicate-formatter is a functor on a built-in type (int).
440TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
441 expected_to_finish_ = false;
442 EXPECT_FATAL_FAILURE({ // NOLINT
444 n1_++);
445 finished_ = true;
446 }, "");
447}
448
449// Tests a failed ASSERT_PRED_FORMAT1 where the
450// predicate-formatter is a functor on a user-defined type (Bool).
451TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
452 expected_to_finish_ = false;
453 EXPECT_FATAL_FAILURE({ // NOLINT
455 Bool(n1_++));
456 finished_ = true;
457 }, "");
458}
459// Sample functions/functors for testing binary predicate assertions.
460
461// A binary predicate function.
462template <typename T1, typename T2>
463bool PredFunction2(T1 v1, T2 v2) {
464 return v1 + v2 > 0;
465}
466
467// The following two functions are needed because a compiler doesn't have
468// a context yet to know which template function must be instantiated.
469bool PredFunction2Int(int v1, int v2) {
470 return v1 + v2 > 0;
471}
473 return v1 + v2 > 0;
474}
475
476// A binary predicate functor.
478 template <typename T1, typename T2>
479 bool operator()(const T1& v1,
480 const T2& v2) {
481 return v1 + v2 > 0;
482 }
483};
484
485// A binary predicate-formatter function.
486template <typename T1, typename T2>
487testing::AssertionResult PredFormatFunction2(const char* e1,
488 const char* e2,
489 const T1& v1,
490 const T2& v2) {
491 if (PredFunction2(v1, v2))
493
495 << e1 << " + " << e2
496 << " is expected to be positive, but evaluates to "
497 << v1 + v2 << ".";
498}
499
500// A binary predicate-formatter functor.
502 template <typename T1, typename T2>
503 testing::AssertionResult operator()(const char* e1,
504 const char* e2,
505 const T1& v1,
506 const T2& v2) const {
507 return PredFormatFunction2(e1, e2, v1, v2);
508 }
509};
510
511// Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
512
514 protected:
515 void SetUp() override {
516 expected_to_finish_ = true;
517 finished_ = false;
518 n1_ = n2_ = 0;
519 }
520
521 void TearDown() override {
522 // Verifies that each of the predicate's arguments was evaluated
523 // exactly once.
524 EXPECT_EQ(1, n1_) <<
525 "The predicate assertion didn't evaluate argument 2 "
526 "exactly once.";
527 EXPECT_EQ(1, n2_) <<
528 "The predicate assertion didn't evaluate argument 3 "
529 "exactly once.";
530
531 // Verifies that the control flow in the test function is expected.
533 FAIL() << "The predicate assertion unexpactedly aborted the test.";
534 } else if (!expected_to_finish_ && finished_) {
535 FAIL() << "The failed predicate assertion didn't abort the test "
536 "as expected.";
537 }
538 }
539
540 // true if and only if the test function is expected to run to finish.
542
543 // true if and only if the test function did run to finish.
544 static bool finished_;
545
546 static int n1_;
547 static int n2_;
548};
549
554
559
560// Tests a successful EXPECT_PRED2 where the
561// predicate-formatter is a function on a built-in type (int).
562TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
564 ++n1_,
565 ++n2_);
566 finished_ = true;
567}
568
569// Tests a successful EXPECT_PRED2 where the
570// predicate-formatter is a function on a user-defined type (Bool).
571TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
573 Bool(++n1_),
574 Bool(++n2_));
575 finished_ = true;
576}
577
578// Tests a successful EXPECT_PRED2 where the
579// predicate-formatter is a functor on a built-in type (int).
580TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
582 ++n1_,
583 ++n2_);
584 finished_ = true;
585}
586
587// Tests a successful EXPECT_PRED2 where the
588// predicate-formatter is a functor on a user-defined type (Bool).
589TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
591 Bool(++n1_),
592 Bool(++n2_));
593 finished_ = true;
594}
595
596// Tests a failed EXPECT_PRED2 where the
597// predicate-formatter is a function on a built-in type (int).
598TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
599 EXPECT_NONFATAL_FAILURE({ // NOLINT
601 n1_++,
602 n2_++);
603 finished_ = true;
604 }, "");
605}
606
607// Tests a failed EXPECT_PRED2 where the
608// predicate-formatter is a function on a user-defined type (Bool).
609TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
610 EXPECT_NONFATAL_FAILURE({ // NOLINT
612 Bool(n1_++),
613 Bool(n2_++));
614 finished_ = true;
615 }, "");
616}
617
618// Tests a failed EXPECT_PRED2 where the
619// predicate-formatter is a functor on a built-in type (int).
620TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
621 EXPECT_NONFATAL_FAILURE({ // NOLINT
623 n1_++,
624 n2_++);
625 finished_ = true;
626 }, "");
627}
628
629// Tests a failed EXPECT_PRED2 where the
630// predicate-formatter is a functor on a user-defined type (Bool).
631TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
632 EXPECT_NONFATAL_FAILURE({ // NOLINT
634 Bool(n1_++),
635 Bool(n2_++));
636 finished_ = true;
637 }, "");
638}
639
640// Tests a successful ASSERT_PRED2 where the
641// predicate-formatter is a function on a built-in type (int).
642TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
644 ++n1_,
645 ++n2_);
646 finished_ = true;
647}
648
649// Tests a successful ASSERT_PRED2 where the
650// predicate-formatter is a function on a user-defined type (Bool).
651TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
653 Bool(++n1_),
654 Bool(++n2_));
655 finished_ = true;
656}
657
658// Tests a successful ASSERT_PRED2 where the
659// predicate-formatter is a functor on a built-in type (int).
660TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
662 ++n1_,
663 ++n2_);
664 finished_ = true;
665}
666
667// Tests a successful ASSERT_PRED2 where the
668// predicate-formatter is a functor on a user-defined type (Bool).
669TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
671 Bool(++n1_),
672 Bool(++n2_));
673 finished_ = true;
674}
675
676// Tests a failed ASSERT_PRED2 where the
677// predicate-formatter is a function on a built-in type (int).
678TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
679 expected_to_finish_ = false;
680 EXPECT_FATAL_FAILURE({ // NOLINT
682 n1_++,
683 n2_++);
684 finished_ = true;
685 }, "");
686}
687
688// Tests a failed ASSERT_PRED2 where the
689// predicate-formatter is a function on a user-defined type (Bool).
690TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
691 expected_to_finish_ = false;
692 EXPECT_FATAL_FAILURE({ // NOLINT
694 Bool(n1_++),
695 Bool(n2_++));
696 finished_ = true;
697 }, "");
698}
699
700// Tests a failed ASSERT_PRED2 where the
701// predicate-formatter is a functor on a built-in type (int).
702TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
703 expected_to_finish_ = false;
704 EXPECT_FATAL_FAILURE({ // NOLINT
706 n1_++,
707 n2_++);
708 finished_ = true;
709 }, "");
710}
711
712// Tests a failed ASSERT_PRED2 where the
713// predicate-formatter is a functor on a user-defined type (Bool).
714TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
715 expected_to_finish_ = false;
716 EXPECT_FATAL_FAILURE({ // NOLINT
718 Bool(n1_++),
719 Bool(n2_++));
720 finished_ = true;
721 }, "");
722}
723
724// Tests a successful EXPECT_PRED_FORMAT2 where the
725// predicate-formatter is a function on a built-in type (int).
726TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
728 ++n1_,
729 ++n2_);
730 finished_ = true;
731}
732
733// Tests a successful EXPECT_PRED_FORMAT2 where the
734// predicate-formatter is a function on a user-defined type (Bool).
735TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
737 Bool(++n1_),
738 Bool(++n2_));
739 finished_ = true;
740}
741
742// Tests a successful EXPECT_PRED_FORMAT2 where the
743// predicate-formatter is a functor on a built-in type (int).
744TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
746 ++n1_,
747 ++n2_);
748 finished_ = true;
749}
750
751// Tests a successful EXPECT_PRED_FORMAT2 where the
752// predicate-formatter is a functor on a user-defined type (Bool).
753TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
755 Bool(++n1_),
756 Bool(++n2_));
757 finished_ = true;
758}
759
760// Tests a failed EXPECT_PRED_FORMAT2 where the
761// predicate-formatter is a function on a built-in type (int).
762TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
763 EXPECT_NONFATAL_FAILURE({ // NOLINT
765 n1_++,
766 n2_++);
767 finished_ = true;
768 }, "");
769}
770
771// Tests a failed EXPECT_PRED_FORMAT2 where the
772// predicate-formatter is a function on a user-defined type (Bool).
773TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
774 EXPECT_NONFATAL_FAILURE({ // NOLINT
776 Bool(n1_++),
777 Bool(n2_++));
778 finished_ = true;
779 }, "");
780}
781
782// Tests a failed EXPECT_PRED_FORMAT2 where the
783// predicate-formatter is a functor on a built-in type (int).
784TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
785 EXPECT_NONFATAL_FAILURE({ // NOLINT
787 n1_++,
788 n2_++);
789 finished_ = true;
790 }, "");
791}
792
793// Tests a failed EXPECT_PRED_FORMAT2 where the
794// predicate-formatter is a functor on a user-defined type (Bool).
795TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
796 EXPECT_NONFATAL_FAILURE({ // NOLINT
798 Bool(n1_++),
799 Bool(n2_++));
800 finished_ = true;
801 }, "");
802}
803
804// Tests a successful ASSERT_PRED_FORMAT2 where the
805// predicate-formatter is a function on a built-in type (int).
806TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
808 ++n1_,
809 ++n2_);
810 finished_ = true;
811}
812
813// Tests a successful ASSERT_PRED_FORMAT2 where the
814// predicate-formatter is a function on a user-defined type (Bool).
815TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
817 Bool(++n1_),
818 Bool(++n2_));
819 finished_ = true;
820}
821
822// Tests a successful ASSERT_PRED_FORMAT2 where the
823// predicate-formatter is a functor on a built-in type (int).
824TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
826 ++n1_,
827 ++n2_);
828 finished_ = true;
829}
830
831// Tests a successful ASSERT_PRED_FORMAT2 where the
832// predicate-formatter is a functor on a user-defined type (Bool).
833TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
835 Bool(++n1_),
836 Bool(++n2_));
837 finished_ = true;
838}
839
840// Tests a failed ASSERT_PRED_FORMAT2 where the
841// predicate-formatter is a function on a built-in type (int).
842TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
843 expected_to_finish_ = false;
844 EXPECT_FATAL_FAILURE({ // NOLINT
846 n1_++,
847 n2_++);
848 finished_ = true;
849 }, "");
850}
851
852// Tests a failed ASSERT_PRED_FORMAT2 where the
853// predicate-formatter is a function on a user-defined type (Bool).
854TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
855 expected_to_finish_ = false;
856 EXPECT_FATAL_FAILURE({ // NOLINT
858 Bool(n1_++),
859 Bool(n2_++));
860 finished_ = true;
861 }, "");
862}
863
864// Tests a failed ASSERT_PRED_FORMAT2 where the
865// predicate-formatter is a functor on a built-in type (int).
866TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
867 expected_to_finish_ = false;
868 EXPECT_FATAL_FAILURE({ // NOLINT
870 n1_++,
871 n2_++);
872 finished_ = true;
873 }, "");
874}
875
876// Tests a failed ASSERT_PRED_FORMAT2 where the
877// predicate-formatter is a functor on a user-defined type (Bool).
878TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
879 expected_to_finish_ = false;
880 EXPECT_FATAL_FAILURE({ // NOLINT
882 Bool(n1_++),
883 Bool(n2_++));
884 finished_ = true;
885 }, "");
886}
887// Sample functions/functors for testing ternary predicate assertions.
888
889// A ternary predicate function.
890template <typename T1, typename T2, typename T3>
891bool PredFunction3(T1 v1, T2 v2, T3 v3) {
892 return v1 + v2 + v3 > 0;
893}
894
895// The following two functions are needed because a compiler doesn't have
896// a context yet to know which template function must be instantiated.
897bool PredFunction3Int(int v1, int v2, int v3) {
898 return v1 + v2 + v3 > 0;
899}
900bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) {
901 return v1 + v2 + v3 > 0;
902}
903
904// A ternary predicate functor.
906 template <typename T1, typename T2, typename T3>
907 bool operator()(const T1& v1,
908 const T2& v2,
909 const T3& v3) {
910 return v1 + v2 + v3 > 0;
911 }
912};
913
914// A ternary predicate-formatter function.
915template <typename T1, typename T2, typename T3>
916testing::AssertionResult PredFormatFunction3(const char* e1,
917 const char* e2,
918 const char* e3,
919 const T1& v1,
920 const T2& v2,
921 const T3& v3) {
922 if (PredFunction3(v1, v2, v3))
924
926 << e1 << " + " << e2 << " + " << e3
927 << " is expected to be positive, but evaluates to "
928 << v1 + v2 + v3 << ".";
929}
930
931// A ternary predicate-formatter functor.
933 template <typename T1, typename T2, typename T3>
934 testing::AssertionResult operator()(const char* e1,
935 const char* e2,
936 const char* e3,
937 const T1& v1,
938 const T2& v2,
939 const T3& v3) const {
940 return PredFormatFunction3(e1, e2, e3, v1, v2, v3);
941 }
942};
943
944// Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
945
947 protected:
948 void SetUp() override {
949 expected_to_finish_ = true;
950 finished_ = false;
951 n1_ = n2_ = n3_ = 0;
952 }
953
954 void TearDown() override {
955 // Verifies that each of the predicate's arguments was evaluated
956 // exactly once.
957 EXPECT_EQ(1, n1_) <<
958 "The predicate assertion didn't evaluate argument 2 "
959 "exactly once.";
960 EXPECT_EQ(1, n2_) <<
961 "The predicate assertion didn't evaluate argument 3 "
962 "exactly once.";
963 EXPECT_EQ(1, n3_) <<
964 "The predicate assertion didn't evaluate argument 4 "
965 "exactly once.";
966
967 // Verifies that the control flow in the test function is expected.
969 FAIL() << "The predicate assertion unexpactedly aborted the test.";
970 } else if (!expected_to_finish_ && finished_) {
971 FAIL() << "The failed predicate assertion didn't abort the test "
972 "as expected.";
973 }
974 }
975
976 // true if and only if the test function is expected to run to finish.
978
979 // true if and only if the test function did run to finish.
980 static bool finished_;
981
982 static int n1_;
983 static int n2_;
984 static int n3_;
985};
986
992
997
998// Tests a successful EXPECT_PRED3 where the
999// predicate-formatter is a function on a built-in type (int).
1000TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
1002 ++n1_,
1003 ++n2_,
1004 ++n3_);
1005 finished_ = true;
1006}
1007
1008// Tests a successful EXPECT_PRED3 where the
1009// predicate-formatter is a function on a user-defined type (Bool).
1010TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
1012 Bool(++n1_),
1013 Bool(++n2_),
1014 Bool(++n3_));
1015 finished_ = true;
1016}
1017
1018// Tests a successful EXPECT_PRED3 where the
1019// predicate-formatter is a functor on a built-in type (int).
1020TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
1022 ++n1_,
1023 ++n2_,
1024 ++n3_);
1025 finished_ = true;
1026}
1027
1028// Tests a successful EXPECT_PRED3 where the
1029// predicate-formatter is a functor on a user-defined type (Bool).
1030TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
1032 Bool(++n1_),
1033 Bool(++n2_),
1034 Bool(++n3_));
1035 finished_ = true;
1036}
1037
1038// Tests a failed EXPECT_PRED3 where the
1039// predicate-formatter is a function on a built-in type (int).
1040TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
1041 EXPECT_NONFATAL_FAILURE({ // NOLINT
1043 n1_++,
1044 n2_++,
1045 n3_++);
1046 finished_ = true;
1047 }, "");
1048}
1049
1050// Tests a failed EXPECT_PRED3 where the
1051// predicate-formatter is a function on a user-defined type (Bool).
1052TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
1053 EXPECT_NONFATAL_FAILURE({ // NOLINT
1055 Bool(n1_++),
1056 Bool(n2_++),
1057 Bool(n3_++));
1058 finished_ = true;
1059 }, "");
1060}
1061
1062// Tests a failed EXPECT_PRED3 where the
1063// predicate-formatter is a functor on a built-in type (int).
1064TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
1065 EXPECT_NONFATAL_FAILURE({ // NOLINT
1067 n1_++,
1068 n2_++,
1069 n3_++);
1070 finished_ = true;
1071 }, "");
1072}
1073
1074// Tests a failed EXPECT_PRED3 where the
1075// predicate-formatter is a functor on a user-defined type (Bool).
1076TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
1077 EXPECT_NONFATAL_FAILURE({ // NOLINT
1079 Bool(n1_++),
1080 Bool(n2_++),
1081 Bool(n3_++));
1082 finished_ = true;
1083 }, "");
1084}
1085
1086// Tests a successful ASSERT_PRED3 where the
1087// predicate-formatter is a function on a built-in type (int).
1088TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
1090 ++n1_,
1091 ++n2_,
1092 ++n3_);
1093 finished_ = true;
1094}
1095
1096// Tests a successful ASSERT_PRED3 where the
1097// predicate-formatter is a function on a user-defined type (Bool).
1098TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
1100 Bool(++n1_),
1101 Bool(++n2_),
1102 Bool(++n3_));
1103 finished_ = true;
1104}
1105
1106// Tests a successful ASSERT_PRED3 where the
1107// predicate-formatter is a functor on a built-in type (int).
1108TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
1110 ++n1_,
1111 ++n2_,
1112 ++n3_);
1113 finished_ = true;
1114}
1115
1116// Tests a successful ASSERT_PRED3 where the
1117// predicate-formatter is a functor on a user-defined type (Bool).
1118TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
1120 Bool(++n1_),
1121 Bool(++n2_),
1122 Bool(++n3_));
1123 finished_ = true;
1124}
1125
1126// Tests a failed ASSERT_PRED3 where the
1127// predicate-formatter is a function on a built-in type (int).
1128TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
1129 expected_to_finish_ = false;
1130 EXPECT_FATAL_FAILURE({ // NOLINT
1132 n1_++,
1133 n2_++,
1134 n3_++);
1135 finished_ = true;
1136 }, "");
1137}
1138
1139// Tests a failed ASSERT_PRED3 where the
1140// predicate-formatter is a function on a user-defined type (Bool).
1141TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
1142 expected_to_finish_ = false;
1143 EXPECT_FATAL_FAILURE({ // NOLINT
1145 Bool(n1_++),
1146 Bool(n2_++),
1147 Bool(n3_++));
1148 finished_ = true;
1149 }, "");
1150}
1151
1152// Tests a failed ASSERT_PRED3 where the
1153// predicate-formatter is a functor on a built-in type (int).
1154TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
1155 expected_to_finish_ = false;
1156 EXPECT_FATAL_FAILURE({ // NOLINT
1158 n1_++,
1159 n2_++,
1160 n3_++);
1161 finished_ = true;
1162 }, "");
1163}
1164
1165// Tests a failed ASSERT_PRED3 where the
1166// predicate-formatter is a functor on a user-defined type (Bool).
1167TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
1168 expected_to_finish_ = false;
1169 EXPECT_FATAL_FAILURE({ // NOLINT
1171 Bool(n1_++),
1172 Bool(n2_++),
1173 Bool(n3_++));
1174 finished_ = true;
1175 }, "");
1176}
1177
1178// Tests a successful EXPECT_PRED_FORMAT3 where the
1179// predicate-formatter is a function on a built-in type (int).
1180TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1182 ++n1_,
1183 ++n2_,
1184 ++n3_);
1185 finished_ = true;
1186}
1187
1188// Tests a successful EXPECT_PRED_FORMAT3 where the
1189// predicate-formatter is a function on a user-defined type (Bool).
1190TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1192 Bool(++n1_),
1193 Bool(++n2_),
1194 Bool(++n3_));
1195 finished_ = true;
1196}
1197
1198// Tests a successful EXPECT_PRED_FORMAT3 where the
1199// predicate-formatter is a functor on a built-in type (int).
1200TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1202 ++n1_,
1203 ++n2_,
1204 ++n3_);
1205 finished_ = true;
1206}
1207
1208// Tests a successful EXPECT_PRED_FORMAT3 where the
1209// predicate-formatter is a functor on a user-defined type (Bool).
1210TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1212 Bool(++n1_),
1213 Bool(++n2_),
1214 Bool(++n3_));
1215 finished_ = true;
1216}
1217
1218// Tests a failed EXPECT_PRED_FORMAT3 where the
1219// predicate-formatter is a function on a built-in type (int).
1220TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1221 EXPECT_NONFATAL_FAILURE({ // NOLINT
1223 n1_++,
1224 n2_++,
1225 n3_++);
1226 finished_ = true;
1227 }, "");
1228}
1229
1230// Tests a failed EXPECT_PRED_FORMAT3 where the
1231// predicate-formatter is a function on a user-defined type (Bool).
1232TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1233 EXPECT_NONFATAL_FAILURE({ // NOLINT
1235 Bool(n1_++),
1236 Bool(n2_++),
1237 Bool(n3_++));
1238 finished_ = true;
1239 }, "");
1240}
1241
1242// Tests a failed EXPECT_PRED_FORMAT3 where the
1243// predicate-formatter is a functor on a built-in type (int).
1244TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1245 EXPECT_NONFATAL_FAILURE({ // NOLINT
1247 n1_++,
1248 n2_++,
1249 n3_++);
1250 finished_ = true;
1251 }, "");
1252}
1253
1254// Tests a failed EXPECT_PRED_FORMAT3 where the
1255// predicate-formatter is a functor on a user-defined type (Bool).
1256TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1257 EXPECT_NONFATAL_FAILURE({ // NOLINT
1259 Bool(n1_++),
1260 Bool(n2_++),
1261 Bool(n3_++));
1262 finished_ = true;
1263 }, "");
1264}
1265
1266// Tests a successful ASSERT_PRED_FORMAT3 where the
1267// predicate-formatter is a function on a built-in type (int).
1268TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
1270 ++n1_,
1271 ++n2_,
1272 ++n3_);
1273 finished_ = true;
1274}
1275
1276// Tests a successful ASSERT_PRED_FORMAT3 where the
1277// predicate-formatter is a function on a user-defined type (Bool).
1278TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
1280 Bool(++n1_),
1281 Bool(++n2_),
1282 Bool(++n3_));
1283 finished_ = true;
1284}
1285
1286// Tests a successful ASSERT_PRED_FORMAT3 where the
1287// predicate-formatter is a functor on a built-in type (int).
1288TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
1290 ++n1_,
1291 ++n2_,
1292 ++n3_);
1293 finished_ = true;
1294}
1295
1296// Tests a successful ASSERT_PRED_FORMAT3 where the
1297// predicate-formatter is a functor on a user-defined type (Bool).
1298TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
1300 Bool(++n1_),
1301 Bool(++n2_),
1302 Bool(++n3_));
1303 finished_ = true;
1304}
1305
1306// Tests a failed ASSERT_PRED_FORMAT3 where the
1307// predicate-formatter is a function on a built-in type (int).
1308TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
1309 expected_to_finish_ = false;
1310 EXPECT_FATAL_FAILURE({ // NOLINT
1312 n1_++,
1313 n2_++,
1314 n3_++);
1315 finished_ = true;
1316 }, "");
1317}
1318
1319// Tests a failed ASSERT_PRED_FORMAT3 where the
1320// predicate-formatter is a function on a user-defined type (Bool).
1321TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
1322 expected_to_finish_ = false;
1323 EXPECT_FATAL_FAILURE({ // NOLINT
1325 Bool(n1_++),
1326 Bool(n2_++),
1327 Bool(n3_++));
1328 finished_ = true;
1329 }, "");
1330}
1331
1332// Tests a failed ASSERT_PRED_FORMAT3 where the
1333// predicate-formatter is a functor on a built-in type (int).
1334TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
1335 expected_to_finish_ = false;
1336 EXPECT_FATAL_FAILURE({ // NOLINT
1338 n1_++,
1339 n2_++,
1340 n3_++);
1341 finished_ = true;
1342 }, "");
1343}
1344
1345// Tests a failed ASSERT_PRED_FORMAT3 where the
1346// predicate-formatter is a functor on a user-defined type (Bool).
1347TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
1348 expected_to_finish_ = false;
1349 EXPECT_FATAL_FAILURE({ // NOLINT
1351 Bool(n1_++),
1352 Bool(n2_++),
1353 Bool(n3_++));
1354 finished_ = true;
1355 }, "");
1356}
1357// Sample functions/functors for testing 4-ary predicate assertions.
1358
1359// A 4-ary predicate function.
1360template <typename T1, typename T2, typename T3, typename T4>
1361bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
1362 return v1 + v2 + v3 + v4 > 0;
1363}
1364
1365// The following two functions are needed because a compiler doesn't have
1366// a context yet to know which template function must be instantiated.
1367bool PredFunction4Int(int v1, int v2, int v3, int v4) {
1368 return v1 + v2 + v3 + v4 > 0;
1369}
1370bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
1371 return v1 + v2 + v3 + v4 > 0;
1372}
1373
1374// A 4-ary predicate functor.
1376 template <typename T1, typename T2, typename T3, typename T4>
1377 bool operator()(const T1& v1,
1378 const T2& v2,
1379 const T3& v3,
1380 const T4& v4) {
1381 return v1 + v2 + v3 + v4 > 0;
1382 }
1383};
1384
1385// A 4-ary predicate-formatter function.
1386template <typename T1, typename T2, typename T3, typename T4>
1387testing::AssertionResult PredFormatFunction4(const char* e1,
1388 const char* e2,
1389 const char* e3,
1390 const char* e4,
1391 const T1& v1,
1392 const T2& v2,
1393 const T3& v3,
1394 const T4& v4) {
1395 if (PredFunction4(v1, v2, v3, v4))
1397
1399 << e1 << " + " << e2 << " + " << e3 << " + " << e4
1400 << " is expected to be positive, but evaluates to "
1401 << v1 + v2 + v3 + v4 << ".";
1402}
1403
1404// A 4-ary predicate-formatter functor.
1406 template <typename T1, typename T2, typename T3, typename T4>
1407 testing::AssertionResult operator()(const char* e1,
1408 const char* e2,
1409 const char* e3,
1410 const char* e4,
1411 const T1& v1,
1412 const T2& v2,
1413 const T3& v3,
1414 const T4& v4) const {
1415 return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);
1416 }
1417};
1418
1419// Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
1420
1422 protected:
1423 void SetUp() override {
1424 expected_to_finish_ = true;
1425 finished_ = false;
1426 n1_ = n2_ = n3_ = n4_ = 0;
1427 }
1428
1429 void TearDown() override {
1430 // Verifies that each of the predicate's arguments was evaluated
1431 // exactly once.
1432 EXPECT_EQ(1, n1_) <<
1433 "The predicate assertion didn't evaluate argument 2 "
1434 "exactly once.";
1435 EXPECT_EQ(1, n2_) <<
1436 "The predicate assertion didn't evaluate argument 3 "
1437 "exactly once.";
1438 EXPECT_EQ(1, n3_) <<
1439 "The predicate assertion didn't evaluate argument 4 "
1440 "exactly once.";
1441 EXPECT_EQ(1, n4_) <<
1442 "The predicate assertion didn't evaluate argument 5 "
1443 "exactly once.";
1444
1445 // Verifies that the control flow in the test function is expected.
1447 FAIL() << "The predicate assertion unexpactedly aborted the test.";
1448 } else if (!expected_to_finish_ && finished_) {
1449 FAIL() << "The failed predicate assertion didn't abort the test "
1450 "as expected.";
1451 }
1452 }
1453
1454 // true if and only if the test function is expected to run to finish.
1456
1457 // true if and only if the test function did run to finish.
1458 static bool finished_;
1459
1460 static int n1_;
1461 static int n2_;
1462 static int n3_;
1463 static int n4_;
1464};
1465
1472
1477
1478// Tests a successful EXPECT_PRED4 where the
1479// predicate-formatter is a function on a built-in type (int).
1480TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1482 ++n1_,
1483 ++n2_,
1484 ++n3_,
1485 ++n4_);
1486 finished_ = true;
1487}
1488
1489// Tests a successful EXPECT_PRED4 where the
1490// predicate-formatter is a function on a user-defined type (Bool).
1491TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
1493 Bool(++n1_),
1494 Bool(++n2_),
1495 Bool(++n3_),
1496 Bool(++n4_));
1497 finished_ = true;
1498}
1499
1500// Tests a successful EXPECT_PRED4 where the
1501// predicate-formatter is a functor on a built-in type (int).
1502TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1504 ++n1_,
1505 ++n2_,
1506 ++n3_,
1507 ++n4_);
1508 finished_ = true;
1509}
1510
1511// Tests a successful EXPECT_PRED4 where the
1512// predicate-formatter is a functor on a user-defined type (Bool).
1513TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
1515 Bool(++n1_),
1516 Bool(++n2_),
1517 Bool(++n3_),
1518 Bool(++n4_));
1519 finished_ = true;
1520}
1521
1522// Tests a failed EXPECT_PRED4 where the
1523// predicate-formatter is a function on a built-in type (int).
1524TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1525 EXPECT_NONFATAL_FAILURE({ // NOLINT
1527 n1_++,
1528 n2_++,
1529 n3_++,
1530 n4_++);
1531 finished_ = true;
1532 }, "");
1533}
1534
1535// Tests a failed EXPECT_PRED4 where the
1536// predicate-formatter is a function on a user-defined type (Bool).
1537TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
1538 EXPECT_NONFATAL_FAILURE({ // NOLINT
1540 Bool(n1_++),
1541 Bool(n2_++),
1542 Bool(n3_++),
1543 Bool(n4_++));
1544 finished_ = true;
1545 }, "");
1546}
1547
1548// Tests a failed EXPECT_PRED4 where the
1549// predicate-formatter is a functor on a built-in type (int).
1550TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1551 EXPECT_NONFATAL_FAILURE({ // NOLINT
1553 n1_++,
1554 n2_++,
1555 n3_++,
1556 n4_++);
1557 finished_ = true;
1558 }, "");
1559}
1560
1561// Tests a failed EXPECT_PRED4 where the
1562// predicate-formatter is a functor on a user-defined type (Bool).
1563TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
1564 EXPECT_NONFATAL_FAILURE({ // NOLINT
1566 Bool(n1_++),
1567 Bool(n2_++),
1568 Bool(n3_++),
1569 Bool(n4_++));
1570 finished_ = true;
1571 }, "");
1572}
1573
1574// Tests a successful ASSERT_PRED4 where the
1575// predicate-formatter is a function on a built-in type (int).
1576TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
1578 ++n1_,
1579 ++n2_,
1580 ++n3_,
1581 ++n4_);
1582 finished_ = true;
1583}
1584
1585// Tests a successful ASSERT_PRED4 where the
1586// predicate-formatter is a function on a user-defined type (Bool).
1587TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
1589 Bool(++n1_),
1590 Bool(++n2_),
1591 Bool(++n3_),
1592 Bool(++n4_));
1593 finished_ = true;
1594}
1595
1596// Tests a successful ASSERT_PRED4 where the
1597// predicate-formatter is a functor on a built-in type (int).
1598TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
1600 ++n1_,
1601 ++n2_,
1602 ++n3_,
1603 ++n4_);
1604 finished_ = true;
1605}
1606
1607// Tests a successful ASSERT_PRED4 where the
1608// predicate-formatter is a functor on a user-defined type (Bool).
1609TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
1611 Bool(++n1_),
1612 Bool(++n2_),
1613 Bool(++n3_),
1614 Bool(++n4_));
1615 finished_ = true;
1616}
1617
1618// Tests a failed ASSERT_PRED4 where the
1619// predicate-formatter is a function on a built-in type (int).
1620TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
1621 expected_to_finish_ = false;
1622 EXPECT_FATAL_FAILURE({ // NOLINT
1624 n1_++,
1625 n2_++,
1626 n3_++,
1627 n4_++);
1628 finished_ = true;
1629 }, "");
1630}
1631
1632// Tests a failed ASSERT_PRED4 where the
1633// predicate-formatter is a function on a user-defined type (Bool).
1634TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
1635 expected_to_finish_ = false;
1636 EXPECT_FATAL_FAILURE({ // NOLINT
1638 Bool(n1_++),
1639 Bool(n2_++),
1640 Bool(n3_++),
1641 Bool(n4_++));
1642 finished_ = true;
1643 }, "");
1644}
1645
1646// Tests a failed ASSERT_PRED4 where the
1647// predicate-formatter is a functor on a built-in type (int).
1648TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
1649 expected_to_finish_ = false;
1650 EXPECT_FATAL_FAILURE({ // NOLINT
1652 n1_++,
1653 n2_++,
1654 n3_++,
1655 n4_++);
1656 finished_ = true;
1657 }, "");
1658}
1659
1660// Tests a failed ASSERT_PRED4 where the
1661// predicate-formatter is a functor on a user-defined type (Bool).
1662TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
1663 expected_to_finish_ = false;
1664 EXPECT_FATAL_FAILURE({ // NOLINT
1666 Bool(n1_++),
1667 Bool(n2_++),
1668 Bool(n3_++),
1669 Bool(n4_++));
1670 finished_ = true;
1671 }, "");
1672}
1673
1674// Tests a successful EXPECT_PRED_FORMAT4 where the
1675// predicate-formatter is a function on a built-in type (int).
1676TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1678 ++n1_,
1679 ++n2_,
1680 ++n3_,
1681 ++n4_);
1682 finished_ = true;
1683}
1684
1685// Tests a successful EXPECT_PRED_FORMAT4 where the
1686// predicate-formatter is a function on a user-defined type (Bool).
1687TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1689 Bool(++n1_),
1690 Bool(++n2_),
1691 Bool(++n3_),
1692 Bool(++n4_));
1693 finished_ = true;
1694}
1695
1696// Tests a successful EXPECT_PRED_FORMAT4 where the
1697// predicate-formatter is a functor on a built-in type (int).
1698TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1700 ++n1_,
1701 ++n2_,
1702 ++n3_,
1703 ++n4_);
1704 finished_ = true;
1705}
1706
1707// Tests a successful EXPECT_PRED_FORMAT4 where the
1708// predicate-formatter is a functor on a user-defined type (Bool).
1709TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1711 Bool(++n1_),
1712 Bool(++n2_),
1713 Bool(++n3_),
1714 Bool(++n4_));
1715 finished_ = true;
1716}
1717
1718// Tests a failed EXPECT_PRED_FORMAT4 where the
1719// predicate-formatter is a function on a built-in type (int).
1720TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1721 EXPECT_NONFATAL_FAILURE({ // NOLINT
1723 n1_++,
1724 n2_++,
1725 n3_++,
1726 n4_++);
1727 finished_ = true;
1728 }, "");
1729}
1730
1731// Tests a failed EXPECT_PRED_FORMAT4 where the
1732// predicate-formatter is a function on a user-defined type (Bool).
1733TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1734 EXPECT_NONFATAL_FAILURE({ // NOLINT
1736 Bool(n1_++),
1737 Bool(n2_++),
1738 Bool(n3_++),
1739 Bool(n4_++));
1740 finished_ = true;
1741 }, "");
1742}
1743
1744// Tests a failed EXPECT_PRED_FORMAT4 where the
1745// predicate-formatter is a functor on a built-in type (int).
1746TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1747 EXPECT_NONFATAL_FAILURE({ // NOLINT
1749 n1_++,
1750 n2_++,
1751 n3_++,
1752 n4_++);
1753 finished_ = true;
1754 }, "");
1755}
1756
1757// Tests a failed EXPECT_PRED_FORMAT4 where the
1758// predicate-formatter is a functor on a user-defined type (Bool).
1759TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1760 EXPECT_NONFATAL_FAILURE({ // NOLINT
1762 Bool(n1_++),
1763 Bool(n2_++),
1764 Bool(n3_++),
1765 Bool(n4_++));
1766 finished_ = true;
1767 }, "");
1768}
1769
1770// Tests a successful ASSERT_PRED_FORMAT4 where the
1771// predicate-formatter is a function on a built-in type (int).
1772TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
1774 ++n1_,
1775 ++n2_,
1776 ++n3_,
1777 ++n4_);
1778 finished_ = true;
1779}
1780
1781// Tests a successful ASSERT_PRED_FORMAT4 where the
1782// predicate-formatter is a function on a user-defined type (Bool).
1783TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
1785 Bool(++n1_),
1786 Bool(++n2_),
1787 Bool(++n3_),
1788 Bool(++n4_));
1789 finished_ = true;
1790}
1791
1792// Tests a successful ASSERT_PRED_FORMAT4 where the
1793// predicate-formatter is a functor on a built-in type (int).
1794TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
1796 ++n1_,
1797 ++n2_,
1798 ++n3_,
1799 ++n4_);
1800 finished_ = true;
1801}
1802
1803// Tests a successful ASSERT_PRED_FORMAT4 where the
1804// predicate-formatter is a functor on a user-defined type (Bool).
1805TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
1807 Bool(++n1_),
1808 Bool(++n2_),
1809 Bool(++n3_),
1810 Bool(++n4_));
1811 finished_ = true;
1812}
1813
1814// Tests a failed ASSERT_PRED_FORMAT4 where the
1815// predicate-formatter is a function on a built-in type (int).
1816TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
1817 expected_to_finish_ = false;
1818 EXPECT_FATAL_FAILURE({ // NOLINT
1820 n1_++,
1821 n2_++,
1822 n3_++,
1823 n4_++);
1824 finished_ = true;
1825 }, "");
1826}
1827
1828// Tests a failed ASSERT_PRED_FORMAT4 where the
1829// predicate-formatter is a function on a user-defined type (Bool).
1830TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
1831 expected_to_finish_ = false;
1832 EXPECT_FATAL_FAILURE({ // NOLINT
1834 Bool(n1_++),
1835 Bool(n2_++),
1836 Bool(n3_++),
1837 Bool(n4_++));
1838 finished_ = true;
1839 }, "");
1840}
1841
1842// Tests a failed ASSERT_PRED_FORMAT4 where the
1843// predicate-formatter is a functor on a built-in type (int).
1844TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
1845 expected_to_finish_ = false;
1846 EXPECT_FATAL_FAILURE({ // NOLINT
1848 n1_++,
1849 n2_++,
1850 n3_++,
1851 n4_++);
1852 finished_ = true;
1853 }, "");
1854}
1855
1856// Tests a failed ASSERT_PRED_FORMAT4 where the
1857// predicate-formatter is a functor on a user-defined type (Bool).
1858TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
1859 expected_to_finish_ = false;
1860 EXPECT_FATAL_FAILURE({ // NOLINT
1862 Bool(n1_++),
1863 Bool(n2_++),
1864 Bool(n3_++),
1865 Bool(n4_++));
1866 finished_ = true;
1867 }, "");
1868}
1869// Sample functions/functors for testing 5-ary predicate assertions.
1870
1871// A 5-ary predicate function.
1872template <typename T1, typename T2, typename T3, typename T4, typename T5>
1873bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
1874 return v1 + v2 + v3 + v4 + v5 > 0;
1875}
1876
1877// The following two functions are needed because a compiler doesn't have
1878// a context yet to know which template function must be instantiated.
1879bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
1880 return v1 + v2 + v3 + v4 + v5 > 0;
1881}
1882bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
1883 return v1 + v2 + v3 + v4 + v5 > 0;
1884}
1885
1886// A 5-ary predicate functor.
1888 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1889 bool operator()(const T1& v1,
1890 const T2& v2,
1891 const T3& v3,
1892 const T4& v4,
1893 const T5& v5) {
1894 return v1 + v2 + v3 + v4 + v5 > 0;
1895 }
1896};
1897
1898// A 5-ary predicate-formatter function.
1899template <typename T1, typename T2, typename T3, typename T4, typename T5>
1900testing::AssertionResult PredFormatFunction5(const char* e1,
1901 const char* e2,
1902 const char* e3,
1903 const char* e4,
1904 const char* e5,
1905 const T1& v1,
1906 const T2& v2,
1907 const T3& v3,
1908 const T4& v4,
1909 const T5& v5) {
1910 if (PredFunction5(v1, v2, v3, v4, v5))
1912
1914 << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
1915 << " is expected to be positive, but evaluates to "
1916 << v1 + v2 + v3 + v4 + v5 << ".";
1917}
1918
1919// A 5-ary predicate-formatter functor.
1921 template <typename T1, typename T2, typename T3, typename T4, typename T5>
1922 testing::AssertionResult operator()(const char* e1,
1923 const char* e2,
1924 const char* e3,
1925 const char* e4,
1926 const char* e5,
1927 const T1& v1,
1928 const T2& v2,
1929 const T3& v3,
1930 const T4& v4,
1931 const T5& v5) const {
1932 return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);
1933 }
1934};
1935
1936// Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
1937
1939 protected:
1940 void SetUp() override {
1941 expected_to_finish_ = true;
1942 finished_ = false;
1943 n1_ = n2_ = n3_ = n4_ = n5_ = 0;
1944 }
1945
1946 void TearDown() override {
1947 // Verifies that each of the predicate's arguments was evaluated
1948 // exactly once.
1949 EXPECT_EQ(1, n1_) <<
1950 "The predicate assertion didn't evaluate argument 2 "
1951 "exactly once.";
1952 EXPECT_EQ(1, n2_) <<
1953 "The predicate assertion didn't evaluate argument 3 "
1954 "exactly once.";
1955 EXPECT_EQ(1, n3_) <<
1956 "The predicate assertion didn't evaluate argument 4 "
1957 "exactly once.";
1958 EXPECT_EQ(1, n4_) <<
1959 "The predicate assertion didn't evaluate argument 5 "
1960 "exactly once.";
1961 EXPECT_EQ(1, n5_) <<
1962 "The predicate assertion didn't evaluate argument 6 "
1963 "exactly once.";
1964
1965 // Verifies that the control flow in the test function is expected.
1967 FAIL() << "The predicate assertion unexpactedly aborted the test.";
1968 } else if (!expected_to_finish_ && finished_) {
1969 FAIL() << "The failed predicate assertion didn't abort the test "
1970 "as expected.";
1971 }
1972 }
1973
1974 // true if and only if the test function is expected to run to finish.
1976
1977 // true if and only if the test function did run to finish.
1978 static bool finished_;
1979
1980 static int n1_;
1981 static int n2_;
1982 static int n3_;
1983 static int n4_;
1984 static int n5_;
1985};
1986
1994
1999
2000// Tests a successful EXPECT_PRED5 where the
2001// predicate-formatter is a function on a built-in type (int).
2002TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
2004 ++n1_,
2005 ++n2_,
2006 ++n3_,
2007 ++n4_,
2008 ++n5_);
2009 finished_ = true;
2010}
2011
2012// Tests a successful EXPECT_PRED5 where the
2013// predicate-formatter is a function on a user-defined type (Bool).
2014TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
2016 Bool(++n1_),
2017 Bool(++n2_),
2018 Bool(++n3_),
2019 Bool(++n4_),
2020 Bool(++n5_));
2021 finished_ = true;
2022}
2023
2024// Tests a successful EXPECT_PRED5 where the
2025// predicate-formatter is a functor on a built-in type (int).
2026TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
2028 ++n1_,
2029 ++n2_,
2030 ++n3_,
2031 ++n4_,
2032 ++n5_);
2033 finished_ = true;
2034}
2035
2036// Tests a successful EXPECT_PRED5 where the
2037// predicate-formatter is a functor on a user-defined type (Bool).
2038TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
2040 Bool(++n1_),
2041 Bool(++n2_),
2042 Bool(++n3_),
2043 Bool(++n4_),
2044 Bool(++n5_));
2045 finished_ = true;
2046}
2047
2048// Tests a failed EXPECT_PRED5 where the
2049// predicate-formatter is a function on a built-in type (int).
2050TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
2051 EXPECT_NONFATAL_FAILURE({ // NOLINT
2053 n1_++,
2054 n2_++,
2055 n3_++,
2056 n4_++,
2057 n5_++);
2058 finished_ = true;
2059 }, "");
2060}
2061
2062// Tests a failed EXPECT_PRED5 where the
2063// predicate-formatter is a function on a user-defined type (Bool).
2064TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
2065 EXPECT_NONFATAL_FAILURE({ // NOLINT
2067 Bool(n1_++),
2068 Bool(n2_++),
2069 Bool(n3_++),
2070 Bool(n4_++),
2071 Bool(n5_++));
2072 finished_ = true;
2073 }, "");
2074}
2075
2076// Tests a failed EXPECT_PRED5 where the
2077// predicate-formatter is a functor on a built-in type (int).
2078TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
2079 EXPECT_NONFATAL_FAILURE({ // NOLINT
2081 n1_++,
2082 n2_++,
2083 n3_++,
2084 n4_++,
2085 n5_++);
2086 finished_ = true;
2087 }, "");
2088}
2089
2090// Tests a failed EXPECT_PRED5 where the
2091// predicate-formatter is a functor on a user-defined type (Bool).
2092TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
2093 EXPECT_NONFATAL_FAILURE({ // NOLINT
2095 Bool(n1_++),
2096 Bool(n2_++),
2097 Bool(n3_++),
2098 Bool(n4_++),
2099 Bool(n5_++));
2100 finished_ = true;
2101 }, "");
2102}
2103
2104// Tests a successful ASSERT_PRED5 where the
2105// predicate-formatter is a function on a built-in type (int).
2106TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
2108 ++n1_,
2109 ++n2_,
2110 ++n3_,
2111 ++n4_,
2112 ++n5_);
2113 finished_ = true;
2114}
2115
2116// Tests a successful ASSERT_PRED5 where the
2117// predicate-formatter is a function on a user-defined type (Bool).
2118TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
2120 Bool(++n1_),
2121 Bool(++n2_),
2122 Bool(++n3_),
2123 Bool(++n4_),
2124 Bool(++n5_));
2125 finished_ = true;
2126}
2127
2128// Tests a successful ASSERT_PRED5 where the
2129// predicate-formatter is a functor on a built-in type (int).
2130TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
2132 ++n1_,
2133 ++n2_,
2134 ++n3_,
2135 ++n4_,
2136 ++n5_);
2137 finished_ = true;
2138}
2139
2140// Tests a successful ASSERT_PRED5 where the
2141// predicate-formatter is a functor on a user-defined type (Bool).
2142TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
2144 Bool(++n1_),
2145 Bool(++n2_),
2146 Bool(++n3_),
2147 Bool(++n4_),
2148 Bool(++n5_));
2149 finished_ = true;
2150}
2151
2152// Tests a failed ASSERT_PRED5 where the
2153// predicate-formatter is a function on a built-in type (int).
2154TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
2155 expected_to_finish_ = false;
2156 EXPECT_FATAL_FAILURE({ // NOLINT
2158 n1_++,
2159 n2_++,
2160 n3_++,
2161 n4_++,
2162 n5_++);
2163 finished_ = true;
2164 }, "");
2165}
2166
2167// Tests a failed ASSERT_PRED5 where the
2168// predicate-formatter is a function on a user-defined type (Bool).
2169TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
2170 expected_to_finish_ = false;
2171 EXPECT_FATAL_FAILURE({ // NOLINT
2173 Bool(n1_++),
2174 Bool(n2_++),
2175 Bool(n3_++),
2176 Bool(n4_++),
2177 Bool(n5_++));
2178 finished_ = true;
2179 }, "");
2180}
2181
2182// Tests a failed ASSERT_PRED5 where the
2183// predicate-formatter is a functor on a built-in type (int).
2184TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
2185 expected_to_finish_ = false;
2186 EXPECT_FATAL_FAILURE({ // NOLINT
2188 n1_++,
2189 n2_++,
2190 n3_++,
2191 n4_++,
2192 n5_++);
2193 finished_ = true;
2194 }, "");
2195}
2196
2197// Tests a failed ASSERT_PRED5 where the
2198// predicate-formatter is a functor on a user-defined type (Bool).
2199TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
2200 expected_to_finish_ = false;
2201 EXPECT_FATAL_FAILURE({ // NOLINT
2203 Bool(n1_++),
2204 Bool(n2_++),
2205 Bool(n3_++),
2206 Bool(n4_++),
2207 Bool(n5_++));
2208 finished_ = true;
2209 }, "");
2210}
2211
2212// Tests a successful EXPECT_PRED_FORMAT5 where the
2213// predicate-formatter is a function on a built-in type (int).
2214TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
2216 ++n1_,
2217 ++n2_,
2218 ++n3_,
2219 ++n4_,
2220 ++n5_);
2221 finished_ = true;
2222}
2223
2224// Tests a successful EXPECT_PRED_FORMAT5 where the
2225// predicate-formatter is a function on a user-defined type (Bool).
2226TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
2228 Bool(++n1_),
2229 Bool(++n2_),
2230 Bool(++n3_),
2231 Bool(++n4_),
2232 Bool(++n5_));
2233 finished_ = true;
2234}
2235
2236// Tests a successful EXPECT_PRED_FORMAT5 where the
2237// predicate-formatter is a functor on a built-in type (int).
2238TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
2240 ++n1_,
2241 ++n2_,
2242 ++n3_,
2243 ++n4_,
2244 ++n5_);
2245 finished_ = true;
2246}
2247
2248// Tests a successful EXPECT_PRED_FORMAT5 where the
2249// predicate-formatter is a functor on a user-defined type (Bool).
2250TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
2252 Bool(++n1_),
2253 Bool(++n2_),
2254 Bool(++n3_),
2255 Bool(++n4_),
2256 Bool(++n5_));
2257 finished_ = true;
2258}
2259
2260// Tests a failed EXPECT_PRED_FORMAT5 where the
2261// predicate-formatter is a function on a built-in type (int).
2262TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
2263 EXPECT_NONFATAL_FAILURE({ // NOLINT
2265 n1_++,
2266 n2_++,
2267 n3_++,
2268 n4_++,
2269 n5_++);
2270 finished_ = true;
2271 }, "");
2272}
2273
2274// Tests a failed EXPECT_PRED_FORMAT5 where the
2275// predicate-formatter is a function on a user-defined type (Bool).
2276TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
2277 EXPECT_NONFATAL_FAILURE({ // NOLINT
2279 Bool(n1_++),
2280 Bool(n2_++),
2281 Bool(n3_++),
2282 Bool(n4_++),
2283 Bool(n5_++));
2284 finished_ = true;
2285 }, "");
2286}
2287
2288// Tests a failed EXPECT_PRED_FORMAT5 where the
2289// predicate-formatter is a functor on a built-in type (int).
2290TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
2291 EXPECT_NONFATAL_FAILURE({ // NOLINT
2293 n1_++,
2294 n2_++,
2295 n3_++,
2296 n4_++,
2297 n5_++);
2298 finished_ = true;
2299 }, "");
2300}
2301
2302// Tests a failed EXPECT_PRED_FORMAT5 where the
2303// predicate-formatter is a functor on a user-defined type (Bool).
2304TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
2305 EXPECT_NONFATAL_FAILURE({ // NOLINT
2307 Bool(n1_++),
2308 Bool(n2_++),
2309 Bool(n3_++),
2310 Bool(n4_++),
2311 Bool(n5_++));
2312 finished_ = true;
2313 }, "");
2314}
2315
2316// Tests a successful ASSERT_PRED_FORMAT5 where the
2317// predicate-formatter is a function on a built-in type (int).
2318TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
2320 ++n1_,
2321 ++n2_,
2322 ++n3_,
2323 ++n4_,
2324 ++n5_);
2325 finished_ = true;
2326}
2327
2328// Tests a successful ASSERT_PRED_FORMAT5 where the
2329// predicate-formatter is a function on a user-defined type (Bool).
2330TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
2332 Bool(++n1_),
2333 Bool(++n2_),
2334 Bool(++n3_),
2335 Bool(++n4_),
2336 Bool(++n5_));
2337 finished_ = true;
2338}
2339
2340// Tests a successful ASSERT_PRED_FORMAT5 where the
2341// predicate-formatter is a functor on a built-in type (int).
2342TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
2344 ++n1_,
2345 ++n2_,
2346 ++n3_,
2347 ++n4_,
2348 ++n5_);
2349 finished_ = true;
2350}
2351
2352// Tests a successful ASSERT_PRED_FORMAT5 where the
2353// predicate-formatter is a functor on a user-defined type (Bool).
2354TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
2356 Bool(++n1_),
2357 Bool(++n2_),
2358 Bool(++n3_),
2359 Bool(++n4_),
2360 Bool(++n5_));
2361 finished_ = true;
2362}
2363
2364// Tests a failed ASSERT_PRED_FORMAT5 where the
2365// predicate-formatter is a function on a built-in type (int).
2366TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
2367 expected_to_finish_ = false;
2368 EXPECT_FATAL_FAILURE({ // NOLINT
2370 n1_++,
2371 n2_++,
2372 n3_++,
2373 n4_++,
2374 n5_++);
2375 finished_ = true;
2376 }, "");
2377}
2378
2379// Tests a failed ASSERT_PRED_FORMAT5 where the
2380// predicate-formatter is a function on a user-defined type (Bool).
2381TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
2382 expected_to_finish_ = false;
2383 EXPECT_FATAL_FAILURE({ // NOLINT
2385 Bool(n1_++),
2386 Bool(n2_++),
2387 Bool(n3_++),
2388 Bool(n4_++),
2389 Bool(n5_++));
2390 finished_ = true;
2391 }, "");
2392}
2393
2394// Tests a failed ASSERT_PRED_FORMAT5 where the
2395// predicate-formatter is a functor on a built-in type (int).
2396TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
2397 expected_to_finish_ = false;
2398 EXPECT_FATAL_FAILURE({ // NOLINT
2400 n1_++,
2401 n2_++,
2402 n3_++,
2403 n4_++,
2404 n5_++);
2405 finished_ = true;
2406 }, "");
2407}
2408
2409// Tests a failed ASSERT_PRED_FORMAT5 where the
2410// predicate-formatter is a functor on a user-defined type (Bool).
2411TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
2412 expected_to_finish_ = false;
2413 EXPECT_FATAL_FAILURE({ // NOLINT
2415 Bool(n1_++),
2416 Bool(n2_++),
2417 Bool(n3_++),
2418 Bool(n4_++),
2419 Bool(n5_++));
2420 finished_ = true;
2421 }, "");
2422}
@ T4
Definition: rune.c:31
@ T3
Definition: rune.c:30
@ T1
Definition: rune.c:27
@ T5
Definition: rune.c:32
@ T2
Definition: rune.c:29
#define FAIL()
Definition: gtest.h:1928
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:2043
#define EXPECT_PRED_FORMAT1(pred_format, v1)
#define EXPECT_PRED3(pred, v1, v2, v3)
#define EXPECT_PRED2(pred, v1, v2)
#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4)
#define ASSERT_PRED_FORMAT1(pred_format, v1)
#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3)
#define ASSERT_PRED2(pred, v1, v2)
#define EXPECT_PRED4(pred, v1, v2, v3, v4)
#define EXPECT_PRED1(pred, v1)
#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3)
#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
#define ASSERT_PRED1(pred, v1)
#define ASSERT_PRED3(pred, v1, v2, v3)
#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5)
#define ASSERT_PRED_FORMAT2(pred_format, v1, v2)
#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5)
#define ASSERT_PRED4(pred, v1, v2, v3, v4)
#define EXPECT_PRED_FORMAT2(pred_format, v1, v2)
#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5)
#define EXPECT_FATAL_FAILURE(statement, substr)
#define EXPECT_NONFATAL_FAILURE(statement, substr)
Predicate4Test ASSERT_PRED4Test
testing::AssertionResult PredFormatFunction5(const char *e1, const char *e2, const char *e3, const char *e4, const char *e5, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
bool PredFunction1Int(int v1)
bool PredFunction4Int(int v1, int v2, int v3, int v4)
Predicate1Test ASSERT_PRED1Test
Predicate3Test EXPECT_PRED3Test
Predicate2Test ASSERT_PRED2Test
bool PredFunction1Bool(Bool v1)
Predicate2Test EXPECT_PRED2Test
Predicate4Test EXPECT_PRED_FORMAT4Test
bool PredFunction3Int(int v1, int v2, int v3)
Predicate3Test EXPECT_PRED_FORMAT3Test
Predicate1Test EXPECT_PRED_FORMAT1Test
bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4)
std::ostream & operator<<(std::ostream &os, const Bool &x)
Predicate3Test ASSERT_PRED3Test
bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4)
bool PredFunction2(T1 v1, T2 v2)
bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5)
Predicate1Test ASSERT_PRED_FORMAT1Test
bool PredFunction3(T1 v1, T2 v2, T3 v3)
bool PredFunction2Int(int v1, int v2)
Predicate2Test EXPECT_PRED_FORMAT2Test
Predicate5Test ASSERT_PRED5Test
Predicate2Test ASSERT_PRED_FORMAT2Test
Predicate5Test EXPECT_PRED5Test
testing::AssertionResult PredFormatFunction4(const char *e1, const char *e2, const char *e3, const char *e4, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
bool PredFunction1(T1 v1)
bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5)
bool PredFunction2Bool(Bool v1, Bool v2)
Predicate4Test EXPECT_PRED4Test
testing::AssertionResult PredFormatFunction3(const char *e1, const char *e2, const char *e3, const T1 &v1, const T2 &v2, const T3 &v3)
Predicate4Test ASSERT_PRED_FORMAT4Test
bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5)
Predicate3Test ASSERT_PRED_FORMAT3Test
testing::AssertionResult PredFormatFunction2(const char *e1, const char *e2, const T1 &v1, const T2 &v2)
Predicate5Test ASSERT_PRED_FORMAT5Test
TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess)
Predicate1Test EXPECT_PRED1Test
Predicate5Test EXPECT_PRED_FORMAT5Test
testing::AssertionResult PredFormatFunction1(const char *e1, const T1 &v1)
bool PredFunction3Bool(Bool v1, Bool v2, Bool v3)
internal::ParamGenerator< bool > Bool()
AssertionResult AssertionFailure()
Definition: gtest.cc:1214
AssertionResult AssertionSuccess()
Definition: gtest.cc:1209
Bool operator+(const Bool &rhs) const
bool operator>(int n) const
bool operator==(const Bool &rhs) const
bool operator()(const T1 &v1)
testing::AssertionResult operator()(const char *e1, const T1 &v1) const
bool operator()(const T1 &v1, const T2 &v2)
testing::AssertionResult operator()(const char *e1, const char *e2, const T1 &v1, const T2 &v2) const
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3)
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const T1 &v1, const T2 &v2, const T3 &v3) const
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4)
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const char *e4, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) const
bool operator()(const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5)
testing::AssertionResult operator()(const char *e1, const char *e2, const char *e3, const char *e4, const char *e5, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5) const