gtest_pred_impl_unittest.cc
Go to the documentation of this file.
00001 // Copyright 2006, Google Inc.
00002 // All rights reserved.
00003 //
00004 // Redistribution and use in source and binary forms, with or without
00005 // modification, are permitted provided that the following conditions are
00006 // met:
00007 //
00008 //     * Redistributions of source code must retain the above copyright
00009 // notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above
00011 // copyright notice, this list of conditions and the following disclaimer
00012 // in the documentation and/or other materials provided with the
00013 // distribution.
00014 //     * Neither the name of Google Inc. nor the names of its
00015 // contributors may be used to endorse or promote products derived from
00016 // this software without specific prior written permission.
00017 //
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 
00030 // This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
00031 // 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
00032 
00033 // Regression test for gtest_pred_impl.h
00034 //
00035 // This file is generated by a script and quite long.  If you intend to
00036 // learn how Google Test works by reading its unit tests, read
00037 // gtest_unittest.cc instead.
00038 //
00039 // This is intended as a regression test for the Google Test predicate
00040 // assertions.  We compile it as part of the gtest_unittest target
00041 // only to keep the implementation tidy and compact, as it is quite
00042 // involved to set up the stage for testing Google Test using Google
00043 // Test itself.
00044 //
00045 // Currently, gtest_unittest takes ~11 seconds to run in the testing
00046 // daemon.  In the future, if it grows too large and needs much more
00047 // time to finish, we should consider separating this file into a
00048 // stand-alone regression test.
00049 
00050 #include <iostream>
00051 
00052 #include "gtest/gtest.h"
00053 #include "gtest/gtest-spi.h"
00054 
00055 // A user-defined data type.
00056 struct Bool {
00057   explicit Bool(int val) : value(val != 0) {}
00058 
00059   bool operator>(int n) const { return value > Bool(n).value; }
00060 
00061   Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
00062 
00063   bool operator==(const Bool& rhs) const { return value == rhs.value; }
00064 
00065   bool value;
00066 };
00067 
00068 // Enables Bool to be used in assertions.
00069 std::ostream& operator<<(std::ostream& os, const Bool& x) {
00070   return os << (x.value ? "true" : "false");
00071 }
00072 
00073 // Sample functions/functors for testing unary predicate assertions.
00074 
00075 // A unary predicate function.
00076 template <typename T1>
00077 bool PredFunction1(T1 v1) {
00078   return v1 > 0;
00079 }
00080 
00081 // The following two functions are needed to circumvent a bug in
00082 // gcc 2.95.3, which sometimes has problem with the above template
00083 // function.
00084 bool PredFunction1Int(int v1) {
00085   return v1 > 0;
00086 }
00087 bool PredFunction1Bool(Bool v1) {
00088   return v1 > 0;
00089 }
00090 
00091 // A unary predicate functor.
00092 struct PredFunctor1 {
00093   template <typename T1>
00094   bool operator()(const T1& v1) {
00095     return v1 > 0;
00096   }
00097 };
00098 
00099 // A unary predicate-formatter function.
00100 template <typename T1>
00101 testing::AssertionResult PredFormatFunction1(const char* e1,
00102                                              const T1& v1) {
00103   if (PredFunction1(v1))
00104     return testing::AssertionSuccess();
00105 
00106   return testing::AssertionFailure()
00107       << e1
00108       << " is expected to be positive, but evaluates to "
00109       << v1 << ".";
00110 }
00111 
00112 // A unary predicate-formatter functor.
00113 struct PredFormatFunctor1 {
00114   template <typename T1>
00115   testing::AssertionResult operator()(const char* e1,
00116                                       const T1& v1) const {
00117     return PredFormatFunction1(e1, v1);
00118   }
00119 };
00120 
00121 // Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
00122 
00123 class Predicate1Test : public testing::Test {
00124  protected:
00125   virtual void SetUp() {
00126     expected_to_finish_ = true;
00127     finished_ = false;
00128     n1_ = 0;
00129   }
00130 
00131   virtual void TearDown() {
00132     // Verifies that each of the predicate's arguments was evaluated
00133     // exactly once.
00134     EXPECT_EQ(1, n1_) <<
00135         "The predicate assertion didn't evaluate argument 2 "
00136         "exactly once.";
00137 
00138     // Verifies that the control flow in the test function is expected.
00139     if (expected_to_finish_ && !finished_) {
00140       FAIL() << "The predicate assertion unexpactedly aborted the test.";
00141     } else if (!expected_to_finish_ && finished_) {
00142       FAIL() << "The failed predicate assertion didn't abort the test "
00143                 "as expected.";
00144     }
00145   }
00146 
00147   // true iff the test function is expected to run to finish.
00148   static bool expected_to_finish_;
00149 
00150   // true iff the test function did run to finish.
00151   static bool finished_;
00152 
00153   static int n1_;
00154 };
00155 
00156 bool Predicate1Test::expected_to_finish_;
00157 bool Predicate1Test::finished_;
00158 int Predicate1Test::n1_;
00159 
00160 typedef Predicate1Test EXPECT_PRED_FORMAT1Test;
00161 typedef Predicate1Test ASSERT_PRED_FORMAT1Test;
00162 typedef Predicate1Test EXPECT_PRED1Test;
00163 typedef Predicate1Test ASSERT_PRED1Test;
00164 
00165 // Tests a successful EXPECT_PRED1 where the
00166 // predicate-formatter is a function on a built-in type (int).
00167 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
00168   EXPECT_PRED1(PredFunction1Int,
00169                ++n1_);
00170   finished_ = true;
00171 }
00172 
00173 // Tests a successful EXPECT_PRED1 where the
00174 // predicate-formatter is a function on a user-defined type (Bool).
00175 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
00176   EXPECT_PRED1(PredFunction1Bool,
00177                Bool(++n1_));
00178   finished_ = true;
00179 }
00180 
00181 // Tests a successful EXPECT_PRED1 where the
00182 // predicate-formatter is a functor on a built-in type (int).
00183 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
00184   EXPECT_PRED1(PredFunctor1(),
00185                ++n1_);
00186   finished_ = true;
00187 }
00188 
00189 // Tests a successful EXPECT_PRED1 where the
00190 // predicate-formatter is a functor on a user-defined type (Bool).
00191 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
00192   EXPECT_PRED1(PredFunctor1(),
00193                Bool(++n1_));
00194   finished_ = true;
00195 }
00196 
00197 // Tests a failed EXPECT_PRED1 where the
00198 // predicate-formatter is a function on a built-in type (int).
00199 TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
00200   EXPECT_NONFATAL_FAILURE({  // NOLINT
00201     EXPECT_PRED1(PredFunction1Int,
00202                  n1_++);
00203     finished_ = true;
00204   }, "");
00205 }
00206 
00207 // Tests a failed EXPECT_PRED1 where the
00208 // predicate-formatter is a function on a user-defined type (Bool).
00209 TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
00210   EXPECT_NONFATAL_FAILURE({  // NOLINT
00211     EXPECT_PRED1(PredFunction1Bool,
00212                  Bool(n1_++));
00213     finished_ = true;
00214   }, "");
00215 }
00216 
00217 // Tests a failed EXPECT_PRED1 where the
00218 // predicate-formatter is a functor on a built-in type (int).
00219 TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
00220   EXPECT_NONFATAL_FAILURE({  // NOLINT
00221     EXPECT_PRED1(PredFunctor1(),
00222                  n1_++);
00223     finished_ = true;
00224   }, "");
00225 }
00226 
00227 // Tests a failed EXPECT_PRED1 where the
00228 // predicate-formatter is a functor on a user-defined type (Bool).
00229 TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
00230   EXPECT_NONFATAL_FAILURE({  // NOLINT
00231     EXPECT_PRED1(PredFunctor1(),
00232                  Bool(n1_++));
00233     finished_ = true;
00234   }, "");
00235 }
00236 
00237 // Tests a successful ASSERT_PRED1 where the
00238 // predicate-formatter is a function on a built-in type (int).
00239 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
00240   ASSERT_PRED1(PredFunction1Int,
00241                ++n1_);
00242   finished_ = true;
00243 }
00244 
00245 // Tests a successful ASSERT_PRED1 where the
00246 // predicate-formatter is a function on a user-defined type (Bool).
00247 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
00248   ASSERT_PRED1(PredFunction1Bool,
00249                Bool(++n1_));
00250   finished_ = true;
00251 }
00252 
00253 // Tests a successful ASSERT_PRED1 where the
00254 // predicate-formatter is a functor on a built-in type (int).
00255 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
00256   ASSERT_PRED1(PredFunctor1(),
00257                ++n1_);
00258   finished_ = true;
00259 }
00260 
00261 // Tests a successful ASSERT_PRED1 where the
00262 // predicate-formatter is a functor on a user-defined type (Bool).
00263 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
00264   ASSERT_PRED1(PredFunctor1(),
00265                Bool(++n1_));
00266   finished_ = true;
00267 }
00268 
00269 // Tests a failed ASSERT_PRED1 where the
00270 // predicate-formatter is a function on a built-in type (int).
00271 TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
00272   expected_to_finish_ = false;
00273   EXPECT_FATAL_FAILURE({  // NOLINT
00274     ASSERT_PRED1(PredFunction1Int,
00275                  n1_++);
00276     finished_ = true;
00277   }, "");
00278 }
00279 
00280 // Tests a failed ASSERT_PRED1 where the
00281 // predicate-formatter is a function on a user-defined type (Bool).
00282 TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
00283   expected_to_finish_ = false;
00284   EXPECT_FATAL_FAILURE({  // NOLINT
00285     ASSERT_PRED1(PredFunction1Bool,
00286                  Bool(n1_++));
00287     finished_ = true;
00288   }, "");
00289 }
00290 
00291 // Tests a failed ASSERT_PRED1 where the
00292 // predicate-formatter is a functor on a built-in type (int).
00293 TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
00294   expected_to_finish_ = false;
00295   EXPECT_FATAL_FAILURE({  // NOLINT
00296     ASSERT_PRED1(PredFunctor1(),
00297                  n1_++);
00298     finished_ = true;
00299   }, "");
00300 }
00301 
00302 // Tests a failed ASSERT_PRED1 where the
00303 // predicate-formatter is a functor on a user-defined type (Bool).
00304 TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
00305   expected_to_finish_ = false;
00306   EXPECT_FATAL_FAILURE({  // NOLINT
00307     ASSERT_PRED1(PredFunctor1(),
00308                  Bool(n1_++));
00309     finished_ = true;
00310   }, "");
00311 }
00312 
00313 // Tests a successful EXPECT_PRED_FORMAT1 where the
00314 // predicate-formatter is a function on a built-in type (int).
00315 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
00316   EXPECT_PRED_FORMAT1(PredFormatFunction1,
00317                       ++n1_);
00318   finished_ = true;
00319 }
00320 
00321 // Tests a successful EXPECT_PRED_FORMAT1 where the
00322 // predicate-formatter is a function on a user-defined type (Bool).
00323 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
00324   EXPECT_PRED_FORMAT1(PredFormatFunction1,
00325                       Bool(++n1_));
00326   finished_ = true;
00327 }
00328 
00329 // Tests a successful EXPECT_PRED_FORMAT1 where the
00330 // predicate-formatter is a functor on a built-in type (int).
00331 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
00332   EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
00333                       ++n1_);
00334   finished_ = true;
00335 }
00336 
00337 // Tests a successful EXPECT_PRED_FORMAT1 where the
00338 // predicate-formatter is a functor on a user-defined type (Bool).
00339 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
00340   EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
00341                       Bool(++n1_));
00342   finished_ = true;
00343 }
00344 
00345 // Tests a failed EXPECT_PRED_FORMAT1 where the
00346 // predicate-formatter is a function on a built-in type (int).
00347 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
00348   EXPECT_NONFATAL_FAILURE({  // NOLINT
00349     EXPECT_PRED_FORMAT1(PredFormatFunction1,
00350                         n1_++);
00351     finished_ = true;
00352   }, "");
00353 }
00354 
00355 // Tests a failed EXPECT_PRED_FORMAT1 where the
00356 // predicate-formatter is a function on a user-defined type (Bool).
00357 TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
00358   EXPECT_NONFATAL_FAILURE({  // NOLINT
00359     EXPECT_PRED_FORMAT1(PredFormatFunction1,
00360                         Bool(n1_++));
00361     finished_ = true;
00362   }, "");
00363 }
00364 
00365 // Tests a failed EXPECT_PRED_FORMAT1 where the
00366 // predicate-formatter is a functor on a built-in type (int).
00367 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
00368   EXPECT_NONFATAL_FAILURE({  // NOLINT
00369     EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
00370                         n1_++);
00371     finished_ = true;
00372   }, "");
00373 }
00374 
00375 // Tests a failed EXPECT_PRED_FORMAT1 where the
00376 // predicate-formatter is a functor on a user-defined type (Bool).
00377 TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
00378   EXPECT_NONFATAL_FAILURE({  // NOLINT
00379     EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
00380                         Bool(n1_++));
00381     finished_ = true;
00382   }, "");
00383 }
00384 
00385 // Tests a successful ASSERT_PRED_FORMAT1 where the
00386 // predicate-formatter is a function on a built-in type (int).
00387 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
00388   ASSERT_PRED_FORMAT1(PredFormatFunction1,
00389                       ++n1_);
00390   finished_ = true;
00391 }
00392 
00393 // Tests a successful ASSERT_PRED_FORMAT1 where the
00394 // predicate-formatter is a function on a user-defined type (Bool).
00395 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
00396   ASSERT_PRED_FORMAT1(PredFormatFunction1,
00397                       Bool(++n1_));
00398   finished_ = true;
00399 }
00400 
00401 // Tests a successful ASSERT_PRED_FORMAT1 where the
00402 // predicate-formatter is a functor on a built-in type (int).
00403 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
00404   ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
00405                       ++n1_);
00406   finished_ = true;
00407 }
00408 
00409 // Tests a successful ASSERT_PRED_FORMAT1 where the
00410 // predicate-formatter is a functor on a user-defined type (Bool).
00411 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
00412   ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
00413                       Bool(++n1_));
00414   finished_ = true;
00415 }
00416 
00417 // Tests a failed ASSERT_PRED_FORMAT1 where the
00418 // predicate-formatter is a function on a built-in type (int).
00419 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
00420   expected_to_finish_ = false;
00421   EXPECT_FATAL_FAILURE({  // NOLINT
00422     ASSERT_PRED_FORMAT1(PredFormatFunction1,
00423                         n1_++);
00424     finished_ = true;
00425   }, "");
00426 }
00427 
00428 // Tests a failed ASSERT_PRED_FORMAT1 where the
00429 // predicate-formatter is a function on a user-defined type (Bool).
00430 TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
00431   expected_to_finish_ = false;
00432   EXPECT_FATAL_FAILURE({  // NOLINT
00433     ASSERT_PRED_FORMAT1(PredFormatFunction1,
00434                         Bool(n1_++));
00435     finished_ = true;
00436   }, "");
00437 }
00438 
00439 // Tests a failed ASSERT_PRED_FORMAT1 where the
00440 // predicate-formatter is a functor on a built-in type (int).
00441 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
00442   expected_to_finish_ = false;
00443   EXPECT_FATAL_FAILURE({  // NOLINT
00444     ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
00445                         n1_++);
00446     finished_ = true;
00447   }, "");
00448 }
00449 
00450 // Tests a failed ASSERT_PRED_FORMAT1 where the
00451 // predicate-formatter is a functor on a user-defined type (Bool).
00452 TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
00453   expected_to_finish_ = false;
00454   EXPECT_FATAL_FAILURE({  // NOLINT
00455     ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
00456                         Bool(n1_++));
00457     finished_ = true;
00458   }, "");
00459 }
00460 // Sample functions/functors for testing binary predicate assertions.
00461 
00462 // A binary predicate function.
00463 template <typename T1, typename T2>
00464 bool PredFunction2(T1 v1, T2 v2) {
00465   return v1 + v2 > 0;
00466 }
00467 
00468 // The following two functions are needed to circumvent a bug in
00469 // gcc 2.95.3, which sometimes has problem with the above template
00470 // function.
00471 bool PredFunction2Int(int v1, int v2) {
00472   return v1 + v2 > 0;
00473 }
00474 bool PredFunction2Bool(Bool v1, Bool v2) {
00475   return v1 + v2 > 0;
00476 }
00477 
00478 // A binary predicate functor.
00479 struct PredFunctor2 {
00480   template <typename T1, typename T2>
00481   bool operator()(const T1& v1,
00482                   const T2& v2) {
00483     return v1 + v2 > 0;
00484   }
00485 };
00486 
00487 // A binary predicate-formatter function.
00488 template <typename T1, typename T2>
00489 testing::AssertionResult PredFormatFunction2(const char* e1,
00490                                              const char* e2,
00491                                              const T1& v1,
00492                                              const T2& v2) {
00493   if (PredFunction2(v1, v2))
00494     return testing::AssertionSuccess();
00495 
00496   return testing::AssertionFailure()
00497       << e1 << " + " << e2
00498       << " is expected to be positive, but evaluates to "
00499       << v1 + v2 << ".";
00500 }
00501 
00502 // A binary predicate-formatter functor.
00503 struct PredFormatFunctor2 {
00504   template <typename T1, typename T2>
00505   testing::AssertionResult operator()(const char* e1,
00506                                       const char* e2,
00507                                       const T1& v1,
00508                                       const T2& v2) const {
00509     return PredFormatFunction2(e1, e2, v1, v2);
00510   }
00511 };
00512 
00513 // Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
00514 
00515 class Predicate2Test : public testing::Test {
00516  protected:
00517   virtual void SetUp() {
00518     expected_to_finish_ = true;
00519     finished_ = false;
00520     n1_ = n2_ = 0;
00521   }
00522 
00523   virtual void TearDown() {
00524     // Verifies that each of the predicate's arguments was evaluated
00525     // exactly once.
00526     EXPECT_EQ(1, n1_) <<
00527         "The predicate assertion didn't evaluate argument 2 "
00528         "exactly once.";
00529     EXPECT_EQ(1, n2_) <<
00530         "The predicate assertion didn't evaluate argument 3 "
00531         "exactly once.";
00532 
00533     // Verifies that the control flow in the test function is expected.
00534     if (expected_to_finish_ && !finished_) {
00535       FAIL() << "The predicate assertion unexpactedly aborted the test.";
00536     } else if (!expected_to_finish_ && finished_) {
00537       FAIL() << "The failed predicate assertion didn't abort the test "
00538                 "as expected.";
00539     }
00540   }
00541 
00542   // true iff the test function is expected to run to finish.
00543   static bool expected_to_finish_;
00544 
00545   // true iff the test function did run to finish.
00546   static bool finished_;
00547 
00548   static int n1_;
00549   static int n2_;
00550 };
00551 
00552 bool Predicate2Test::expected_to_finish_;
00553 bool Predicate2Test::finished_;
00554 int Predicate2Test::n1_;
00555 int Predicate2Test::n2_;
00556 
00557 typedef Predicate2Test EXPECT_PRED_FORMAT2Test;
00558 typedef Predicate2Test ASSERT_PRED_FORMAT2Test;
00559 typedef Predicate2Test EXPECT_PRED2Test;
00560 typedef Predicate2Test ASSERT_PRED2Test;
00561 
00562 // Tests a successful EXPECT_PRED2 where the
00563 // predicate-formatter is a function on a built-in type (int).
00564 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
00565   EXPECT_PRED2(PredFunction2Int,
00566                ++n1_,
00567                ++n2_);
00568   finished_ = true;
00569 }
00570 
00571 // Tests a successful EXPECT_PRED2 where the
00572 // predicate-formatter is a function on a user-defined type (Bool).
00573 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
00574   EXPECT_PRED2(PredFunction2Bool,
00575                Bool(++n1_),
00576                Bool(++n2_));
00577   finished_ = true;
00578 }
00579 
00580 // Tests a successful EXPECT_PRED2 where the
00581 // predicate-formatter is a functor on a built-in type (int).
00582 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
00583   EXPECT_PRED2(PredFunctor2(),
00584                ++n1_,
00585                ++n2_);
00586   finished_ = true;
00587 }
00588 
00589 // Tests a successful EXPECT_PRED2 where the
00590 // predicate-formatter is a functor on a user-defined type (Bool).
00591 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
00592   EXPECT_PRED2(PredFunctor2(),
00593                Bool(++n1_),
00594                Bool(++n2_));
00595   finished_ = true;
00596 }
00597 
00598 // Tests a failed EXPECT_PRED2 where the
00599 // predicate-formatter is a function on a built-in type (int).
00600 TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
00601   EXPECT_NONFATAL_FAILURE({  // NOLINT
00602     EXPECT_PRED2(PredFunction2Int,
00603                  n1_++,
00604                  n2_++);
00605     finished_ = true;
00606   }, "");
00607 }
00608 
00609 // Tests a failed EXPECT_PRED2 where the
00610 // predicate-formatter is a function on a user-defined type (Bool).
00611 TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
00612   EXPECT_NONFATAL_FAILURE({  // NOLINT
00613     EXPECT_PRED2(PredFunction2Bool,
00614                  Bool(n1_++),
00615                  Bool(n2_++));
00616     finished_ = true;
00617   }, "");
00618 }
00619 
00620 // Tests a failed EXPECT_PRED2 where the
00621 // predicate-formatter is a functor on a built-in type (int).
00622 TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
00623   EXPECT_NONFATAL_FAILURE({  // NOLINT
00624     EXPECT_PRED2(PredFunctor2(),
00625                  n1_++,
00626                  n2_++);
00627     finished_ = true;
00628   }, "");
00629 }
00630 
00631 // Tests a failed EXPECT_PRED2 where the
00632 // predicate-formatter is a functor on a user-defined type (Bool).
00633 TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
00634   EXPECT_NONFATAL_FAILURE({  // NOLINT
00635     EXPECT_PRED2(PredFunctor2(),
00636                  Bool(n1_++),
00637                  Bool(n2_++));
00638     finished_ = true;
00639   }, "");
00640 }
00641 
00642 // Tests a successful ASSERT_PRED2 where the
00643 // predicate-formatter is a function on a built-in type (int).
00644 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
00645   ASSERT_PRED2(PredFunction2Int,
00646                ++n1_,
00647                ++n2_);
00648   finished_ = true;
00649 }
00650 
00651 // Tests a successful ASSERT_PRED2 where the
00652 // predicate-formatter is a function on a user-defined type (Bool).
00653 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
00654   ASSERT_PRED2(PredFunction2Bool,
00655                Bool(++n1_),
00656                Bool(++n2_));
00657   finished_ = true;
00658 }
00659 
00660 // Tests a successful ASSERT_PRED2 where the
00661 // predicate-formatter is a functor on a built-in type (int).
00662 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
00663   ASSERT_PRED2(PredFunctor2(),
00664                ++n1_,
00665                ++n2_);
00666   finished_ = true;
00667 }
00668 
00669 // Tests a successful ASSERT_PRED2 where the
00670 // predicate-formatter is a functor on a user-defined type (Bool).
00671 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
00672   ASSERT_PRED2(PredFunctor2(),
00673                Bool(++n1_),
00674                Bool(++n2_));
00675   finished_ = true;
00676 }
00677 
00678 // Tests a failed ASSERT_PRED2 where the
00679 // predicate-formatter is a function on a built-in type (int).
00680 TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
00681   expected_to_finish_ = false;
00682   EXPECT_FATAL_FAILURE({  // NOLINT
00683     ASSERT_PRED2(PredFunction2Int,
00684                  n1_++,
00685                  n2_++);
00686     finished_ = true;
00687   }, "");
00688 }
00689 
00690 // Tests a failed ASSERT_PRED2 where the
00691 // predicate-formatter is a function on a user-defined type (Bool).
00692 TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
00693   expected_to_finish_ = false;
00694   EXPECT_FATAL_FAILURE({  // NOLINT
00695     ASSERT_PRED2(PredFunction2Bool,
00696                  Bool(n1_++),
00697                  Bool(n2_++));
00698     finished_ = true;
00699   }, "");
00700 }
00701 
00702 // Tests a failed ASSERT_PRED2 where the
00703 // predicate-formatter is a functor on a built-in type (int).
00704 TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
00705   expected_to_finish_ = false;
00706   EXPECT_FATAL_FAILURE({  // NOLINT
00707     ASSERT_PRED2(PredFunctor2(),
00708                  n1_++,
00709                  n2_++);
00710     finished_ = true;
00711   }, "");
00712 }
00713 
00714 // Tests a failed ASSERT_PRED2 where the
00715 // predicate-formatter is a functor on a user-defined type (Bool).
00716 TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
00717   expected_to_finish_ = false;
00718   EXPECT_FATAL_FAILURE({  // NOLINT
00719     ASSERT_PRED2(PredFunctor2(),
00720                  Bool(n1_++),
00721                  Bool(n2_++));
00722     finished_ = true;
00723   }, "");
00724 }
00725 
00726 // Tests a successful EXPECT_PRED_FORMAT2 where the
00727 // predicate-formatter is a function on a built-in type (int).
00728 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
00729   EXPECT_PRED_FORMAT2(PredFormatFunction2,
00730                       ++n1_,
00731                       ++n2_);
00732   finished_ = true;
00733 }
00734 
00735 // Tests a successful EXPECT_PRED_FORMAT2 where the
00736 // predicate-formatter is a function on a user-defined type (Bool).
00737 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
00738   EXPECT_PRED_FORMAT2(PredFormatFunction2,
00739                       Bool(++n1_),
00740                       Bool(++n2_));
00741   finished_ = true;
00742 }
00743 
00744 // Tests a successful EXPECT_PRED_FORMAT2 where the
00745 // predicate-formatter is a functor on a built-in type (int).
00746 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
00747   EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
00748                       ++n1_,
00749                       ++n2_);
00750   finished_ = true;
00751 }
00752 
00753 // Tests a successful EXPECT_PRED_FORMAT2 where the
00754 // predicate-formatter is a functor on a user-defined type (Bool).
00755 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
00756   EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
00757                       Bool(++n1_),
00758                       Bool(++n2_));
00759   finished_ = true;
00760 }
00761 
00762 // Tests a failed EXPECT_PRED_FORMAT2 where the
00763 // predicate-formatter is a function on a built-in type (int).
00764 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
00765   EXPECT_NONFATAL_FAILURE({  // NOLINT
00766     EXPECT_PRED_FORMAT2(PredFormatFunction2,
00767                         n1_++,
00768                         n2_++);
00769     finished_ = true;
00770   }, "");
00771 }
00772 
00773 // Tests a failed EXPECT_PRED_FORMAT2 where the
00774 // predicate-formatter is a function on a user-defined type (Bool).
00775 TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
00776   EXPECT_NONFATAL_FAILURE({  // NOLINT
00777     EXPECT_PRED_FORMAT2(PredFormatFunction2,
00778                         Bool(n1_++),
00779                         Bool(n2_++));
00780     finished_ = true;
00781   }, "");
00782 }
00783 
00784 // Tests a failed EXPECT_PRED_FORMAT2 where the
00785 // predicate-formatter is a functor on a built-in type (int).
00786 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
00787   EXPECT_NONFATAL_FAILURE({  // NOLINT
00788     EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
00789                         n1_++,
00790                         n2_++);
00791     finished_ = true;
00792   }, "");
00793 }
00794 
00795 // Tests a failed EXPECT_PRED_FORMAT2 where the
00796 // predicate-formatter is a functor on a user-defined type (Bool).
00797 TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
00798   EXPECT_NONFATAL_FAILURE({  // NOLINT
00799     EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
00800                         Bool(n1_++),
00801                         Bool(n2_++));
00802     finished_ = true;
00803   }, "");
00804 }
00805 
00806 // Tests a successful ASSERT_PRED_FORMAT2 where the
00807 // predicate-formatter is a function on a built-in type (int).
00808 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
00809   ASSERT_PRED_FORMAT2(PredFormatFunction2,
00810                       ++n1_,
00811                       ++n2_);
00812   finished_ = true;
00813 }
00814 
00815 // Tests a successful ASSERT_PRED_FORMAT2 where the
00816 // predicate-formatter is a function on a user-defined type (Bool).
00817 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
00818   ASSERT_PRED_FORMAT2(PredFormatFunction2,
00819                       Bool(++n1_),
00820                       Bool(++n2_));
00821   finished_ = true;
00822 }
00823 
00824 // Tests a successful ASSERT_PRED_FORMAT2 where the
00825 // predicate-formatter is a functor on a built-in type (int).
00826 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
00827   ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
00828                       ++n1_,
00829                       ++n2_);
00830   finished_ = true;
00831 }
00832 
00833 // Tests a successful ASSERT_PRED_FORMAT2 where the
00834 // predicate-formatter is a functor on a user-defined type (Bool).
00835 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
00836   ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
00837                       Bool(++n1_),
00838                       Bool(++n2_));
00839   finished_ = true;
00840 }
00841 
00842 // Tests a failed ASSERT_PRED_FORMAT2 where the
00843 // predicate-formatter is a function on a built-in type (int).
00844 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
00845   expected_to_finish_ = false;
00846   EXPECT_FATAL_FAILURE({  // NOLINT
00847     ASSERT_PRED_FORMAT2(PredFormatFunction2,
00848                         n1_++,
00849                         n2_++);
00850     finished_ = true;
00851   }, "");
00852 }
00853 
00854 // Tests a failed ASSERT_PRED_FORMAT2 where the
00855 // predicate-formatter is a function on a user-defined type (Bool).
00856 TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
00857   expected_to_finish_ = false;
00858   EXPECT_FATAL_FAILURE({  // NOLINT
00859     ASSERT_PRED_FORMAT2(PredFormatFunction2,
00860                         Bool(n1_++),
00861                         Bool(n2_++));
00862     finished_ = true;
00863   }, "");
00864 }
00865 
00866 // Tests a failed ASSERT_PRED_FORMAT2 where the
00867 // predicate-formatter is a functor on a built-in type (int).
00868 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
00869   expected_to_finish_ = false;
00870   EXPECT_FATAL_FAILURE({  // NOLINT
00871     ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
00872                         n1_++,
00873                         n2_++);
00874     finished_ = true;
00875   }, "");
00876 }
00877 
00878 // Tests a failed ASSERT_PRED_FORMAT2 where the
00879 // predicate-formatter is a functor on a user-defined type (Bool).
00880 TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
00881   expected_to_finish_ = false;
00882   EXPECT_FATAL_FAILURE({  // NOLINT
00883     ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
00884                         Bool(n1_++),
00885                         Bool(n2_++));
00886     finished_ = true;
00887   }, "");
00888 }
00889 // Sample functions/functors for testing ternary predicate assertions.
00890 
00891 // A ternary predicate function.
00892 template <typename T1, typename T2, typename T3>
00893 bool PredFunction3(T1 v1, T2 v2, T3 v3) {
00894   return v1 + v2 + v3 > 0;
00895 }
00896 
00897 // The following two functions are needed to circumvent a bug in
00898 // gcc 2.95.3, which sometimes has problem with the above template
00899 // function.
00900 bool PredFunction3Int(int v1, int v2, int v3) {
00901   return v1 + v2 + v3 > 0;
00902 }
00903 bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) {
00904   return v1 + v2 + v3 > 0;
00905 }
00906 
00907 // A ternary predicate functor.
00908 struct PredFunctor3 {
00909   template <typename T1, typename T2, typename T3>
00910   bool operator()(const T1& v1,
00911                   const T2& v2,
00912                   const T3& v3) {
00913     return v1 + v2 + v3 > 0;
00914   }
00915 };
00916 
00917 // A ternary predicate-formatter function.
00918 template <typename T1, typename T2, typename T3>
00919 testing::AssertionResult PredFormatFunction3(const char* e1,
00920                                              const char* e2,
00921                                              const char* e3,
00922                                              const T1& v1,
00923                                              const T2& v2,
00924                                              const T3& v3) {
00925   if (PredFunction3(v1, v2, v3))
00926     return testing::AssertionSuccess();
00927 
00928   return testing::AssertionFailure()
00929       << e1 << " + " << e2 << " + " << e3
00930       << " is expected to be positive, but evaluates to "
00931       << v1 + v2 + v3 << ".";
00932 }
00933 
00934 // A ternary predicate-formatter functor.
00935 struct PredFormatFunctor3 {
00936   template <typename T1, typename T2, typename T3>
00937   testing::AssertionResult operator()(const char* e1,
00938                                       const char* e2,
00939                                       const char* e3,
00940                                       const T1& v1,
00941                                       const T2& v2,
00942                                       const T3& v3) const {
00943     return PredFormatFunction3(e1, e2, e3, v1, v2, v3);
00944   }
00945 };
00946 
00947 // Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
00948 
00949 class Predicate3Test : public testing::Test {
00950  protected:
00951   virtual void SetUp() {
00952     expected_to_finish_ = true;
00953     finished_ = false;
00954     n1_ = n2_ = n3_ = 0;
00955   }
00956 
00957   virtual void TearDown() {
00958     // Verifies that each of the predicate's arguments was evaluated
00959     // exactly once.
00960     EXPECT_EQ(1, n1_) <<
00961         "The predicate assertion didn't evaluate argument 2 "
00962         "exactly once.";
00963     EXPECT_EQ(1, n2_) <<
00964         "The predicate assertion didn't evaluate argument 3 "
00965         "exactly once.";
00966     EXPECT_EQ(1, n3_) <<
00967         "The predicate assertion didn't evaluate argument 4 "
00968         "exactly once.";
00969 
00970     // Verifies that the control flow in the test function is expected.
00971     if (expected_to_finish_ && !finished_) {
00972       FAIL() << "The predicate assertion unexpactedly aborted the test.";
00973     } else if (!expected_to_finish_ && finished_) {
00974       FAIL() << "The failed predicate assertion didn't abort the test "
00975                 "as expected.";
00976     }
00977   }
00978 
00979   // true iff the test function is expected to run to finish.
00980   static bool expected_to_finish_;
00981 
00982   // true iff the test function did run to finish.
00983   static bool finished_;
00984 
00985   static int n1_;
00986   static int n2_;
00987   static int n3_;
00988 };
00989 
00990 bool Predicate3Test::expected_to_finish_;
00991 bool Predicate3Test::finished_;
00992 int Predicate3Test::n1_;
00993 int Predicate3Test::n2_;
00994 int Predicate3Test::n3_;
00995 
00996 typedef Predicate3Test EXPECT_PRED_FORMAT3Test;
00997 typedef Predicate3Test ASSERT_PRED_FORMAT3Test;
00998 typedef Predicate3Test EXPECT_PRED3Test;
00999 typedef Predicate3Test ASSERT_PRED3Test;
01000 
01001 // Tests a successful EXPECT_PRED3 where the
01002 // predicate-formatter is a function on a built-in type (int).
01003 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
01004   EXPECT_PRED3(PredFunction3Int,
01005                ++n1_,
01006                ++n2_,
01007                ++n3_);
01008   finished_ = true;
01009 }
01010 
01011 // Tests a successful EXPECT_PRED3 where the
01012 // predicate-formatter is a function on a user-defined type (Bool).
01013 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
01014   EXPECT_PRED3(PredFunction3Bool,
01015                Bool(++n1_),
01016                Bool(++n2_),
01017                Bool(++n3_));
01018   finished_ = true;
01019 }
01020 
01021 // Tests a successful EXPECT_PRED3 where the
01022 // predicate-formatter is a functor on a built-in type (int).
01023 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
01024   EXPECT_PRED3(PredFunctor3(),
01025                ++n1_,
01026                ++n2_,
01027                ++n3_);
01028   finished_ = true;
01029 }
01030 
01031 // Tests a successful EXPECT_PRED3 where the
01032 // predicate-formatter is a functor on a user-defined type (Bool).
01033 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
01034   EXPECT_PRED3(PredFunctor3(),
01035                Bool(++n1_),
01036                Bool(++n2_),
01037                Bool(++n3_));
01038   finished_ = true;
01039 }
01040 
01041 // Tests a failed EXPECT_PRED3 where the
01042 // predicate-formatter is a function on a built-in type (int).
01043 TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
01044   EXPECT_NONFATAL_FAILURE({  // NOLINT
01045     EXPECT_PRED3(PredFunction3Int,
01046                  n1_++,
01047                  n2_++,
01048                  n3_++);
01049     finished_ = true;
01050   }, "");
01051 }
01052 
01053 // Tests a failed EXPECT_PRED3 where the
01054 // predicate-formatter is a function on a user-defined type (Bool).
01055 TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
01056   EXPECT_NONFATAL_FAILURE({  // NOLINT
01057     EXPECT_PRED3(PredFunction3Bool,
01058                  Bool(n1_++),
01059                  Bool(n2_++),
01060                  Bool(n3_++));
01061     finished_ = true;
01062   }, "");
01063 }
01064 
01065 // Tests a failed EXPECT_PRED3 where the
01066 // predicate-formatter is a functor on a built-in type (int).
01067 TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
01068   EXPECT_NONFATAL_FAILURE({  // NOLINT
01069     EXPECT_PRED3(PredFunctor3(),
01070                  n1_++,
01071                  n2_++,
01072                  n3_++);
01073     finished_ = true;
01074   }, "");
01075 }
01076 
01077 // Tests a failed EXPECT_PRED3 where the
01078 // predicate-formatter is a functor on a user-defined type (Bool).
01079 TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
01080   EXPECT_NONFATAL_FAILURE({  // NOLINT
01081     EXPECT_PRED3(PredFunctor3(),
01082                  Bool(n1_++),
01083                  Bool(n2_++),
01084                  Bool(n3_++));
01085     finished_ = true;
01086   }, "");
01087 }
01088 
01089 // Tests a successful ASSERT_PRED3 where the
01090 // predicate-formatter is a function on a built-in type (int).
01091 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
01092   ASSERT_PRED3(PredFunction3Int,
01093                ++n1_,
01094                ++n2_,
01095                ++n3_);
01096   finished_ = true;
01097 }
01098 
01099 // Tests a successful ASSERT_PRED3 where the
01100 // predicate-formatter is a function on a user-defined type (Bool).
01101 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
01102   ASSERT_PRED3(PredFunction3Bool,
01103                Bool(++n1_),
01104                Bool(++n2_),
01105                Bool(++n3_));
01106   finished_ = true;
01107 }
01108 
01109 // Tests a successful ASSERT_PRED3 where the
01110 // predicate-formatter is a functor on a built-in type (int).
01111 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
01112   ASSERT_PRED3(PredFunctor3(),
01113                ++n1_,
01114                ++n2_,
01115                ++n3_);
01116   finished_ = true;
01117 }
01118 
01119 // Tests a successful ASSERT_PRED3 where the
01120 // predicate-formatter is a functor on a user-defined type (Bool).
01121 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
01122   ASSERT_PRED3(PredFunctor3(),
01123                Bool(++n1_),
01124                Bool(++n2_),
01125                Bool(++n3_));
01126   finished_ = true;
01127 }
01128 
01129 // Tests a failed ASSERT_PRED3 where the
01130 // predicate-formatter is a function on a built-in type (int).
01131 TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
01132   expected_to_finish_ = false;
01133   EXPECT_FATAL_FAILURE({  // NOLINT
01134     ASSERT_PRED3(PredFunction3Int,
01135                  n1_++,
01136                  n2_++,
01137                  n3_++);
01138     finished_ = true;
01139   }, "");
01140 }
01141 
01142 // Tests a failed ASSERT_PRED3 where the
01143 // predicate-formatter is a function on a user-defined type (Bool).
01144 TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
01145   expected_to_finish_ = false;
01146   EXPECT_FATAL_FAILURE({  // NOLINT
01147     ASSERT_PRED3(PredFunction3Bool,
01148                  Bool(n1_++),
01149                  Bool(n2_++),
01150                  Bool(n3_++));
01151     finished_ = true;
01152   }, "");
01153 }
01154 
01155 // Tests a failed ASSERT_PRED3 where the
01156 // predicate-formatter is a functor on a built-in type (int).
01157 TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
01158   expected_to_finish_ = false;
01159   EXPECT_FATAL_FAILURE({  // NOLINT
01160     ASSERT_PRED3(PredFunctor3(),
01161                  n1_++,
01162                  n2_++,
01163                  n3_++);
01164     finished_ = true;
01165   }, "");
01166 }
01167 
01168 // Tests a failed ASSERT_PRED3 where the
01169 // predicate-formatter is a functor on a user-defined type (Bool).
01170 TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
01171   expected_to_finish_ = false;
01172   EXPECT_FATAL_FAILURE({  // NOLINT
01173     ASSERT_PRED3(PredFunctor3(),
01174                  Bool(n1_++),
01175                  Bool(n2_++),
01176                  Bool(n3_++));
01177     finished_ = true;
01178   }, "");
01179 }
01180 
01181 // Tests a successful EXPECT_PRED_FORMAT3 where the
01182 // predicate-formatter is a function on a built-in type (int).
01183 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
01184   EXPECT_PRED_FORMAT3(PredFormatFunction3,
01185                       ++n1_,
01186                       ++n2_,
01187                       ++n3_);
01188   finished_ = true;
01189 }
01190 
01191 // Tests a successful EXPECT_PRED_FORMAT3 where the
01192 // predicate-formatter is a function on a user-defined type (Bool).
01193 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
01194   EXPECT_PRED_FORMAT3(PredFormatFunction3,
01195                       Bool(++n1_),
01196                       Bool(++n2_),
01197                       Bool(++n3_));
01198   finished_ = true;
01199 }
01200 
01201 // Tests a successful EXPECT_PRED_FORMAT3 where the
01202 // predicate-formatter is a functor on a built-in type (int).
01203 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
01204   EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
01205                       ++n1_,
01206                       ++n2_,
01207                       ++n3_);
01208   finished_ = true;
01209 }
01210 
01211 // Tests a successful EXPECT_PRED_FORMAT3 where the
01212 // predicate-formatter is a functor on a user-defined type (Bool).
01213 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
01214   EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
01215                       Bool(++n1_),
01216                       Bool(++n2_),
01217                       Bool(++n3_));
01218   finished_ = true;
01219 }
01220 
01221 // Tests a failed EXPECT_PRED_FORMAT3 where the
01222 // predicate-formatter is a function on a built-in type (int).
01223 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
01224   EXPECT_NONFATAL_FAILURE({  // NOLINT
01225     EXPECT_PRED_FORMAT3(PredFormatFunction3,
01226                         n1_++,
01227                         n2_++,
01228                         n3_++);
01229     finished_ = true;
01230   }, "");
01231 }
01232 
01233 // Tests a failed EXPECT_PRED_FORMAT3 where the
01234 // predicate-formatter is a function on a user-defined type (Bool).
01235 TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
01236   EXPECT_NONFATAL_FAILURE({  // NOLINT
01237     EXPECT_PRED_FORMAT3(PredFormatFunction3,
01238                         Bool(n1_++),
01239                         Bool(n2_++),
01240                         Bool(n3_++));
01241     finished_ = true;
01242   }, "");
01243 }
01244 
01245 // Tests a failed EXPECT_PRED_FORMAT3 where the
01246 // predicate-formatter is a functor on a built-in type (int).
01247 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
01248   EXPECT_NONFATAL_FAILURE({  // NOLINT
01249     EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
01250                         n1_++,
01251                         n2_++,
01252                         n3_++);
01253     finished_ = true;
01254   }, "");
01255 }
01256 
01257 // Tests a failed EXPECT_PRED_FORMAT3 where the
01258 // predicate-formatter is a functor on a user-defined type (Bool).
01259 TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
01260   EXPECT_NONFATAL_FAILURE({  // NOLINT
01261     EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
01262                         Bool(n1_++),
01263                         Bool(n2_++),
01264                         Bool(n3_++));
01265     finished_ = true;
01266   }, "");
01267 }
01268 
01269 // Tests a successful ASSERT_PRED_FORMAT3 where the
01270 // predicate-formatter is a function on a built-in type (int).
01271 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
01272   ASSERT_PRED_FORMAT3(PredFormatFunction3,
01273                       ++n1_,
01274                       ++n2_,
01275                       ++n3_);
01276   finished_ = true;
01277 }
01278 
01279 // Tests a successful ASSERT_PRED_FORMAT3 where the
01280 // predicate-formatter is a function on a user-defined type (Bool).
01281 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
01282   ASSERT_PRED_FORMAT3(PredFormatFunction3,
01283                       Bool(++n1_),
01284                       Bool(++n2_),
01285                       Bool(++n3_));
01286   finished_ = true;
01287 }
01288 
01289 // Tests a successful ASSERT_PRED_FORMAT3 where the
01290 // predicate-formatter is a functor on a built-in type (int).
01291 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
01292   ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
01293                       ++n1_,
01294                       ++n2_,
01295                       ++n3_);
01296   finished_ = true;
01297 }
01298 
01299 // Tests a successful ASSERT_PRED_FORMAT3 where the
01300 // predicate-formatter is a functor on a user-defined type (Bool).
01301 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
01302   ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
01303                       Bool(++n1_),
01304                       Bool(++n2_),
01305                       Bool(++n3_));
01306   finished_ = true;
01307 }
01308 
01309 // Tests a failed ASSERT_PRED_FORMAT3 where the
01310 // predicate-formatter is a function on a built-in type (int).
01311 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
01312   expected_to_finish_ = false;
01313   EXPECT_FATAL_FAILURE({  // NOLINT
01314     ASSERT_PRED_FORMAT3(PredFormatFunction3,
01315                         n1_++,
01316                         n2_++,
01317                         n3_++);
01318     finished_ = true;
01319   }, "");
01320 }
01321 
01322 // Tests a failed ASSERT_PRED_FORMAT3 where the
01323 // predicate-formatter is a function on a user-defined type (Bool).
01324 TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
01325   expected_to_finish_ = false;
01326   EXPECT_FATAL_FAILURE({  // NOLINT
01327     ASSERT_PRED_FORMAT3(PredFormatFunction3,
01328                         Bool(n1_++),
01329                         Bool(n2_++),
01330                         Bool(n3_++));
01331     finished_ = true;
01332   }, "");
01333 }
01334 
01335 // Tests a failed ASSERT_PRED_FORMAT3 where the
01336 // predicate-formatter is a functor on a built-in type (int).
01337 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
01338   expected_to_finish_ = false;
01339   EXPECT_FATAL_FAILURE({  // NOLINT
01340     ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
01341                         n1_++,
01342                         n2_++,
01343                         n3_++);
01344     finished_ = true;
01345   }, "");
01346 }
01347 
01348 // Tests a failed ASSERT_PRED_FORMAT3 where the
01349 // predicate-formatter is a functor on a user-defined type (Bool).
01350 TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
01351   expected_to_finish_ = false;
01352   EXPECT_FATAL_FAILURE({  // NOLINT
01353     ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
01354                         Bool(n1_++),
01355                         Bool(n2_++),
01356                         Bool(n3_++));
01357     finished_ = true;
01358   }, "");
01359 }
01360 // Sample functions/functors for testing 4-ary predicate assertions.
01361 
01362 // A 4-ary predicate function.
01363 template <typename T1, typename T2, typename T3, typename T4>
01364 bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
01365   return v1 + v2 + v3 + v4 > 0;
01366 }
01367 
01368 // The following two functions are needed to circumvent a bug in
01369 // gcc 2.95.3, which sometimes has problem with the above template
01370 // function.
01371 bool PredFunction4Int(int v1, int v2, int v3, int v4) {
01372   return v1 + v2 + v3 + v4 > 0;
01373 }
01374 bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
01375   return v1 + v2 + v3 + v4 > 0;
01376 }
01377 
01378 // A 4-ary predicate functor.
01379 struct PredFunctor4 {
01380   template <typename T1, typename T2, typename T3, typename T4>
01381   bool operator()(const T1& v1,
01382                   const T2& v2,
01383                   const T3& v3,
01384                   const T4& v4) {
01385     return v1 + v2 + v3 + v4 > 0;
01386   }
01387 };
01388 
01389 // A 4-ary predicate-formatter function.
01390 template <typename T1, typename T2, typename T3, typename T4>
01391 testing::AssertionResult PredFormatFunction4(const char* e1,
01392                                              const char* e2,
01393                                              const char* e3,
01394                                              const char* e4,
01395                                              const T1& v1,
01396                                              const T2& v2,
01397                                              const T3& v3,
01398                                              const T4& v4) {
01399   if (PredFunction4(v1, v2, v3, v4))
01400     return testing::AssertionSuccess();
01401 
01402   return testing::AssertionFailure()
01403       << e1 << " + " << e2 << " + " << e3 << " + " << e4
01404       << " is expected to be positive, but evaluates to "
01405       << v1 + v2 + v3 + v4 << ".";
01406 }
01407 
01408 // A 4-ary predicate-formatter functor.
01409 struct PredFormatFunctor4 {
01410   template <typename T1, typename T2, typename T3, typename T4>
01411   testing::AssertionResult operator()(const char* e1,
01412                                       const char* e2,
01413                                       const char* e3,
01414                                       const char* e4,
01415                                       const T1& v1,
01416                                       const T2& v2,
01417                                       const T3& v3,
01418                                       const T4& v4) const {
01419     return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);
01420   }
01421 };
01422 
01423 // Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
01424 
01425 class Predicate4Test : public testing::Test {
01426  protected:
01427   virtual void SetUp() {
01428     expected_to_finish_ = true;
01429     finished_ = false;
01430     n1_ = n2_ = n3_ = n4_ = 0;
01431   }
01432 
01433   virtual void TearDown() {
01434     // Verifies that each of the predicate's arguments was evaluated
01435     // exactly once.
01436     EXPECT_EQ(1, n1_) <<
01437         "The predicate assertion didn't evaluate argument 2 "
01438         "exactly once.";
01439     EXPECT_EQ(1, n2_) <<
01440         "The predicate assertion didn't evaluate argument 3 "
01441         "exactly once.";
01442     EXPECT_EQ(1, n3_) <<
01443         "The predicate assertion didn't evaluate argument 4 "
01444         "exactly once.";
01445     EXPECT_EQ(1, n4_) <<
01446         "The predicate assertion didn't evaluate argument 5 "
01447         "exactly once.";
01448 
01449     // Verifies that the control flow in the test function is expected.
01450     if (expected_to_finish_ && !finished_) {
01451       FAIL() << "The predicate assertion unexpactedly aborted the test.";
01452     } else if (!expected_to_finish_ && finished_) {
01453       FAIL() << "The failed predicate assertion didn't abort the test "
01454                 "as expected.";
01455     }
01456   }
01457 
01458   // true iff the test function is expected to run to finish.
01459   static bool expected_to_finish_;
01460 
01461   // true iff the test function did run to finish.
01462   static bool finished_;
01463 
01464   static int n1_;
01465   static int n2_;
01466   static int n3_;
01467   static int n4_;
01468 };
01469 
01470 bool Predicate4Test::expected_to_finish_;
01471 bool Predicate4Test::finished_;
01472 int Predicate4Test::n1_;
01473 int Predicate4Test::n2_;
01474 int Predicate4Test::n3_;
01475 int Predicate4Test::n4_;
01476 
01477 typedef Predicate4Test EXPECT_PRED_FORMAT4Test;
01478 typedef Predicate4Test ASSERT_PRED_FORMAT4Test;
01479 typedef Predicate4Test EXPECT_PRED4Test;
01480 typedef Predicate4Test ASSERT_PRED4Test;
01481 
01482 // Tests a successful EXPECT_PRED4 where the
01483 // predicate-formatter is a function on a built-in type (int).
01484 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
01485   EXPECT_PRED4(PredFunction4Int,
01486                ++n1_,
01487                ++n2_,
01488                ++n3_,
01489                ++n4_);
01490   finished_ = true;
01491 }
01492 
01493 // Tests a successful EXPECT_PRED4 where the
01494 // predicate-formatter is a function on a user-defined type (Bool).
01495 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
01496   EXPECT_PRED4(PredFunction4Bool,
01497                Bool(++n1_),
01498                Bool(++n2_),
01499                Bool(++n3_),
01500                Bool(++n4_));
01501   finished_ = true;
01502 }
01503 
01504 // Tests a successful EXPECT_PRED4 where the
01505 // predicate-formatter is a functor on a built-in type (int).
01506 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
01507   EXPECT_PRED4(PredFunctor4(),
01508                ++n1_,
01509                ++n2_,
01510                ++n3_,
01511                ++n4_);
01512   finished_ = true;
01513 }
01514 
01515 // Tests a successful EXPECT_PRED4 where the
01516 // predicate-formatter is a functor on a user-defined type (Bool).
01517 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
01518   EXPECT_PRED4(PredFunctor4(),
01519                Bool(++n1_),
01520                Bool(++n2_),
01521                Bool(++n3_),
01522                Bool(++n4_));
01523   finished_ = true;
01524 }
01525 
01526 // Tests a failed EXPECT_PRED4 where the
01527 // predicate-formatter is a function on a built-in type (int).
01528 TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
01529   EXPECT_NONFATAL_FAILURE({  // NOLINT
01530     EXPECT_PRED4(PredFunction4Int,
01531                  n1_++,
01532                  n2_++,
01533                  n3_++,
01534                  n4_++);
01535     finished_ = true;
01536   }, "");
01537 }
01538 
01539 // Tests a failed EXPECT_PRED4 where the
01540 // predicate-formatter is a function on a user-defined type (Bool).
01541 TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
01542   EXPECT_NONFATAL_FAILURE({  // NOLINT
01543     EXPECT_PRED4(PredFunction4Bool,
01544                  Bool(n1_++),
01545                  Bool(n2_++),
01546                  Bool(n3_++),
01547                  Bool(n4_++));
01548     finished_ = true;
01549   }, "");
01550 }
01551 
01552 // Tests a failed EXPECT_PRED4 where the
01553 // predicate-formatter is a functor on a built-in type (int).
01554 TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
01555   EXPECT_NONFATAL_FAILURE({  // NOLINT
01556     EXPECT_PRED4(PredFunctor4(),
01557                  n1_++,
01558                  n2_++,
01559                  n3_++,
01560                  n4_++);
01561     finished_ = true;
01562   }, "");
01563 }
01564 
01565 // Tests a failed EXPECT_PRED4 where the
01566 // predicate-formatter is a functor on a user-defined type (Bool).
01567 TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
01568   EXPECT_NONFATAL_FAILURE({  // NOLINT
01569     EXPECT_PRED4(PredFunctor4(),
01570                  Bool(n1_++),
01571                  Bool(n2_++),
01572                  Bool(n3_++),
01573                  Bool(n4_++));
01574     finished_ = true;
01575   }, "");
01576 }
01577 
01578 // Tests a successful ASSERT_PRED4 where the
01579 // predicate-formatter is a function on a built-in type (int).
01580 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
01581   ASSERT_PRED4(PredFunction4Int,
01582                ++n1_,
01583                ++n2_,
01584                ++n3_,
01585                ++n4_);
01586   finished_ = true;
01587 }
01588 
01589 // Tests a successful ASSERT_PRED4 where the
01590 // predicate-formatter is a function on a user-defined type (Bool).
01591 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
01592   ASSERT_PRED4(PredFunction4Bool,
01593                Bool(++n1_),
01594                Bool(++n2_),
01595                Bool(++n3_),
01596                Bool(++n4_));
01597   finished_ = true;
01598 }
01599 
01600 // Tests a successful ASSERT_PRED4 where the
01601 // predicate-formatter is a functor on a built-in type (int).
01602 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
01603   ASSERT_PRED4(PredFunctor4(),
01604                ++n1_,
01605                ++n2_,
01606                ++n3_,
01607                ++n4_);
01608   finished_ = true;
01609 }
01610 
01611 // Tests a successful ASSERT_PRED4 where the
01612 // predicate-formatter is a functor on a user-defined type (Bool).
01613 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
01614   ASSERT_PRED4(PredFunctor4(),
01615                Bool(++n1_),
01616                Bool(++n2_),
01617                Bool(++n3_),
01618                Bool(++n4_));
01619   finished_ = true;
01620 }
01621 
01622 // Tests a failed ASSERT_PRED4 where the
01623 // predicate-formatter is a function on a built-in type (int).
01624 TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
01625   expected_to_finish_ = false;
01626   EXPECT_FATAL_FAILURE({  // NOLINT
01627     ASSERT_PRED4(PredFunction4Int,
01628                  n1_++,
01629                  n2_++,
01630                  n3_++,
01631                  n4_++);
01632     finished_ = true;
01633   }, "");
01634 }
01635 
01636 // Tests a failed ASSERT_PRED4 where the
01637 // predicate-formatter is a function on a user-defined type (Bool).
01638 TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
01639   expected_to_finish_ = false;
01640   EXPECT_FATAL_FAILURE({  // NOLINT
01641     ASSERT_PRED4(PredFunction4Bool,
01642                  Bool(n1_++),
01643                  Bool(n2_++),
01644                  Bool(n3_++),
01645                  Bool(n4_++));
01646     finished_ = true;
01647   }, "");
01648 }
01649 
01650 // Tests a failed ASSERT_PRED4 where the
01651 // predicate-formatter is a functor on a built-in type (int).
01652 TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
01653   expected_to_finish_ = false;
01654   EXPECT_FATAL_FAILURE({  // NOLINT
01655     ASSERT_PRED4(PredFunctor4(),
01656                  n1_++,
01657                  n2_++,
01658                  n3_++,
01659                  n4_++);
01660     finished_ = true;
01661   }, "");
01662 }
01663 
01664 // Tests a failed ASSERT_PRED4 where the
01665 // predicate-formatter is a functor on a user-defined type (Bool).
01666 TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
01667   expected_to_finish_ = false;
01668   EXPECT_FATAL_FAILURE({  // NOLINT
01669     ASSERT_PRED4(PredFunctor4(),
01670                  Bool(n1_++),
01671                  Bool(n2_++),
01672                  Bool(n3_++),
01673                  Bool(n4_++));
01674     finished_ = true;
01675   }, "");
01676 }
01677 
01678 // Tests a successful EXPECT_PRED_FORMAT4 where the
01679 // predicate-formatter is a function on a built-in type (int).
01680 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
01681   EXPECT_PRED_FORMAT4(PredFormatFunction4,
01682                       ++n1_,
01683                       ++n2_,
01684                       ++n3_,
01685                       ++n4_);
01686   finished_ = true;
01687 }
01688 
01689 // Tests a successful EXPECT_PRED_FORMAT4 where the
01690 // predicate-formatter is a function on a user-defined type (Bool).
01691 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
01692   EXPECT_PRED_FORMAT4(PredFormatFunction4,
01693                       Bool(++n1_),
01694                       Bool(++n2_),
01695                       Bool(++n3_),
01696                       Bool(++n4_));
01697   finished_ = true;
01698 }
01699 
01700 // Tests a successful EXPECT_PRED_FORMAT4 where the
01701 // predicate-formatter is a functor on a built-in type (int).
01702 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
01703   EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
01704                       ++n1_,
01705                       ++n2_,
01706                       ++n3_,
01707                       ++n4_);
01708   finished_ = true;
01709 }
01710 
01711 // Tests a successful EXPECT_PRED_FORMAT4 where the
01712 // predicate-formatter is a functor on a user-defined type (Bool).
01713 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
01714   EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
01715                       Bool(++n1_),
01716                       Bool(++n2_),
01717                       Bool(++n3_),
01718                       Bool(++n4_));
01719   finished_ = true;
01720 }
01721 
01722 // Tests a failed EXPECT_PRED_FORMAT4 where the
01723 // predicate-formatter is a function on a built-in type (int).
01724 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
01725   EXPECT_NONFATAL_FAILURE({  // NOLINT
01726     EXPECT_PRED_FORMAT4(PredFormatFunction4,
01727                         n1_++,
01728                         n2_++,
01729                         n3_++,
01730                         n4_++);
01731     finished_ = true;
01732   }, "");
01733 }
01734 
01735 // Tests a failed EXPECT_PRED_FORMAT4 where the
01736 // predicate-formatter is a function on a user-defined type (Bool).
01737 TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
01738   EXPECT_NONFATAL_FAILURE({  // NOLINT
01739     EXPECT_PRED_FORMAT4(PredFormatFunction4,
01740                         Bool(n1_++),
01741                         Bool(n2_++),
01742                         Bool(n3_++),
01743                         Bool(n4_++));
01744     finished_ = true;
01745   }, "");
01746 }
01747 
01748 // Tests a failed EXPECT_PRED_FORMAT4 where the
01749 // predicate-formatter is a functor on a built-in type (int).
01750 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
01751   EXPECT_NONFATAL_FAILURE({  // NOLINT
01752     EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
01753                         n1_++,
01754                         n2_++,
01755                         n3_++,
01756                         n4_++);
01757     finished_ = true;
01758   }, "");
01759 }
01760 
01761 // Tests a failed EXPECT_PRED_FORMAT4 where the
01762 // predicate-formatter is a functor on a user-defined type (Bool).
01763 TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
01764   EXPECT_NONFATAL_FAILURE({  // NOLINT
01765     EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
01766                         Bool(n1_++),
01767                         Bool(n2_++),
01768                         Bool(n3_++),
01769                         Bool(n4_++));
01770     finished_ = true;
01771   }, "");
01772 }
01773 
01774 // Tests a successful ASSERT_PRED_FORMAT4 where the
01775 // predicate-formatter is a function on a built-in type (int).
01776 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
01777   ASSERT_PRED_FORMAT4(PredFormatFunction4,
01778                       ++n1_,
01779                       ++n2_,
01780                       ++n3_,
01781                       ++n4_);
01782   finished_ = true;
01783 }
01784 
01785 // Tests a successful ASSERT_PRED_FORMAT4 where the
01786 // predicate-formatter is a function on a user-defined type (Bool).
01787 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
01788   ASSERT_PRED_FORMAT4(PredFormatFunction4,
01789                       Bool(++n1_),
01790                       Bool(++n2_),
01791                       Bool(++n3_),
01792                       Bool(++n4_));
01793   finished_ = true;
01794 }
01795 
01796 // Tests a successful ASSERT_PRED_FORMAT4 where the
01797 // predicate-formatter is a functor on a built-in type (int).
01798 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
01799   ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
01800                       ++n1_,
01801                       ++n2_,
01802                       ++n3_,
01803                       ++n4_);
01804   finished_ = true;
01805 }
01806 
01807 // Tests a successful ASSERT_PRED_FORMAT4 where the
01808 // predicate-formatter is a functor on a user-defined type (Bool).
01809 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
01810   ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
01811                       Bool(++n1_),
01812                       Bool(++n2_),
01813                       Bool(++n3_),
01814                       Bool(++n4_));
01815   finished_ = true;
01816 }
01817 
01818 // Tests a failed ASSERT_PRED_FORMAT4 where the
01819 // predicate-formatter is a function on a built-in type (int).
01820 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
01821   expected_to_finish_ = false;
01822   EXPECT_FATAL_FAILURE({  // NOLINT
01823     ASSERT_PRED_FORMAT4(PredFormatFunction4,
01824                         n1_++,
01825                         n2_++,
01826                         n3_++,
01827                         n4_++);
01828     finished_ = true;
01829   }, "");
01830 }
01831 
01832 // Tests a failed ASSERT_PRED_FORMAT4 where the
01833 // predicate-formatter is a function on a user-defined type (Bool).
01834 TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
01835   expected_to_finish_ = false;
01836   EXPECT_FATAL_FAILURE({  // NOLINT
01837     ASSERT_PRED_FORMAT4(PredFormatFunction4,
01838                         Bool(n1_++),
01839                         Bool(n2_++),
01840                         Bool(n3_++),
01841                         Bool(n4_++));
01842     finished_ = true;
01843   }, "");
01844 }
01845 
01846 // Tests a failed ASSERT_PRED_FORMAT4 where the
01847 // predicate-formatter is a functor on a built-in type (int).
01848 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
01849   expected_to_finish_ = false;
01850   EXPECT_FATAL_FAILURE({  // NOLINT
01851     ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
01852                         n1_++,
01853                         n2_++,
01854                         n3_++,
01855                         n4_++);
01856     finished_ = true;
01857   }, "");
01858 }
01859 
01860 // Tests a failed ASSERT_PRED_FORMAT4 where the
01861 // predicate-formatter is a functor on a user-defined type (Bool).
01862 TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
01863   expected_to_finish_ = false;
01864   EXPECT_FATAL_FAILURE({  // NOLINT
01865     ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
01866                         Bool(n1_++),
01867                         Bool(n2_++),
01868                         Bool(n3_++),
01869                         Bool(n4_++));
01870     finished_ = true;
01871   }, "");
01872 }
01873 // Sample functions/functors for testing 5-ary predicate assertions.
01874 
01875 // A 5-ary predicate function.
01876 template <typename T1, typename T2, typename T3, typename T4, typename T5>
01877 bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
01878   return v1 + v2 + v3 + v4 + v5 > 0;
01879 }
01880 
01881 // The following two functions are needed to circumvent a bug in
01882 // gcc 2.95.3, which sometimes has problem with the above template
01883 // function.
01884 bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
01885   return v1 + v2 + v3 + v4 + v5 > 0;
01886 }
01887 bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
01888   return v1 + v2 + v3 + v4 + v5 > 0;
01889 }
01890 
01891 // A 5-ary predicate functor.
01892 struct PredFunctor5 {
01893   template <typename T1, typename T2, typename T3, typename T4, typename T5>
01894   bool operator()(const T1& v1,
01895                   const T2& v2,
01896                   const T3& v3,
01897                   const T4& v4,
01898                   const T5& v5) {
01899     return v1 + v2 + v3 + v4 + v5 > 0;
01900   }
01901 };
01902 
01903 // A 5-ary predicate-formatter function.
01904 template <typename T1, typename T2, typename T3, typename T4, typename T5>
01905 testing::AssertionResult PredFormatFunction5(const char* e1,
01906                                              const char* e2,
01907                                              const char* e3,
01908                                              const char* e4,
01909                                              const char* e5,
01910                                              const T1& v1,
01911                                              const T2& v2,
01912                                              const T3& v3,
01913                                              const T4& v4,
01914                                              const T5& v5) {
01915   if (PredFunction5(v1, v2, v3, v4, v5))
01916     return testing::AssertionSuccess();
01917 
01918   return testing::AssertionFailure()
01919       << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
01920       << " is expected to be positive, but evaluates to "
01921       << v1 + v2 + v3 + v4 + v5 << ".";
01922 }
01923 
01924 // A 5-ary predicate-formatter functor.
01925 struct PredFormatFunctor5 {
01926   template <typename T1, typename T2, typename T3, typename T4, typename T5>
01927   testing::AssertionResult operator()(const char* e1,
01928                                       const char* e2,
01929                                       const char* e3,
01930                                       const char* e4,
01931                                       const char* e5,
01932                                       const T1& v1,
01933                                       const T2& v2,
01934                                       const T3& v3,
01935                                       const T4& v4,
01936                                       const T5& v5) const {
01937     return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);
01938   }
01939 };
01940 
01941 // Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
01942 
01943 class Predicate5Test : public testing::Test {
01944  protected:
01945   virtual void SetUp() {
01946     expected_to_finish_ = true;
01947     finished_ = false;
01948     n1_ = n2_ = n3_ = n4_ = n5_ = 0;
01949   }
01950 
01951   virtual void TearDown() {
01952     // Verifies that each of the predicate's arguments was evaluated
01953     // exactly once.
01954     EXPECT_EQ(1, n1_) <<
01955         "The predicate assertion didn't evaluate argument 2 "
01956         "exactly once.";
01957     EXPECT_EQ(1, n2_) <<
01958         "The predicate assertion didn't evaluate argument 3 "
01959         "exactly once.";
01960     EXPECT_EQ(1, n3_) <<
01961         "The predicate assertion didn't evaluate argument 4 "
01962         "exactly once.";
01963     EXPECT_EQ(1, n4_) <<
01964         "The predicate assertion didn't evaluate argument 5 "
01965         "exactly once.";
01966     EXPECT_EQ(1, n5_) <<
01967         "The predicate assertion didn't evaluate argument 6 "
01968         "exactly once.";
01969 
01970     // Verifies that the control flow in the test function is expected.
01971     if (expected_to_finish_ && !finished_) {
01972       FAIL() << "The predicate assertion unexpactedly aborted the test.";
01973     } else if (!expected_to_finish_ && finished_) {
01974       FAIL() << "The failed predicate assertion didn't abort the test "
01975                 "as expected.";
01976     }
01977   }
01978 
01979   // true iff the test function is expected to run to finish.
01980   static bool expected_to_finish_;
01981 
01982   // true iff the test function did run to finish.
01983   static bool finished_;
01984 
01985   static int n1_;
01986   static int n2_;
01987   static int n3_;
01988   static int n4_;
01989   static int n5_;
01990 };
01991 
01992 bool Predicate5Test::expected_to_finish_;
01993 bool Predicate5Test::finished_;
01994 int Predicate5Test::n1_;
01995 int Predicate5Test::n2_;
01996 int Predicate5Test::n3_;
01997 int Predicate5Test::n4_;
01998 int Predicate5Test::n5_;
01999 
02000 typedef Predicate5Test EXPECT_PRED_FORMAT5Test;
02001 typedef Predicate5Test ASSERT_PRED_FORMAT5Test;
02002 typedef Predicate5Test EXPECT_PRED5Test;
02003 typedef Predicate5Test ASSERT_PRED5Test;
02004 
02005 // Tests a successful EXPECT_PRED5 where the
02006 // predicate-formatter is a function on a built-in type (int).
02007 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
02008   EXPECT_PRED5(PredFunction5Int,
02009                ++n1_,
02010                ++n2_,
02011                ++n3_,
02012                ++n4_,
02013                ++n5_);
02014   finished_ = true;
02015 }
02016 
02017 // Tests a successful EXPECT_PRED5 where the
02018 // predicate-formatter is a function on a user-defined type (Bool).
02019 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
02020   EXPECT_PRED5(PredFunction5Bool,
02021                Bool(++n1_),
02022                Bool(++n2_),
02023                Bool(++n3_),
02024                Bool(++n4_),
02025                Bool(++n5_));
02026   finished_ = true;
02027 }
02028 
02029 // Tests a successful EXPECT_PRED5 where the
02030 // predicate-formatter is a functor on a built-in type (int).
02031 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
02032   EXPECT_PRED5(PredFunctor5(),
02033                ++n1_,
02034                ++n2_,
02035                ++n3_,
02036                ++n4_,
02037                ++n5_);
02038   finished_ = true;
02039 }
02040 
02041 // Tests a successful EXPECT_PRED5 where the
02042 // predicate-formatter is a functor on a user-defined type (Bool).
02043 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
02044   EXPECT_PRED5(PredFunctor5(),
02045                Bool(++n1_),
02046                Bool(++n2_),
02047                Bool(++n3_),
02048                Bool(++n4_),
02049                Bool(++n5_));
02050   finished_ = true;
02051 }
02052 
02053 // Tests a failed EXPECT_PRED5 where the
02054 // predicate-formatter is a function on a built-in type (int).
02055 TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
02056   EXPECT_NONFATAL_FAILURE({  // NOLINT
02057     EXPECT_PRED5(PredFunction5Int,
02058                  n1_++,
02059                  n2_++,
02060                  n3_++,
02061                  n4_++,
02062                  n5_++);
02063     finished_ = true;
02064   }, "");
02065 }
02066 
02067 // Tests a failed EXPECT_PRED5 where the
02068 // predicate-formatter is a function on a user-defined type (Bool).
02069 TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
02070   EXPECT_NONFATAL_FAILURE({  // NOLINT
02071     EXPECT_PRED5(PredFunction5Bool,
02072                  Bool(n1_++),
02073                  Bool(n2_++),
02074                  Bool(n3_++),
02075                  Bool(n4_++),
02076                  Bool(n5_++));
02077     finished_ = true;
02078   }, "");
02079 }
02080 
02081 // Tests a failed EXPECT_PRED5 where the
02082 // predicate-formatter is a functor on a built-in type (int).
02083 TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
02084   EXPECT_NONFATAL_FAILURE({  // NOLINT
02085     EXPECT_PRED5(PredFunctor5(),
02086                  n1_++,
02087                  n2_++,
02088                  n3_++,
02089                  n4_++,
02090                  n5_++);
02091     finished_ = true;
02092   }, "");
02093 }
02094 
02095 // Tests a failed EXPECT_PRED5 where the
02096 // predicate-formatter is a functor on a user-defined type (Bool).
02097 TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
02098   EXPECT_NONFATAL_FAILURE({  // NOLINT
02099     EXPECT_PRED5(PredFunctor5(),
02100                  Bool(n1_++),
02101                  Bool(n2_++),
02102                  Bool(n3_++),
02103                  Bool(n4_++),
02104                  Bool(n5_++));
02105     finished_ = true;
02106   }, "");
02107 }
02108 
02109 // Tests a successful ASSERT_PRED5 where the
02110 // predicate-formatter is a function on a built-in type (int).
02111 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
02112   ASSERT_PRED5(PredFunction5Int,
02113                ++n1_,
02114                ++n2_,
02115                ++n3_,
02116                ++n4_,
02117                ++n5_);
02118   finished_ = true;
02119 }
02120 
02121 // Tests a successful ASSERT_PRED5 where the
02122 // predicate-formatter is a function on a user-defined type (Bool).
02123 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
02124   ASSERT_PRED5(PredFunction5Bool,
02125                Bool(++n1_),
02126                Bool(++n2_),
02127                Bool(++n3_),
02128                Bool(++n4_),
02129                Bool(++n5_));
02130   finished_ = true;
02131 }
02132 
02133 // Tests a successful ASSERT_PRED5 where the
02134 // predicate-formatter is a functor on a built-in type (int).
02135 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
02136   ASSERT_PRED5(PredFunctor5(),
02137                ++n1_,
02138                ++n2_,
02139                ++n3_,
02140                ++n4_,
02141                ++n5_);
02142   finished_ = true;
02143 }
02144 
02145 // Tests a successful ASSERT_PRED5 where the
02146 // predicate-formatter is a functor on a user-defined type (Bool).
02147 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
02148   ASSERT_PRED5(PredFunctor5(),
02149                Bool(++n1_),
02150                Bool(++n2_),
02151                Bool(++n3_),
02152                Bool(++n4_),
02153                Bool(++n5_));
02154   finished_ = true;
02155 }
02156 
02157 // Tests a failed ASSERT_PRED5 where the
02158 // predicate-formatter is a function on a built-in type (int).
02159 TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
02160   expected_to_finish_ = false;
02161   EXPECT_FATAL_FAILURE({  // NOLINT
02162     ASSERT_PRED5(PredFunction5Int,
02163                  n1_++,
02164                  n2_++,
02165                  n3_++,
02166                  n4_++,
02167                  n5_++);
02168     finished_ = true;
02169   }, "");
02170 }
02171 
02172 // Tests a failed ASSERT_PRED5 where the
02173 // predicate-formatter is a function on a user-defined type (Bool).
02174 TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
02175   expected_to_finish_ = false;
02176   EXPECT_FATAL_FAILURE({  // NOLINT
02177     ASSERT_PRED5(PredFunction5Bool,
02178                  Bool(n1_++),
02179                  Bool(n2_++),
02180                  Bool(n3_++),
02181                  Bool(n4_++),
02182                  Bool(n5_++));
02183     finished_ = true;
02184   }, "");
02185 }
02186 
02187 // Tests a failed ASSERT_PRED5 where the
02188 // predicate-formatter is a functor on a built-in type (int).
02189 TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
02190   expected_to_finish_ = false;
02191   EXPECT_FATAL_FAILURE({  // NOLINT
02192     ASSERT_PRED5(PredFunctor5(),
02193                  n1_++,
02194                  n2_++,
02195                  n3_++,
02196                  n4_++,
02197                  n5_++);
02198     finished_ = true;
02199   }, "");
02200 }
02201 
02202 // Tests a failed ASSERT_PRED5 where the
02203 // predicate-formatter is a functor on a user-defined type (Bool).
02204 TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
02205   expected_to_finish_ = false;
02206   EXPECT_FATAL_FAILURE({  // NOLINT
02207     ASSERT_PRED5(PredFunctor5(),
02208                  Bool(n1_++),
02209                  Bool(n2_++),
02210                  Bool(n3_++),
02211                  Bool(n4_++),
02212                  Bool(n5_++));
02213     finished_ = true;
02214   }, "");
02215 }
02216 
02217 // Tests a successful EXPECT_PRED_FORMAT5 where the
02218 // predicate-formatter is a function on a built-in type (int).
02219 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
02220   EXPECT_PRED_FORMAT5(PredFormatFunction5,
02221                       ++n1_,
02222                       ++n2_,
02223                       ++n3_,
02224                       ++n4_,
02225                       ++n5_);
02226   finished_ = true;
02227 }
02228 
02229 // Tests a successful EXPECT_PRED_FORMAT5 where the
02230 // predicate-formatter is a function on a user-defined type (Bool).
02231 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
02232   EXPECT_PRED_FORMAT5(PredFormatFunction5,
02233                       Bool(++n1_),
02234                       Bool(++n2_),
02235                       Bool(++n3_),
02236                       Bool(++n4_),
02237                       Bool(++n5_));
02238   finished_ = true;
02239 }
02240 
02241 // Tests a successful EXPECT_PRED_FORMAT5 where the
02242 // predicate-formatter is a functor on a built-in type (int).
02243 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
02244   EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
02245                       ++n1_,
02246                       ++n2_,
02247                       ++n3_,
02248                       ++n4_,
02249                       ++n5_);
02250   finished_ = true;
02251 }
02252 
02253 // Tests a successful EXPECT_PRED_FORMAT5 where the
02254 // predicate-formatter is a functor on a user-defined type (Bool).
02255 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
02256   EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
02257                       Bool(++n1_),
02258                       Bool(++n2_),
02259                       Bool(++n3_),
02260                       Bool(++n4_),
02261                       Bool(++n5_));
02262   finished_ = true;
02263 }
02264 
02265 // Tests a failed EXPECT_PRED_FORMAT5 where the
02266 // predicate-formatter is a function on a built-in type (int).
02267 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
02268   EXPECT_NONFATAL_FAILURE({  // NOLINT
02269     EXPECT_PRED_FORMAT5(PredFormatFunction5,
02270                         n1_++,
02271                         n2_++,
02272                         n3_++,
02273                         n4_++,
02274                         n5_++);
02275     finished_ = true;
02276   }, "");
02277 }
02278 
02279 // Tests a failed EXPECT_PRED_FORMAT5 where the
02280 // predicate-formatter is a function on a user-defined type (Bool).
02281 TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
02282   EXPECT_NONFATAL_FAILURE({  // NOLINT
02283     EXPECT_PRED_FORMAT5(PredFormatFunction5,
02284                         Bool(n1_++),
02285                         Bool(n2_++),
02286                         Bool(n3_++),
02287                         Bool(n4_++),
02288                         Bool(n5_++));
02289     finished_ = true;
02290   }, "");
02291 }
02292 
02293 // Tests a failed EXPECT_PRED_FORMAT5 where the
02294 // predicate-formatter is a functor on a built-in type (int).
02295 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
02296   EXPECT_NONFATAL_FAILURE({  // NOLINT
02297     EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
02298                         n1_++,
02299                         n2_++,
02300                         n3_++,
02301                         n4_++,
02302                         n5_++);
02303     finished_ = true;
02304   }, "");
02305 }
02306 
02307 // Tests a failed EXPECT_PRED_FORMAT5 where the
02308 // predicate-formatter is a functor on a user-defined type (Bool).
02309 TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
02310   EXPECT_NONFATAL_FAILURE({  // NOLINT
02311     EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
02312                         Bool(n1_++),
02313                         Bool(n2_++),
02314                         Bool(n3_++),
02315                         Bool(n4_++),
02316                         Bool(n5_++));
02317     finished_ = true;
02318   }, "");
02319 }
02320 
02321 // Tests a successful ASSERT_PRED_FORMAT5 where the
02322 // predicate-formatter is a function on a built-in type (int).
02323 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
02324   ASSERT_PRED_FORMAT5(PredFormatFunction5,
02325                       ++n1_,
02326                       ++n2_,
02327                       ++n3_,
02328                       ++n4_,
02329                       ++n5_);
02330   finished_ = true;
02331 }
02332 
02333 // Tests a successful ASSERT_PRED_FORMAT5 where the
02334 // predicate-formatter is a function on a user-defined type (Bool).
02335 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
02336   ASSERT_PRED_FORMAT5(PredFormatFunction5,
02337                       Bool(++n1_),
02338                       Bool(++n2_),
02339                       Bool(++n3_),
02340                       Bool(++n4_),
02341                       Bool(++n5_));
02342   finished_ = true;
02343 }
02344 
02345 // Tests a successful ASSERT_PRED_FORMAT5 where the
02346 // predicate-formatter is a functor on a built-in type (int).
02347 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
02348   ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
02349                       ++n1_,
02350                       ++n2_,
02351                       ++n3_,
02352                       ++n4_,
02353                       ++n5_);
02354   finished_ = true;
02355 }
02356 
02357 // Tests a successful ASSERT_PRED_FORMAT5 where the
02358 // predicate-formatter is a functor on a user-defined type (Bool).
02359 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
02360   ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
02361                       Bool(++n1_),
02362                       Bool(++n2_),
02363                       Bool(++n3_),
02364                       Bool(++n4_),
02365                       Bool(++n5_));
02366   finished_ = true;
02367 }
02368 
02369 // Tests a failed ASSERT_PRED_FORMAT5 where the
02370 // predicate-formatter is a function on a built-in type (int).
02371 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
02372   expected_to_finish_ = false;
02373   EXPECT_FATAL_FAILURE({  // NOLINT
02374     ASSERT_PRED_FORMAT5(PredFormatFunction5,
02375                         n1_++,
02376                         n2_++,
02377                         n3_++,
02378                         n4_++,
02379                         n5_++);
02380     finished_ = true;
02381   }, "");
02382 }
02383 
02384 // Tests a failed ASSERT_PRED_FORMAT5 where the
02385 // predicate-formatter is a function on a user-defined type (Bool).
02386 TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
02387   expected_to_finish_ = false;
02388   EXPECT_FATAL_FAILURE({  // NOLINT
02389     ASSERT_PRED_FORMAT5(PredFormatFunction5,
02390                         Bool(n1_++),
02391                         Bool(n2_++),
02392                         Bool(n3_++),
02393                         Bool(n4_++),
02394                         Bool(n5_++));
02395     finished_ = true;
02396   }, "");
02397 }
02398 
02399 // Tests a failed ASSERT_PRED_FORMAT5 where the
02400 // predicate-formatter is a functor on a built-in type (int).
02401 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
02402   expected_to_finish_ = false;
02403   EXPECT_FATAL_FAILURE({  // NOLINT
02404     ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
02405                         n1_++,
02406                         n2_++,
02407                         n3_++,
02408                         n4_++,
02409                         n5_++);
02410     finished_ = true;
02411   }, "");
02412 }
02413 
02414 // Tests a failed ASSERT_PRED_FORMAT5 where the
02415 // predicate-formatter is a functor on a user-defined type (Bool).
02416 TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
02417   expected_to_finish_ = false;
02418   EXPECT_FATAL_FAILURE({  // NOLINT
02419     ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
02420                         Bool(n1_++),
02421                         Bool(n2_++),
02422                         Bool(n3_++),
02423                         Bool(n4_++),
02424                         Bool(n5_++));
02425     finished_ = true;
02426   }, "");
02427 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:04