gtest_pred_impl_unittest.cc (77498B)
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. 56 struct 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. 69 std::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. 76 template <typename T1> 77 bool 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. 83 bool PredFunction1Int(int v1) { 84 return v1 > 0; 85 } 86 bool PredFunction1Bool(Bool v1) { 87 return v1 > 0; 88 } 89 90 // A unary predicate functor. 91 struct PredFunctor1 { 92 template <typename T1> 93 bool operator()(const T1& v1) { 94 return v1 > 0; 95 } 96 }; 97 98 // A unary predicate-formatter function. 99 template <typename T1> 100 testing::AssertionResult PredFormatFunction1(const char* e1, 101 const T1& v1) { 102 if (PredFunction1(v1)) 103 return testing::AssertionSuccess(); 104 105 return testing::AssertionFailure() 106 << e1 107 << " is expected to be positive, but evaluates to " 108 << v1 << "."; 109 } 110 111 // A unary predicate-formatter functor. 112 struct PredFormatFunctor1 { 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 122 class Predicate1Test : public testing::Test { 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. 138 if (expected_to_finish_ && !finished_) { 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. 147 static bool expected_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 155 bool Predicate1Test::expected_to_finish_; 156 bool Predicate1Test::finished_; 157 int Predicate1Test::n1_; 158 159 typedef Predicate1Test EXPECT_PRED_FORMAT1Test; 160 typedef Predicate1Test ASSERT_PRED_FORMAT1Test; 161 typedef Predicate1Test EXPECT_PRED1Test; 162 typedef Predicate1Test ASSERT_PRED1Test; 163 164 // Tests a successful EXPECT_PRED1 where the 165 // predicate-formatter is a function on a built-in type (int). 166 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) { 167 EXPECT_PRED1(PredFunction1Int, 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). 174 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) { 175 EXPECT_PRED1(PredFunction1Bool, 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). 182 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) { 183 EXPECT_PRED1(PredFunctor1(), 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). 190 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) { 191 EXPECT_PRED1(PredFunctor1(), 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). 198 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) { 199 EXPECT_NONFATAL_FAILURE({ // NOLINT 200 EXPECT_PRED1(PredFunction1Int, 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). 208 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) { 209 EXPECT_NONFATAL_FAILURE({ // NOLINT 210 EXPECT_PRED1(PredFunction1Bool, 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). 218 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) { 219 EXPECT_NONFATAL_FAILURE({ // NOLINT 220 EXPECT_PRED1(PredFunctor1(), 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). 228 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) { 229 EXPECT_NONFATAL_FAILURE({ // NOLINT 230 EXPECT_PRED1(PredFunctor1(), 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). 238 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) { 239 ASSERT_PRED1(PredFunction1Int, 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). 246 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) { 247 ASSERT_PRED1(PredFunction1Bool, 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). 254 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) { 255 ASSERT_PRED1(PredFunctor1(), 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). 262 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) { 263 ASSERT_PRED1(PredFunctor1(), 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). 270 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) { 271 expected_to_finish_ = false; 272 EXPECT_FATAL_FAILURE({ // NOLINT 273 ASSERT_PRED1(PredFunction1Int, 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). 281 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) { 282 expected_to_finish_ = false; 283 EXPECT_FATAL_FAILURE({ // NOLINT 284 ASSERT_PRED1(PredFunction1Bool, 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). 292 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) { 293 expected_to_finish_ = false; 294 EXPECT_FATAL_FAILURE({ // NOLINT 295 ASSERT_PRED1(PredFunctor1(), 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). 303 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) { 304 expected_to_finish_ = false; 305 EXPECT_FATAL_FAILURE({ // NOLINT 306 ASSERT_PRED1(PredFunctor1(), 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). 314 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) { 315 EXPECT_PRED_FORMAT1(PredFormatFunction1, 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). 322 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) { 323 EXPECT_PRED_FORMAT1(PredFormatFunction1, 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). 330 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) { 331 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), 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). 338 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) { 339 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), 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). 346 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) { 347 EXPECT_NONFATAL_FAILURE({ // NOLINT 348 EXPECT_PRED_FORMAT1(PredFormatFunction1, 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). 356 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) { 357 EXPECT_NONFATAL_FAILURE({ // NOLINT 358 EXPECT_PRED_FORMAT1(PredFormatFunction1, 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). 366 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) { 367 EXPECT_NONFATAL_FAILURE({ // NOLINT 368 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), 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). 376 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) { 377 EXPECT_NONFATAL_FAILURE({ // NOLINT 378 EXPECT_PRED_FORMAT1(PredFormatFunctor1(), 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). 386 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) { 387 ASSERT_PRED_FORMAT1(PredFormatFunction1, 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). 394 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) { 395 ASSERT_PRED_FORMAT1(PredFormatFunction1, 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). 402 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) { 403 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), 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). 410 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) { 411 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), 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). 418 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) { 419 expected_to_finish_ = false; 420 EXPECT_FATAL_FAILURE({ // NOLINT 421 ASSERT_PRED_FORMAT1(PredFormatFunction1, 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). 429 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) { 430 expected_to_finish_ = false; 431 EXPECT_FATAL_FAILURE({ // NOLINT 432 ASSERT_PRED_FORMAT1(PredFormatFunction1, 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). 440 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) { 441 expected_to_finish_ = false; 442 EXPECT_FATAL_FAILURE({ // NOLINT 443 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), 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). 451 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) { 452 expected_to_finish_ = false; 453 EXPECT_FATAL_FAILURE({ // NOLINT 454 ASSERT_PRED_FORMAT1(PredFormatFunctor1(), 455 Bool(n1_++)); 456 finished_ = true; 457 }, ""); 458 } 459 // Sample functions/functors for testing binary predicate assertions. 460 461 // A binary predicate function. 462 template <typename T1, typename T2> 463 bool 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. 469 bool PredFunction2Int(int v1, int v2) { 470 return v1 + v2 > 0; 471 } 472 bool PredFunction2Bool(Bool v1, Bool v2) { 473 return v1 + v2 > 0; 474 } 475 476 // A binary predicate functor. 477 struct PredFunctor2 { 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. 486 template <typename T1, typename T2> 487 testing::AssertionResult PredFormatFunction2(const char* e1, 488 const char* e2, 489 const T1& v1, 490 const T2& v2) { 491 if (PredFunction2(v1, v2)) 492 return testing::AssertionSuccess(); 493 494 return testing::AssertionFailure() 495 << e1 << " + " << e2 496 << " is expected to be positive, but evaluates to " 497 << v1 + v2 << "."; 498 } 499 500 // A binary predicate-formatter functor. 501 struct PredFormatFunctor2 { 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 513 class Predicate2Test : public testing::Test { 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. 532 if (expected_to_finish_ && !finished_) { 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. 541 static bool expected_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 550 bool Predicate2Test::expected_to_finish_; 551 bool Predicate2Test::finished_; 552 int Predicate2Test::n1_; 553 int Predicate2Test::n2_; 554 555 typedef Predicate2Test EXPECT_PRED_FORMAT2Test; 556 typedef Predicate2Test ASSERT_PRED_FORMAT2Test; 557 typedef Predicate2Test EXPECT_PRED2Test; 558 typedef Predicate2Test ASSERT_PRED2Test; 559 560 // Tests a successful EXPECT_PRED2 where the 561 // predicate-formatter is a function on a built-in type (int). 562 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) { 563 EXPECT_PRED2(PredFunction2Int, 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). 571 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) { 572 EXPECT_PRED2(PredFunction2Bool, 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). 580 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) { 581 EXPECT_PRED2(PredFunctor2(), 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). 589 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) { 590 EXPECT_PRED2(PredFunctor2(), 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). 598 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) { 599 EXPECT_NONFATAL_FAILURE({ // NOLINT 600 EXPECT_PRED2(PredFunction2Int, 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). 609 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) { 610 EXPECT_NONFATAL_FAILURE({ // NOLINT 611 EXPECT_PRED2(PredFunction2Bool, 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). 620 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) { 621 EXPECT_NONFATAL_FAILURE({ // NOLINT 622 EXPECT_PRED2(PredFunctor2(), 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). 631 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) { 632 EXPECT_NONFATAL_FAILURE({ // NOLINT 633 EXPECT_PRED2(PredFunctor2(), 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). 642 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) { 643 ASSERT_PRED2(PredFunction2Int, 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). 651 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) { 652 ASSERT_PRED2(PredFunction2Bool, 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). 660 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) { 661 ASSERT_PRED2(PredFunctor2(), 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). 669 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) { 670 ASSERT_PRED2(PredFunctor2(), 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). 678 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) { 679 expected_to_finish_ = false; 680 EXPECT_FATAL_FAILURE({ // NOLINT 681 ASSERT_PRED2(PredFunction2Int, 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). 690 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) { 691 expected_to_finish_ = false; 692 EXPECT_FATAL_FAILURE({ // NOLINT 693 ASSERT_PRED2(PredFunction2Bool, 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). 702 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) { 703 expected_to_finish_ = false; 704 EXPECT_FATAL_FAILURE({ // NOLINT 705 ASSERT_PRED2(PredFunctor2(), 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). 714 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) { 715 expected_to_finish_ = false; 716 EXPECT_FATAL_FAILURE({ // NOLINT 717 ASSERT_PRED2(PredFunctor2(), 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). 726 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) { 727 EXPECT_PRED_FORMAT2(PredFormatFunction2, 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). 735 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) { 736 EXPECT_PRED_FORMAT2(PredFormatFunction2, 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). 744 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) { 745 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), 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). 753 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) { 754 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), 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). 762 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) { 763 EXPECT_NONFATAL_FAILURE({ // NOLINT 764 EXPECT_PRED_FORMAT2(PredFormatFunction2, 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). 773 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) { 774 EXPECT_NONFATAL_FAILURE({ // NOLINT 775 EXPECT_PRED_FORMAT2(PredFormatFunction2, 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). 784 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) { 785 EXPECT_NONFATAL_FAILURE({ // NOLINT 786 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), 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). 795 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) { 796 EXPECT_NONFATAL_FAILURE({ // NOLINT 797 EXPECT_PRED_FORMAT2(PredFormatFunctor2(), 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). 806 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) { 807 ASSERT_PRED_FORMAT2(PredFormatFunction2, 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). 815 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) { 816 ASSERT_PRED_FORMAT2(PredFormatFunction2, 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). 824 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) { 825 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), 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). 833 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) { 834 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), 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). 842 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) { 843 expected_to_finish_ = false; 844 EXPECT_FATAL_FAILURE({ // NOLINT 845 ASSERT_PRED_FORMAT2(PredFormatFunction2, 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). 854 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) { 855 expected_to_finish_ = false; 856 EXPECT_FATAL_FAILURE({ // NOLINT 857 ASSERT_PRED_FORMAT2(PredFormatFunction2, 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). 866 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) { 867 expected_to_finish_ = false; 868 EXPECT_FATAL_FAILURE({ // NOLINT 869 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), 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). 878 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) { 879 expected_to_finish_ = false; 880 EXPECT_FATAL_FAILURE({ // NOLINT 881 ASSERT_PRED_FORMAT2(PredFormatFunctor2(), 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. 890 template <typename T1, typename T2, typename T3> 891 bool 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. 897 bool PredFunction3Int(int v1, int v2, int v3) { 898 return v1 + v2 + v3 > 0; 899 } 900 bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) { 901 return v1 + v2 + v3 > 0; 902 } 903 904 // A ternary predicate functor. 905 struct PredFunctor3 { 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. 915 template <typename T1, typename T2, typename T3> 916 testing::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)) 923 return testing::AssertionSuccess(); 924 925 return testing::AssertionFailure() 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. 932 struct PredFormatFunctor3 { 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 946 class Predicate3Test : public testing::Test { 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. 968 if (expected_to_finish_ && !finished_) { 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. 977 static bool expected_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 987 bool Predicate3Test::expected_to_finish_; 988 bool Predicate3Test::finished_; 989 int Predicate3Test::n1_; 990 int Predicate3Test::n2_; 991 int Predicate3Test::n3_; 992 993 typedef Predicate3Test EXPECT_PRED_FORMAT3Test; 994 typedef Predicate3Test ASSERT_PRED_FORMAT3Test; 995 typedef Predicate3Test EXPECT_PRED3Test; 996 typedef Predicate3Test ASSERT_PRED3Test; 997 998 // Tests a successful EXPECT_PRED3 where the 999 // predicate-formatter is a function on a built-in type (int). 1000 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) { 1001 EXPECT_PRED3(PredFunction3Int, 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). 1010 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) { 1011 EXPECT_PRED3(PredFunction3Bool, 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). 1020 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) { 1021 EXPECT_PRED3(PredFunctor3(), 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). 1030 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) { 1031 EXPECT_PRED3(PredFunctor3(), 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). 1040 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) { 1041 EXPECT_NONFATAL_FAILURE({ // NOLINT 1042 EXPECT_PRED3(PredFunction3Int, 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). 1052 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) { 1053 EXPECT_NONFATAL_FAILURE({ // NOLINT 1054 EXPECT_PRED3(PredFunction3Bool, 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). 1064 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) { 1065 EXPECT_NONFATAL_FAILURE({ // NOLINT 1066 EXPECT_PRED3(PredFunctor3(), 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). 1076 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) { 1077 EXPECT_NONFATAL_FAILURE({ // NOLINT 1078 EXPECT_PRED3(PredFunctor3(), 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). 1088 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) { 1089 ASSERT_PRED3(PredFunction3Int, 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). 1098 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) { 1099 ASSERT_PRED3(PredFunction3Bool, 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). 1108 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) { 1109 ASSERT_PRED3(PredFunctor3(), 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). 1118 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) { 1119 ASSERT_PRED3(PredFunctor3(), 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). 1128 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) { 1129 expected_to_finish_ = false; 1130 EXPECT_FATAL_FAILURE({ // NOLINT 1131 ASSERT_PRED3(PredFunction3Int, 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). 1141 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) { 1142 expected_to_finish_ = false; 1143 EXPECT_FATAL_FAILURE({ // NOLINT 1144 ASSERT_PRED3(PredFunction3Bool, 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). 1154 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) { 1155 expected_to_finish_ = false; 1156 EXPECT_FATAL_FAILURE({ // NOLINT 1157 ASSERT_PRED3(PredFunctor3(), 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). 1167 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) { 1168 expected_to_finish_ = false; 1169 EXPECT_FATAL_FAILURE({ // NOLINT 1170 ASSERT_PRED3(PredFunctor3(), 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). 1180 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) { 1181 EXPECT_PRED_FORMAT3(PredFormatFunction3, 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). 1190 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) { 1191 EXPECT_PRED_FORMAT3(PredFormatFunction3, 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). 1200 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) { 1201 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1210 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) { 1211 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1220 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) { 1221 EXPECT_NONFATAL_FAILURE({ // NOLINT 1222 EXPECT_PRED_FORMAT3(PredFormatFunction3, 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). 1232 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) { 1233 EXPECT_NONFATAL_FAILURE({ // NOLINT 1234 EXPECT_PRED_FORMAT3(PredFormatFunction3, 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). 1244 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) { 1245 EXPECT_NONFATAL_FAILURE({ // NOLINT 1246 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1256 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) { 1257 EXPECT_NONFATAL_FAILURE({ // NOLINT 1258 EXPECT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1268 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) { 1269 ASSERT_PRED_FORMAT3(PredFormatFunction3, 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). 1278 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) { 1279 ASSERT_PRED_FORMAT3(PredFormatFunction3, 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). 1288 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) { 1289 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1298 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) { 1299 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1308 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) { 1309 expected_to_finish_ = false; 1310 EXPECT_FATAL_FAILURE({ // NOLINT 1311 ASSERT_PRED_FORMAT3(PredFormatFunction3, 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). 1321 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) { 1322 expected_to_finish_ = false; 1323 EXPECT_FATAL_FAILURE({ // NOLINT 1324 ASSERT_PRED_FORMAT3(PredFormatFunction3, 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). 1334 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) { 1335 expected_to_finish_ = false; 1336 EXPECT_FATAL_FAILURE({ // NOLINT 1337 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), 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). 1347 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) { 1348 expected_to_finish_ = false; 1349 EXPECT_FATAL_FAILURE({ // NOLINT 1350 ASSERT_PRED_FORMAT3(PredFormatFunctor3(), 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. 1360 template <typename T1, typename T2, typename T3, typename T4> 1361 bool 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. 1367 bool PredFunction4Int(int v1, int v2, int v3, int v4) { 1368 return v1 + v2 + v3 + v4 > 0; 1369 } 1370 bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) { 1371 return v1 + v2 + v3 + v4 > 0; 1372 } 1373 1374 // A 4-ary predicate functor. 1375 struct PredFunctor4 { 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. 1386 template <typename T1, typename T2, typename T3, typename T4> 1387 testing::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)) 1396 return testing::AssertionSuccess(); 1397 1398 return testing::AssertionFailure() 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. 1405 struct PredFormatFunctor4 { 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 1421 class Predicate4Test : public testing::Test { 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. 1446 if (expected_to_finish_ && !finished_) { 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. 1455 static bool expected_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 1466 bool Predicate4Test::expected_to_finish_; 1467 bool Predicate4Test::finished_; 1468 int Predicate4Test::n1_; 1469 int Predicate4Test::n2_; 1470 int Predicate4Test::n3_; 1471 int Predicate4Test::n4_; 1472 1473 typedef Predicate4Test EXPECT_PRED_FORMAT4Test; 1474 typedef Predicate4Test ASSERT_PRED_FORMAT4Test; 1475 typedef Predicate4Test EXPECT_PRED4Test; 1476 typedef Predicate4Test ASSERT_PRED4Test; 1477 1478 // Tests a successful EXPECT_PRED4 where the 1479 // predicate-formatter is a function on a built-in type (int). 1480 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) { 1481 EXPECT_PRED4(PredFunction4Int, 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). 1491 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) { 1492 EXPECT_PRED4(PredFunction4Bool, 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). 1502 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) { 1503 EXPECT_PRED4(PredFunctor4(), 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). 1513 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) { 1514 EXPECT_PRED4(PredFunctor4(), 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). 1524 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) { 1525 EXPECT_NONFATAL_FAILURE({ // NOLINT 1526 EXPECT_PRED4(PredFunction4Int, 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). 1537 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) { 1538 EXPECT_NONFATAL_FAILURE({ // NOLINT 1539 EXPECT_PRED4(PredFunction4Bool, 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). 1550 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) { 1551 EXPECT_NONFATAL_FAILURE({ // NOLINT 1552 EXPECT_PRED4(PredFunctor4(), 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). 1563 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) { 1564 EXPECT_NONFATAL_FAILURE({ // NOLINT 1565 EXPECT_PRED4(PredFunctor4(), 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). 1576 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) { 1577 ASSERT_PRED4(PredFunction4Int, 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). 1587 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) { 1588 ASSERT_PRED4(PredFunction4Bool, 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). 1598 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) { 1599 ASSERT_PRED4(PredFunctor4(), 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). 1609 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) { 1610 ASSERT_PRED4(PredFunctor4(), 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). 1620 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) { 1621 expected_to_finish_ = false; 1622 EXPECT_FATAL_FAILURE({ // NOLINT 1623 ASSERT_PRED4(PredFunction4Int, 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). 1634 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) { 1635 expected_to_finish_ = false; 1636 EXPECT_FATAL_FAILURE({ // NOLINT 1637 ASSERT_PRED4(PredFunction4Bool, 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). 1648 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) { 1649 expected_to_finish_ = false; 1650 EXPECT_FATAL_FAILURE({ // NOLINT 1651 ASSERT_PRED4(PredFunctor4(), 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). 1662 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) { 1663 expected_to_finish_ = false; 1664 EXPECT_FATAL_FAILURE({ // NOLINT 1665 ASSERT_PRED4(PredFunctor4(), 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). 1676 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) { 1677 EXPECT_PRED_FORMAT4(PredFormatFunction4, 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). 1687 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) { 1688 EXPECT_PRED_FORMAT4(PredFormatFunction4, 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). 1698 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) { 1699 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1709 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) { 1710 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1720 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) { 1721 EXPECT_NONFATAL_FAILURE({ // NOLINT 1722 EXPECT_PRED_FORMAT4(PredFormatFunction4, 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). 1733 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) { 1734 EXPECT_NONFATAL_FAILURE({ // NOLINT 1735 EXPECT_PRED_FORMAT4(PredFormatFunction4, 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). 1746 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) { 1747 EXPECT_NONFATAL_FAILURE({ // NOLINT 1748 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1759 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) { 1760 EXPECT_NONFATAL_FAILURE({ // NOLINT 1761 EXPECT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1772 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) { 1773 ASSERT_PRED_FORMAT4(PredFormatFunction4, 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). 1783 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) { 1784 ASSERT_PRED_FORMAT4(PredFormatFunction4, 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). 1794 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) { 1795 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1805 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) { 1806 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1816 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) { 1817 expected_to_finish_ = false; 1818 EXPECT_FATAL_FAILURE({ // NOLINT 1819 ASSERT_PRED_FORMAT4(PredFormatFunction4, 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). 1830 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) { 1831 expected_to_finish_ = false; 1832 EXPECT_FATAL_FAILURE({ // NOLINT 1833 ASSERT_PRED_FORMAT4(PredFormatFunction4, 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). 1844 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) { 1845 expected_to_finish_ = false; 1846 EXPECT_FATAL_FAILURE({ // NOLINT 1847 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), 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). 1858 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) { 1859 expected_to_finish_ = false; 1860 EXPECT_FATAL_FAILURE({ // NOLINT 1861 ASSERT_PRED_FORMAT4(PredFormatFunctor4(), 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. 1872 template <typename T1, typename T2, typename T3, typename T4, typename T5> 1873 bool 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. 1879 bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) { 1880 return v1 + v2 + v3 + v4 + v5 > 0; 1881 } 1882 bool 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. 1887 struct PredFunctor5 { 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. 1899 template <typename T1, typename T2, typename T3, typename T4, typename T5> 1900 testing::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)) 1911 return testing::AssertionSuccess(); 1912 1913 return testing::AssertionFailure() 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. 1920 struct PredFormatFunctor5 { 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 1938 class Predicate5Test : public testing::Test { 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. 1966 if (expected_to_finish_ && !finished_) { 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. 1975 static bool expected_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 1987 bool Predicate5Test::expected_to_finish_; 1988 bool Predicate5Test::finished_; 1989 int Predicate5Test::n1_; 1990 int Predicate5Test::n2_; 1991 int Predicate5Test::n3_; 1992 int Predicate5Test::n4_; 1993 int Predicate5Test::n5_; 1994 1995 typedef Predicate5Test EXPECT_PRED_FORMAT5Test; 1996 typedef Predicate5Test ASSERT_PRED_FORMAT5Test; 1997 typedef Predicate5Test EXPECT_PRED5Test; 1998 typedef Predicate5Test ASSERT_PRED5Test; 1999 2000 // Tests a successful EXPECT_PRED5 where the 2001 // predicate-formatter is a function on a built-in type (int). 2002 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) { 2003 EXPECT_PRED5(PredFunction5Int, 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). 2014 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) { 2015 EXPECT_PRED5(PredFunction5Bool, 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). 2026 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) { 2027 EXPECT_PRED5(PredFunctor5(), 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). 2038 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) { 2039 EXPECT_PRED5(PredFunctor5(), 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). 2050 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) { 2051 EXPECT_NONFATAL_FAILURE({ // NOLINT 2052 EXPECT_PRED5(PredFunction5Int, 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). 2064 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) { 2065 EXPECT_NONFATAL_FAILURE({ // NOLINT 2066 EXPECT_PRED5(PredFunction5Bool, 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). 2078 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) { 2079 EXPECT_NONFATAL_FAILURE({ // NOLINT 2080 EXPECT_PRED5(PredFunctor5(), 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). 2092 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) { 2093 EXPECT_NONFATAL_FAILURE({ // NOLINT 2094 EXPECT_PRED5(PredFunctor5(), 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). 2106 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) { 2107 ASSERT_PRED5(PredFunction5Int, 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). 2118 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) { 2119 ASSERT_PRED5(PredFunction5Bool, 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). 2130 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) { 2131 ASSERT_PRED5(PredFunctor5(), 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). 2142 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) { 2143 ASSERT_PRED5(PredFunctor5(), 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). 2154 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) { 2155 expected_to_finish_ = false; 2156 EXPECT_FATAL_FAILURE({ // NOLINT 2157 ASSERT_PRED5(PredFunction5Int, 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). 2169 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) { 2170 expected_to_finish_ = false; 2171 EXPECT_FATAL_FAILURE({ // NOLINT 2172 ASSERT_PRED5(PredFunction5Bool, 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). 2184 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) { 2185 expected_to_finish_ = false; 2186 EXPECT_FATAL_FAILURE({ // NOLINT 2187 ASSERT_PRED5(PredFunctor5(), 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). 2199 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) { 2200 expected_to_finish_ = false; 2201 EXPECT_FATAL_FAILURE({ // NOLINT 2202 ASSERT_PRED5(PredFunctor5(), 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). 2214 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) { 2215 EXPECT_PRED_FORMAT5(PredFormatFunction5, 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). 2226 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) { 2227 EXPECT_PRED_FORMAT5(PredFormatFunction5, 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). 2238 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) { 2239 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2250 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) { 2251 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2262 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) { 2263 EXPECT_NONFATAL_FAILURE({ // NOLINT 2264 EXPECT_PRED_FORMAT5(PredFormatFunction5, 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). 2276 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) { 2277 EXPECT_NONFATAL_FAILURE({ // NOLINT 2278 EXPECT_PRED_FORMAT5(PredFormatFunction5, 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). 2290 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) { 2291 EXPECT_NONFATAL_FAILURE({ // NOLINT 2292 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2304 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) { 2305 EXPECT_NONFATAL_FAILURE({ // NOLINT 2306 EXPECT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2318 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) { 2319 ASSERT_PRED_FORMAT5(PredFormatFunction5, 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). 2330 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) { 2331 ASSERT_PRED_FORMAT5(PredFormatFunction5, 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). 2342 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) { 2343 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2354 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) { 2355 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2366 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) { 2367 expected_to_finish_ = false; 2368 EXPECT_FATAL_FAILURE({ // NOLINT 2369 ASSERT_PRED_FORMAT5(PredFormatFunction5, 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). 2381 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) { 2382 expected_to_finish_ = false; 2383 EXPECT_FATAL_FAILURE({ // NOLINT 2384 ASSERT_PRED_FORMAT5(PredFormatFunction5, 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). 2396 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) { 2397 expected_to_finish_ = false; 2398 EXPECT_FATAL_FAILURE({ // NOLINT 2399 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), 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). 2411 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) { 2412 expected_to_finish_ = false; 2413 EXPECT_FATAL_FAILURE({ // NOLINT 2414 ASSERT_PRED_FORMAT5(PredFormatFunctor5(), 2415 Bool(n1_++), 2416 Bool(n2_++), 2417 Bool(n3_++), 2418 Bool(n4_++), 2419 Bool(n5_++)); 2420 finished_ = true; 2421 }, ""); 2422 }