media/webrtc/trunk/testing/gtest/test/gtest_pred_impl_unittest.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/testing/gtest/test/gtest_pred_impl_unittest.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,2427 @@
     1.4 +// Copyright 2006, Google Inc.
     1.5 +// All rights reserved.
     1.6 +//
     1.7 +// Redistribution and use in source and binary forms, with or without
     1.8 +// modification, are permitted provided that the following conditions are
     1.9 +// met:
    1.10 +//
    1.11 +//     * Redistributions of source code must retain the above copyright
    1.12 +// notice, this list of conditions and the following disclaimer.
    1.13 +//     * Redistributions in binary form must reproduce the above
    1.14 +// copyright notice, this list of conditions and the following disclaimer
    1.15 +// in the documentation and/or other materials provided with the
    1.16 +// distribution.
    1.17 +//     * Neither the name of Google Inc. nor the names of its
    1.18 +// contributors may be used to endorse or promote products derived from
    1.19 +// this software without specific prior written permission.
    1.20 +//
    1.21 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1.22 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    1.23 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.24 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    1.25 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.26 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.27 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.28 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    1.29 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.30 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.31 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.32 +
    1.33 +// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command
    1.34 +// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!
    1.35 +
    1.36 +// Regression test for gtest_pred_impl.h
    1.37 +//
    1.38 +// This file is generated by a script and quite long.  If you intend to
    1.39 +// learn how Google Test works by reading its unit tests, read
    1.40 +// gtest_unittest.cc instead.
    1.41 +//
    1.42 +// This is intended as a regression test for the Google Test predicate
    1.43 +// assertions.  We compile it as part of the gtest_unittest target
    1.44 +// only to keep the implementation tidy and compact, as it is quite
    1.45 +// involved to set up the stage for testing Google Test using Google
    1.46 +// Test itself.
    1.47 +//
    1.48 +// Currently, gtest_unittest takes ~11 seconds to run in the testing
    1.49 +// daemon.  In the future, if it grows too large and needs much more
    1.50 +// time to finish, we should consider separating this file into a
    1.51 +// stand-alone regression test.
    1.52 +
    1.53 +#include <iostream>
    1.54 +
    1.55 +#include "gtest/gtest.h"
    1.56 +#include "gtest/gtest-spi.h"
    1.57 +
    1.58 +// A user-defined data type.
    1.59 +struct Bool {
    1.60 +  explicit Bool(int val) : value(val != 0) {}
    1.61 +
    1.62 +  bool operator>(int n) const { return value > Bool(n).value; }
    1.63 +
    1.64 +  Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }
    1.65 +
    1.66 +  bool operator==(const Bool& rhs) const { return value == rhs.value; }
    1.67 +
    1.68 +  bool value;
    1.69 +};
    1.70 +
    1.71 +// Enables Bool to be used in assertions.
    1.72 +std::ostream& operator<<(std::ostream& os, const Bool& x) {
    1.73 +  return os << (x.value ? "true" : "false");
    1.74 +}
    1.75 +
    1.76 +// Sample functions/functors for testing unary predicate assertions.
    1.77 +
    1.78 +// A unary predicate function.
    1.79 +template <typename T1>
    1.80 +bool PredFunction1(T1 v1) {
    1.81 +  return v1 > 0;
    1.82 +}
    1.83 +
    1.84 +// The following two functions are needed to circumvent a bug in
    1.85 +// gcc 2.95.3, which sometimes has problem with the above template
    1.86 +// function.
    1.87 +bool PredFunction1Int(int v1) {
    1.88 +  return v1 > 0;
    1.89 +}
    1.90 +bool PredFunction1Bool(Bool v1) {
    1.91 +  return v1 > 0;
    1.92 +}
    1.93 +
    1.94 +// A unary predicate functor.
    1.95 +struct PredFunctor1 {
    1.96 +  template <typename T1>
    1.97 +  bool operator()(const T1& v1) {
    1.98 +    return v1 > 0;
    1.99 +  }
   1.100 +};
   1.101 +
   1.102 +// A unary predicate-formatter function.
   1.103 +template <typename T1>
   1.104 +testing::AssertionResult PredFormatFunction1(const char* e1,
   1.105 +                                             const T1& v1) {
   1.106 +  if (PredFunction1(v1))
   1.107 +    return testing::AssertionSuccess();
   1.108 +
   1.109 +  return testing::AssertionFailure()
   1.110 +      << e1
   1.111 +      << " is expected to be positive, but evaluates to "
   1.112 +      << v1 << ".";
   1.113 +}
   1.114 +
   1.115 +// A unary predicate-formatter functor.
   1.116 +struct PredFormatFunctor1 {
   1.117 +  template <typename T1>
   1.118 +  testing::AssertionResult operator()(const char* e1,
   1.119 +                                      const T1& v1) const {
   1.120 +    return PredFormatFunction1(e1, v1);
   1.121 +  }
   1.122 +};
   1.123 +
   1.124 +// Tests for {EXPECT|ASSERT}_PRED_FORMAT1.
   1.125 +
   1.126 +class Predicate1Test : public testing::Test {
   1.127 + protected:
   1.128 +  virtual void SetUp() {
   1.129 +    expected_to_finish_ = true;
   1.130 +    finished_ = false;
   1.131 +    n1_ = 0;
   1.132 +  }
   1.133 +
   1.134 +  virtual void TearDown() {
   1.135 +    // Verifies that each of the predicate's arguments was evaluated
   1.136 +    // exactly once.
   1.137 +    EXPECT_EQ(1, n1_) <<
   1.138 +        "The predicate assertion didn't evaluate argument 2 "
   1.139 +        "exactly once.";
   1.140 +
   1.141 +    // Verifies that the control flow in the test function is expected.
   1.142 +    if (expected_to_finish_ && !finished_) {
   1.143 +      FAIL() << "The predicate assertion unexpactedly aborted the test.";
   1.144 +    } else if (!expected_to_finish_ && finished_) {
   1.145 +      FAIL() << "The failed predicate assertion didn't abort the test "
   1.146 +                "as expected.";
   1.147 +    }
   1.148 +  }
   1.149 +
   1.150 +  // true iff the test function is expected to run to finish.
   1.151 +  static bool expected_to_finish_;
   1.152 +
   1.153 +  // true iff the test function did run to finish.
   1.154 +  static bool finished_;
   1.155 +
   1.156 +  static int n1_;
   1.157 +};
   1.158 +
   1.159 +bool Predicate1Test::expected_to_finish_;
   1.160 +bool Predicate1Test::finished_;
   1.161 +int Predicate1Test::n1_;
   1.162 +
   1.163 +typedef Predicate1Test EXPECT_PRED_FORMAT1Test;
   1.164 +typedef Predicate1Test ASSERT_PRED_FORMAT1Test;
   1.165 +typedef Predicate1Test EXPECT_PRED1Test;
   1.166 +typedef Predicate1Test ASSERT_PRED1Test;
   1.167 +
   1.168 +// Tests a successful EXPECT_PRED1 where the
   1.169 +// predicate-formatter is a function on a built-in type (int).
   1.170 +TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
   1.171 +  EXPECT_PRED1(PredFunction1Int,
   1.172 +               ++n1_);
   1.173 +  finished_ = true;
   1.174 +}
   1.175 +
   1.176 +// Tests a successful EXPECT_PRED1 where the
   1.177 +// predicate-formatter is a function on a user-defined type (Bool).
   1.178 +TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {
   1.179 +  EXPECT_PRED1(PredFunction1Bool,
   1.180 +               Bool(++n1_));
   1.181 +  finished_ = true;
   1.182 +}
   1.183 +
   1.184 +// Tests a successful EXPECT_PRED1 where the
   1.185 +// predicate-formatter is a functor on a built-in type (int).
   1.186 +TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
   1.187 +  EXPECT_PRED1(PredFunctor1(),
   1.188 +               ++n1_);
   1.189 +  finished_ = true;
   1.190 +}
   1.191 +
   1.192 +// Tests a successful EXPECT_PRED1 where the
   1.193 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.194 +TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {
   1.195 +  EXPECT_PRED1(PredFunctor1(),
   1.196 +               Bool(++n1_));
   1.197 +  finished_ = true;
   1.198 +}
   1.199 +
   1.200 +// Tests a failed EXPECT_PRED1 where the
   1.201 +// predicate-formatter is a function on a built-in type (int).
   1.202 +TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {
   1.203 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.204 +    EXPECT_PRED1(PredFunction1Int,
   1.205 +                 n1_++);
   1.206 +    finished_ = true;
   1.207 +  }, "");
   1.208 +}
   1.209 +
   1.210 +// Tests a failed EXPECT_PRED1 where the
   1.211 +// predicate-formatter is a function on a user-defined type (Bool).
   1.212 +TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {
   1.213 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.214 +    EXPECT_PRED1(PredFunction1Bool,
   1.215 +                 Bool(n1_++));
   1.216 +    finished_ = true;
   1.217 +  }, "");
   1.218 +}
   1.219 +
   1.220 +// Tests a failed EXPECT_PRED1 where the
   1.221 +// predicate-formatter is a functor on a built-in type (int).
   1.222 +TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {
   1.223 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.224 +    EXPECT_PRED1(PredFunctor1(),
   1.225 +                 n1_++);
   1.226 +    finished_ = true;
   1.227 +  }, "");
   1.228 +}
   1.229 +
   1.230 +// Tests a failed EXPECT_PRED1 where the
   1.231 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.232 +TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {
   1.233 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.234 +    EXPECT_PRED1(PredFunctor1(),
   1.235 +                 Bool(n1_++));
   1.236 +    finished_ = true;
   1.237 +  }, "");
   1.238 +}
   1.239 +
   1.240 +// Tests a successful ASSERT_PRED1 where the
   1.241 +// predicate-formatter is a function on a built-in type (int).
   1.242 +TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {
   1.243 +  ASSERT_PRED1(PredFunction1Int,
   1.244 +               ++n1_);
   1.245 +  finished_ = true;
   1.246 +}
   1.247 +
   1.248 +// Tests a successful ASSERT_PRED1 where the
   1.249 +// predicate-formatter is a function on a user-defined type (Bool).
   1.250 +TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {
   1.251 +  ASSERT_PRED1(PredFunction1Bool,
   1.252 +               Bool(++n1_));
   1.253 +  finished_ = true;
   1.254 +}
   1.255 +
   1.256 +// Tests a successful ASSERT_PRED1 where the
   1.257 +// predicate-formatter is a functor on a built-in type (int).
   1.258 +TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {
   1.259 +  ASSERT_PRED1(PredFunctor1(),
   1.260 +               ++n1_);
   1.261 +  finished_ = true;
   1.262 +}
   1.263 +
   1.264 +// Tests a successful ASSERT_PRED1 where the
   1.265 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.266 +TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {
   1.267 +  ASSERT_PRED1(PredFunctor1(),
   1.268 +               Bool(++n1_));
   1.269 +  finished_ = true;
   1.270 +}
   1.271 +
   1.272 +// Tests a failed ASSERT_PRED1 where the
   1.273 +// predicate-formatter is a function on a built-in type (int).
   1.274 +TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {
   1.275 +  expected_to_finish_ = false;
   1.276 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.277 +    ASSERT_PRED1(PredFunction1Int,
   1.278 +                 n1_++);
   1.279 +    finished_ = true;
   1.280 +  }, "");
   1.281 +}
   1.282 +
   1.283 +// Tests a failed ASSERT_PRED1 where the
   1.284 +// predicate-formatter is a function on a user-defined type (Bool).
   1.285 +TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {
   1.286 +  expected_to_finish_ = false;
   1.287 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.288 +    ASSERT_PRED1(PredFunction1Bool,
   1.289 +                 Bool(n1_++));
   1.290 +    finished_ = true;
   1.291 +  }, "");
   1.292 +}
   1.293 +
   1.294 +// Tests a failed ASSERT_PRED1 where the
   1.295 +// predicate-formatter is a functor on a built-in type (int).
   1.296 +TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {
   1.297 +  expected_to_finish_ = false;
   1.298 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.299 +    ASSERT_PRED1(PredFunctor1(),
   1.300 +                 n1_++);
   1.301 +    finished_ = true;
   1.302 +  }, "");
   1.303 +}
   1.304 +
   1.305 +// Tests a failed ASSERT_PRED1 where the
   1.306 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.307 +TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {
   1.308 +  expected_to_finish_ = false;
   1.309 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.310 +    ASSERT_PRED1(PredFunctor1(),
   1.311 +                 Bool(n1_++));
   1.312 +    finished_ = true;
   1.313 +  }, "");
   1.314 +}
   1.315 +
   1.316 +// Tests a successful EXPECT_PRED_FORMAT1 where the
   1.317 +// predicate-formatter is a function on a built-in type (int).
   1.318 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
   1.319 +  EXPECT_PRED_FORMAT1(PredFormatFunction1,
   1.320 +                      ++n1_);
   1.321 +  finished_ = true;
   1.322 +}
   1.323 +
   1.324 +// Tests a successful EXPECT_PRED_FORMAT1 where the
   1.325 +// predicate-formatter is a function on a user-defined type (Bool).
   1.326 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
   1.327 +  EXPECT_PRED_FORMAT1(PredFormatFunction1,
   1.328 +                      Bool(++n1_));
   1.329 +  finished_ = true;
   1.330 +}
   1.331 +
   1.332 +// Tests a successful EXPECT_PRED_FORMAT1 where the
   1.333 +// predicate-formatter is a functor on a built-in type (int).
   1.334 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
   1.335 +  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
   1.336 +                      ++n1_);
   1.337 +  finished_ = true;
   1.338 +}
   1.339 +
   1.340 +// Tests a successful EXPECT_PRED_FORMAT1 where the
   1.341 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.342 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
   1.343 +  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
   1.344 +                      Bool(++n1_));
   1.345 +  finished_ = true;
   1.346 +}
   1.347 +
   1.348 +// Tests a failed EXPECT_PRED_FORMAT1 where the
   1.349 +// predicate-formatter is a function on a built-in type (int).
   1.350 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
   1.351 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.352 +    EXPECT_PRED_FORMAT1(PredFormatFunction1,
   1.353 +                        n1_++);
   1.354 +    finished_ = true;
   1.355 +  }, "");
   1.356 +}
   1.357 +
   1.358 +// Tests a failed EXPECT_PRED_FORMAT1 where the
   1.359 +// predicate-formatter is a function on a user-defined type (Bool).
   1.360 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
   1.361 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.362 +    EXPECT_PRED_FORMAT1(PredFormatFunction1,
   1.363 +                        Bool(n1_++));
   1.364 +    finished_ = true;
   1.365 +  }, "");
   1.366 +}
   1.367 +
   1.368 +// Tests a failed EXPECT_PRED_FORMAT1 where the
   1.369 +// predicate-formatter is a functor on a built-in type (int).
   1.370 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
   1.371 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.372 +    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
   1.373 +                        n1_++);
   1.374 +    finished_ = true;
   1.375 +  }, "");
   1.376 +}
   1.377 +
   1.378 +// Tests a failed EXPECT_PRED_FORMAT1 where the
   1.379 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.380 +TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
   1.381 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.382 +    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),
   1.383 +                        Bool(n1_++));
   1.384 +    finished_ = true;
   1.385 +  }, "");
   1.386 +}
   1.387 +
   1.388 +// Tests a successful ASSERT_PRED_FORMAT1 where the
   1.389 +// predicate-formatter is a function on a built-in type (int).
   1.390 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {
   1.391 +  ASSERT_PRED_FORMAT1(PredFormatFunction1,
   1.392 +                      ++n1_);
   1.393 +  finished_ = true;
   1.394 +}
   1.395 +
   1.396 +// Tests a successful ASSERT_PRED_FORMAT1 where the
   1.397 +// predicate-formatter is a function on a user-defined type (Bool).
   1.398 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {
   1.399 +  ASSERT_PRED_FORMAT1(PredFormatFunction1,
   1.400 +                      Bool(++n1_));
   1.401 +  finished_ = true;
   1.402 +}
   1.403 +
   1.404 +// Tests a successful ASSERT_PRED_FORMAT1 where the
   1.405 +// predicate-formatter is a functor on a built-in type (int).
   1.406 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {
   1.407 +  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
   1.408 +                      ++n1_);
   1.409 +  finished_ = true;
   1.410 +}
   1.411 +
   1.412 +// Tests a successful ASSERT_PRED_FORMAT1 where the
   1.413 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.414 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {
   1.415 +  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
   1.416 +                      Bool(++n1_));
   1.417 +  finished_ = true;
   1.418 +}
   1.419 +
   1.420 +// Tests a failed ASSERT_PRED_FORMAT1 where the
   1.421 +// predicate-formatter is a function on a built-in type (int).
   1.422 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {
   1.423 +  expected_to_finish_ = false;
   1.424 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.425 +    ASSERT_PRED_FORMAT1(PredFormatFunction1,
   1.426 +                        n1_++);
   1.427 +    finished_ = true;
   1.428 +  }, "");
   1.429 +}
   1.430 +
   1.431 +// Tests a failed ASSERT_PRED_FORMAT1 where the
   1.432 +// predicate-formatter is a function on a user-defined type (Bool).
   1.433 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {
   1.434 +  expected_to_finish_ = false;
   1.435 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.436 +    ASSERT_PRED_FORMAT1(PredFormatFunction1,
   1.437 +                        Bool(n1_++));
   1.438 +    finished_ = true;
   1.439 +  }, "");
   1.440 +}
   1.441 +
   1.442 +// Tests a failed ASSERT_PRED_FORMAT1 where the
   1.443 +// predicate-formatter is a functor on a built-in type (int).
   1.444 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {
   1.445 +  expected_to_finish_ = false;
   1.446 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.447 +    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
   1.448 +                        n1_++);
   1.449 +    finished_ = true;
   1.450 +  }, "");
   1.451 +}
   1.452 +
   1.453 +// Tests a failed ASSERT_PRED_FORMAT1 where the
   1.454 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.455 +TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {
   1.456 +  expected_to_finish_ = false;
   1.457 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.458 +    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),
   1.459 +                        Bool(n1_++));
   1.460 +    finished_ = true;
   1.461 +  }, "");
   1.462 +}
   1.463 +// Sample functions/functors for testing binary predicate assertions.
   1.464 +
   1.465 +// A binary predicate function.
   1.466 +template <typename T1, typename T2>
   1.467 +bool PredFunction2(T1 v1, T2 v2) {
   1.468 +  return v1 + v2 > 0;
   1.469 +}
   1.470 +
   1.471 +// The following two functions are needed to circumvent a bug in
   1.472 +// gcc 2.95.3, which sometimes has problem with the above template
   1.473 +// function.
   1.474 +bool PredFunction2Int(int v1, int v2) {
   1.475 +  return v1 + v2 > 0;
   1.476 +}
   1.477 +bool PredFunction2Bool(Bool v1, Bool v2) {
   1.478 +  return v1 + v2 > 0;
   1.479 +}
   1.480 +
   1.481 +// A binary predicate functor.
   1.482 +struct PredFunctor2 {
   1.483 +  template <typename T1, typename T2>
   1.484 +  bool operator()(const T1& v1,
   1.485 +                  const T2& v2) {
   1.486 +    return v1 + v2 > 0;
   1.487 +  }
   1.488 +};
   1.489 +
   1.490 +// A binary predicate-formatter function.
   1.491 +template <typename T1, typename T2>
   1.492 +testing::AssertionResult PredFormatFunction2(const char* e1,
   1.493 +                                             const char* e2,
   1.494 +                                             const T1& v1,
   1.495 +                                             const T2& v2) {
   1.496 +  if (PredFunction2(v1, v2))
   1.497 +    return testing::AssertionSuccess();
   1.498 +
   1.499 +  return testing::AssertionFailure()
   1.500 +      << e1 << " + " << e2
   1.501 +      << " is expected to be positive, but evaluates to "
   1.502 +      << v1 + v2 << ".";
   1.503 +}
   1.504 +
   1.505 +// A binary predicate-formatter functor.
   1.506 +struct PredFormatFunctor2 {
   1.507 +  template <typename T1, typename T2>
   1.508 +  testing::AssertionResult operator()(const char* e1,
   1.509 +                                      const char* e2,
   1.510 +                                      const T1& v1,
   1.511 +                                      const T2& v2) const {
   1.512 +    return PredFormatFunction2(e1, e2, v1, v2);
   1.513 +  }
   1.514 +};
   1.515 +
   1.516 +// Tests for {EXPECT|ASSERT}_PRED_FORMAT2.
   1.517 +
   1.518 +class Predicate2Test : public testing::Test {
   1.519 + protected:
   1.520 +  virtual void SetUp() {
   1.521 +    expected_to_finish_ = true;
   1.522 +    finished_ = false;
   1.523 +    n1_ = n2_ = 0;
   1.524 +  }
   1.525 +
   1.526 +  virtual void TearDown() {
   1.527 +    // Verifies that each of the predicate's arguments was evaluated
   1.528 +    // exactly once.
   1.529 +    EXPECT_EQ(1, n1_) <<
   1.530 +        "The predicate assertion didn't evaluate argument 2 "
   1.531 +        "exactly once.";
   1.532 +    EXPECT_EQ(1, n2_) <<
   1.533 +        "The predicate assertion didn't evaluate argument 3 "
   1.534 +        "exactly once.";
   1.535 +
   1.536 +    // Verifies that the control flow in the test function is expected.
   1.537 +    if (expected_to_finish_ && !finished_) {
   1.538 +      FAIL() << "The predicate assertion unexpactedly aborted the test.";
   1.539 +    } else if (!expected_to_finish_ && finished_) {
   1.540 +      FAIL() << "The failed predicate assertion didn't abort the test "
   1.541 +                "as expected.";
   1.542 +    }
   1.543 +  }
   1.544 +
   1.545 +  // true iff the test function is expected to run to finish.
   1.546 +  static bool expected_to_finish_;
   1.547 +
   1.548 +  // true iff the test function did run to finish.
   1.549 +  static bool finished_;
   1.550 +
   1.551 +  static int n1_;
   1.552 +  static int n2_;
   1.553 +};
   1.554 +
   1.555 +bool Predicate2Test::expected_to_finish_;
   1.556 +bool Predicate2Test::finished_;
   1.557 +int Predicate2Test::n1_;
   1.558 +int Predicate2Test::n2_;
   1.559 +
   1.560 +typedef Predicate2Test EXPECT_PRED_FORMAT2Test;
   1.561 +typedef Predicate2Test ASSERT_PRED_FORMAT2Test;
   1.562 +typedef Predicate2Test EXPECT_PRED2Test;
   1.563 +typedef Predicate2Test ASSERT_PRED2Test;
   1.564 +
   1.565 +// Tests a successful EXPECT_PRED2 where the
   1.566 +// predicate-formatter is a function on a built-in type (int).
   1.567 +TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
   1.568 +  EXPECT_PRED2(PredFunction2Int,
   1.569 +               ++n1_,
   1.570 +               ++n2_);
   1.571 +  finished_ = true;
   1.572 +}
   1.573 +
   1.574 +// Tests a successful EXPECT_PRED2 where the
   1.575 +// predicate-formatter is a function on a user-defined type (Bool).
   1.576 +TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {
   1.577 +  EXPECT_PRED2(PredFunction2Bool,
   1.578 +               Bool(++n1_),
   1.579 +               Bool(++n2_));
   1.580 +  finished_ = true;
   1.581 +}
   1.582 +
   1.583 +// Tests a successful EXPECT_PRED2 where the
   1.584 +// predicate-formatter is a functor on a built-in type (int).
   1.585 +TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
   1.586 +  EXPECT_PRED2(PredFunctor2(),
   1.587 +               ++n1_,
   1.588 +               ++n2_);
   1.589 +  finished_ = true;
   1.590 +}
   1.591 +
   1.592 +// Tests a successful EXPECT_PRED2 where the
   1.593 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.594 +TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {
   1.595 +  EXPECT_PRED2(PredFunctor2(),
   1.596 +               Bool(++n1_),
   1.597 +               Bool(++n2_));
   1.598 +  finished_ = true;
   1.599 +}
   1.600 +
   1.601 +// Tests a failed EXPECT_PRED2 where the
   1.602 +// predicate-formatter is a function on a built-in type (int).
   1.603 +TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {
   1.604 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.605 +    EXPECT_PRED2(PredFunction2Int,
   1.606 +                 n1_++,
   1.607 +                 n2_++);
   1.608 +    finished_ = true;
   1.609 +  }, "");
   1.610 +}
   1.611 +
   1.612 +// Tests a failed EXPECT_PRED2 where the
   1.613 +// predicate-formatter is a function on a user-defined type (Bool).
   1.614 +TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {
   1.615 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.616 +    EXPECT_PRED2(PredFunction2Bool,
   1.617 +                 Bool(n1_++),
   1.618 +                 Bool(n2_++));
   1.619 +    finished_ = true;
   1.620 +  }, "");
   1.621 +}
   1.622 +
   1.623 +// Tests a failed EXPECT_PRED2 where the
   1.624 +// predicate-formatter is a functor on a built-in type (int).
   1.625 +TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {
   1.626 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.627 +    EXPECT_PRED2(PredFunctor2(),
   1.628 +                 n1_++,
   1.629 +                 n2_++);
   1.630 +    finished_ = true;
   1.631 +  }, "");
   1.632 +}
   1.633 +
   1.634 +// Tests a failed EXPECT_PRED2 where the
   1.635 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.636 +TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {
   1.637 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.638 +    EXPECT_PRED2(PredFunctor2(),
   1.639 +                 Bool(n1_++),
   1.640 +                 Bool(n2_++));
   1.641 +    finished_ = true;
   1.642 +  }, "");
   1.643 +}
   1.644 +
   1.645 +// Tests a successful ASSERT_PRED2 where the
   1.646 +// predicate-formatter is a function on a built-in type (int).
   1.647 +TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {
   1.648 +  ASSERT_PRED2(PredFunction2Int,
   1.649 +               ++n1_,
   1.650 +               ++n2_);
   1.651 +  finished_ = true;
   1.652 +}
   1.653 +
   1.654 +// Tests a successful ASSERT_PRED2 where the
   1.655 +// predicate-formatter is a function on a user-defined type (Bool).
   1.656 +TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {
   1.657 +  ASSERT_PRED2(PredFunction2Bool,
   1.658 +               Bool(++n1_),
   1.659 +               Bool(++n2_));
   1.660 +  finished_ = true;
   1.661 +}
   1.662 +
   1.663 +// Tests a successful ASSERT_PRED2 where the
   1.664 +// predicate-formatter is a functor on a built-in type (int).
   1.665 +TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {
   1.666 +  ASSERT_PRED2(PredFunctor2(),
   1.667 +               ++n1_,
   1.668 +               ++n2_);
   1.669 +  finished_ = true;
   1.670 +}
   1.671 +
   1.672 +// Tests a successful ASSERT_PRED2 where the
   1.673 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.674 +TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {
   1.675 +  ASSERT_PRED2(PredFunctor2(),
   1.676 +               Bool(++n1_),
   1.677 +               Bool(++n2_));
   1.678 +  finished_ = true;
   1.679 +}
   1.680 +
   1.681 +// Tests a failed ASSERT_PRED2 where the
   1.682 +// predicate-formatter is a function on a built-in type (int).
   1.683 +TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {
   1.684 +  expected_to_finish_ = false;
   1.685 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.686 +    ASSERT_PRED2(PredFunction2Int,
   1.687 +                 n1_++,
   1.688 +                 n2_++);
   1.689 +    finished_ = true;
   1.690 +  }, "");
   1.691 +}
   1.692 +
   1.693 +// Tests a failed ASSERT_PRED2 where the
   1.694 +// predicate-formatter is a function on a user-defined type (Bool).
   1.695 +TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {
   1.696 +  expected_to_finish_ = false;
   1.697 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.698 +    ASSERT_PRED2(PredFunction2Bool,
   1.699 +                 Bool(n1_++),
   1.700 +                 Bool(n2_++));
   1.701 +    finished_ = true;
   1.702 +  }, "");
   1.703 +}
   1.704 +
   1.705 +// Tests a failed ASSERT_PRED2 where the
   1.706 +// predicate-formatter is a functor on a built-in type (int).
   1.707 +TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {
   1.708 +  expected_to_finish_ = false;
   1.709 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.710 +    ASSERT_PRED2(PredFunctor2(),
   1.711 +                 n1_++,
   1.712 +                 n2_++);
   1.713 +    finished_ = true;
   1.714 +  }, "");
   1.715 +}
   1.716 +
   1.717 +// Tests a failed ASSERT_PRED2 where the
   1.718 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.719 +TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {
   1.720 +  expected_to_finish_ = false;
   1.721 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.722 +    ASSERT_PRED2(PredFunctor2(),
   1.723 +                 Bool(n1_++),
   1.724 +                 Bool(n2_++));
   1.725 +    finished_ = true;
   1.726 +  }, "");
   1.727 +}
   1.728 +
   1.729 +// Tests a successful EXPECT_PRED_FORMAT2 where the
   1.730 +// predicate-formatter is a function on a built-in type (int).
   1.731 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
   1.732 +  EXPECT_PRED_FORMAT2(PredFormatFunction2,
   1.733 +                      ++n1_,
   1.734 +                      ++n2_);
   1.735 +  finished_ = true;
   1.736 +}
   1.737 +
   1.738 +// Tests a successful EXPECT_PRED_FORMAT2 where the
   1.739 +// predicate-formatter is a function on a user-defined type (Bool).
   1.740 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
   1.741 +  EXPECT_PRED_FORMAT2(PredFormatFunction2,
   1.742 +                      Bool(++n1_),
   1.743 +                      Bool(++n2_));
   1.744 +  finished_ = true;
   1.745 +}
   1.746 +
   1.747 +// Tests a successful EXPECT_PRED_FORMAT2 where the
   1.748 +// predicate-formatter is a functor on a built-in type (int).
   1.749 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
   1.750 +  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
   1.751 +                      ++n1_,
   1.752 +                      ++n2_);
   1.753 +  finished_ = true;
   1.754 +}
   1.755 +
   1.756 +// Tests a successful EXPECT_PRED_FORMAT2 where the
   1.757 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.758 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
   1.759 +  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
   1.760 +                      Bool(++n1_),
   1.761 +                      Bool(++n2_));
   1.762 +  finished_ = true;
   1.763 +}
   1.764 +
   1.765 +// Tests a failed EXPECT_PRED_FORMAT2 where the
   1.766 +// predicate-formatter is a function on a built-in type (int).
   1.767 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
   1.768 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.769 +    EXPECT_PRED_FORMAT2(PredFormatFunction2,
   1.770 +                        n1_++,
   1.771 +                        n2_++);
   1.772 +    finished_ = true;
   1.773 +  }, "");
   1.774 +}
   1.775 +
   1.776 +// Tests a failed EXPECT_PRED_FORMAT2 where the
   1.777 +// predicate-formatter is a function on a user-defined type (Bool).
   1.778 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
   1.779 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.780 +    EXPECT_PRED_FORMAT2(PredFormatFunction2,
   1.781 +                        Bool(n1_++),
   1.782 +                        Bool(n2_++));
   1.783 +    finished_ = true;
   1.784 +  }, "");
   1.785 +}
   1.786 +
   1.787 +// Tests a failed EXPECT_PRED_FORMAT2 where the
   1.788 +// predicate-formatter is a functor on a built-in type (int).
   1.789 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
   1.790 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.791 +    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
   1.792 +                        n1_++,
   1.793 +                        n2_++);
   1.794 +    finished_ = true;
   1.795 +  }, "");
   1.796 +}
   1.797 +
   1.798 +// Tests a failed EXPECT_PRED_FORMAT2 where the
   1.799 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.800 +TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
   1.801 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
   1.802 +    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),
   1.803 +                        Bool(n1_++),
   1.804 +                        Bool(n2_++));
   1.805 +    finished_ = true;
   1.806 +  }, "");
   1.807 +}
   1.808 +
   1.809 +// Tests a successful ASSERT_PRED_FORMAT2 where the
   1.810 +// predicate-formatter is a function on a built-in type (int).
   1.811 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {
   1.812 +  ASSERT_PRED_FORMAT2(PredFormatFunction2,
   1.813 +                      ++n1_,
   1.814 +                      ++n2_);
   1.815 +  finished_ = true;
   1.816 +}
   1.817 +
   1.818 +// Tests a successful ASSERT_PRED_FORMAT2 where the
   1.819 +// predicate-formatter is a function on a user-defined type (Bool).
   1.820 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {
   1.821 +  ASSERT_PRED_FORMAT2(PredFormatFunction2,
   1.822 +                      Bool(++n1_),
   1.823 +                      Bool(++n2_));
   1.824 +  finished_ = true;
   1.825 +}
   1.826 +
   1.827 +// Tests a successful ASSERT_PRED_FORMAT2 where the
   1.828 +// predicate-formatter is a functor on a built-in type (int).
   1.829 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {
   1.830 +  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
   1.831 +                      ++n1_,
   1.832 +                      ++n2_);
   1.833 +  finished_ = true;
   1.834 +}
   1.835 +
   1.836 +// Tests a successful ASSERT_PRED_FORMAT2 where the
   1.837 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.838 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {
   1.839 +  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
   1.840 +                      Bool(++n1_),
   1.841 +                      Bool(++n2_));
   1.842 +  finished_ = true;
   1.843 +}
   1.844 +
   1.845 +// Tests a failed ASSERT_PRED_FORMAT2 where the
   1.846 +// predicate-formatter is a function on a built-in type (int).
   1.847 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {
   1.848 +  expected_to_finish_ = false;
   1.849 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.850 +    ASSERT_PRED_FORMAT2(PredFormatFunction2,
   1.851 +                        n1_++,
   1.852 +                        n2_++);
   1.853 +    finished_ = true;
   1.854 +  }, "");
   1.855 +}
   1.856 +
   1.857 +// Tests a failed ASSERT_PRED_FORMAT2 where the
   1.858 +// predicate-formatter is a function on a user-defined type (Bool).
   1.859 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {
   1.860 +  expected_to_finish_ = false;
   1.861 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.862 +    ASSERT_PRED_FORMAT2(PredFormatFunction2,
   1.863 +                        Bool(n1_++),
   1.864 +                        Bool(n2_++));
   1.865 +    finished_ = true;
   1.866 +  }, "");
   1.867 +}
   1.868 +
   1.869 +// Tests a failed ASSERT_PRED_FORMAT2 where the
   1.870 +// predicate-formatter is a functor on a built-in type (int).
   1.871 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {
   1.872 +  expected_to_finish_ = false;
   1.873 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.874 +    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
   1.875 +                        n1_++,
   1.876 +                        n2_++);
   1.877 +    finished_ = true;
   1.878 +  }, "");
   1.879 +}
   1.880 +
   1.881 +// Tests a failed ASSERT_PRED_FORMAT2 where the
   1.882 +// predicate-formatter is a functor on a user-defined type (Bool).
   1.883 +TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {
   1.884 +  expected_to_finish_ = false;
   1.885 +  EXPECT_FATAL_FAILURE({  // NOLINT
   1.886 +    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),
   1.887 +                        Bool(n1_++),
   1.888 +                        Bool(n2_++));
   1.889 +    finished_ = true;
   1.890 +  }, "");
   1.891 +}
   1.892 +// Sample functions/functors for testing ternary predicate assertions.
   1.893 +
   1.894 +// A ternary predicate function.
   1.895 +template <typename T1, typename T2, typename T3>
   1.896 +bool PredFunction3(T1 v1, T2 v2, T3 v3) {
   1.897 +  return v1 + v2 + v3 > 0;
   1.898 +}
   1.899 +
   1.900 +// The following two functions are needed to circumvent a bug in
   1.901 +// gcc 2.95.3, which sometimes has problem with the above template
   1.902 +// function.
   1.903 +bool PredFunction3Int(int v1, int v2, int v3) {
   1.904 +  return v1 + v2 + v3 > 0;
   1.905 +}
   1.906 +bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) {
   1.907 +  return v1 + v2 + v3 > 0;
   1.908 +}
   1.909 +
   1.910 +// A ternary predicate functor.
   1.911 +struct PredFunctor3 {
   1.912 +  template <typename T1, typename T2, typename T3>
   1.913 +  bool operator()(const T1& v1,
   1.914 +                  const T2& v2,
   1.915 +                  const T3& v3) {
   1.916 +    return v1 + v2 + v3 > 0;
   1.917 +  }
   1.918 +};
   1.919 +
   1.920 +// A ternary predicate-formatter function.
   1.921 +template <typename T1, typename T2, typename T3>
   1.922 +testing::AssertionResult PredFormatFunction3(const char* e1,
   1.923 +                                             const char* e2,
   1.924 +                                             const char* e3,
   1.925 +                                             const T1& v1,
   1.926 +                                             const T2& v2,
   1.927 +                                             const T3& v3) {
   1.928 +  if (PredFunction3(v1, v2, v3))
   1.929 +    return testing::AssertionSuccess();
   1.930 +
   1.931 +  return testing::AssertionFailure()
   1.932 +      << e1 << " + " << e2 << " + " << e3
   1.933 +      << " is expected to be positive, but evaluates to "
   1.934 +      << v1 + v2 + v3 << ".";
   1.935 +}
   1.936 +
   1.937 +// A ternary predicate-formatter functor.
   1.938 +struct PredFormatFunctor3 {
   1.939 +  template <typename T1, typename T2, typename T3>
   1.940 +  testing::AssertionResult operator()(const char* e1,
   1.941 +                                      const char* e2,
   1.942 +                                      const char* e3,
   1.943 +                                      const T1& v1,
   1.944 +                                      const T2& v2,
   1.945 +                                      const T3& v3) const {
   1.946 +    return PredFormatFunction3(e1, e2, e3, v1, v2, v3);
   1.947 +  }
   1.948 +};
   1.949 +
   1.950 +// Tests for {EXPECT|ASSERT}_PRED_FORMAT3.
   1.951 +
   1.952 +class Predicate3Test : public testing::Test {
   1.953 + protected:
   1.954 +  virtual void SetUp() {
   1.955 +    expected_to_finish_ = true;
   1.956 +    finished_ = false;
   1.957 +    n1_ = n2_ = n3_ = 0;
   1.958 +  }
   1.959 +
   1.960 +  virtual void TearDown() {
   1.961 +    // Verifies that each of the predicate's arguments was evaluated
   1.962 +    // exactly once.
   1.963 +    EXPECT_EQ(1, n1_) <<
   1.964 +        "The predicate assertion didn't evaluate argument 2 "
   1.965 +        "exactly once.";
   1.966 +    EXPECT_EQ(1, n2_) <<
   1.967 +        "The predicate assertion didn't evaluate argument 3 "
   1.968 +        "exactly once.";
   1.969 +    EXPECT_EQ(1, n3_) <<
   1.970 +        "The predicate assertion didn't evaluate argument 4 "
   1.971 +        "exactly once.";
   1.972 +
   1.973 +    // Verifies that the control flow in the test function is expected.
   1.974 +    if (expected_to_finish_ && !finished_) {
   1.975 +      FAIL() << "The predicate assertion unexpactedly aborted the test.";
   1.976 +    } else if (!expected_to_finish_ && finished_) {
   1.977 +      FAIL() << "The failed predicate assertion didn't abort the test "
   1.978 +                "as expected.";
   1.979 +    }
   1.980 +  }
   1.981 +
   1.982 +  // true iff the test function is expected to run to finish.
   1.983 +  static bool expected_to_finish_;
   1.984 +
   1.985 +  // true iff the test function did run to finish.
   1.986 +  static bool finished_;
   1.987 +
   1.988 +  static int n1_;
   1.989 +  static int n2_;
   1.990 +  static int n3_;
   1.991 +};
   1.992 +
   1.993 +bool Predicate3Test::expected_to_finish_;
   1.994 +bool Predicate3Test::finished_;
   1.995 +int Predicate3Test::n1_;
   1.996 +int Predicate3Test::n2_;
   1.997 +int Predicate3Test::n3_;
   1.998 +
   1.999 +typedef Predicate3Test EXPECT_PRED_FORMAT3Test;
  1.1000 +typedef Predicate3Test ASSERT_PRED_FORMAT3Test;
  1.1001 +typedef Predicate3Test EXPECT_PRED3Test;
  1.1002 +typedef Predicate3Test ASSERT_PRED3Test;
  1.1003 +
  1.1004 +// Tests a successful EXPECT_PRED3 where the
  1.1005 +// predicate-formatter is a function on a built-in type (int).
  1.1006 +TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
  1.1007 +  EXPECT_PRED3(PredFunction3Int,
  1.1008 +               ++n1_,
  1.1009 +               ++n2_,
  1.1010 +               ++n3_);
  1.1011 +  finished_ = true;
  1.1012 +}
  1.1013 +
  1.1014 +// Tests a successful EXPECT_PRED3 where the
  1.1015 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1016 +TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {
  1.1017 +  EXPECT_PRED3(PredFunction3Bool,
  1.1018 +               Bool(++n1_),
  1.1019 +               Bool(++n2_),
  1.1020 +               Bool(++n3_));
  1.1021 +  finished_ = true;
  1.1022 +}
  1.1023 +
  1.1024 +// Tests a successful EXPECT_PRED3 where the
  1.1025 +// predicate-formatter is a functor on a built-in type (int).
  1.1026 +TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
  1.1027 +  EXPECT_PRED3(PredFunctor3(),
  1.1028 +               ++n1_,
  1.1029 +               ++n2_,
  1.1030 +               ++n3_);
  1.1031 +  finished_ = true;
  1.1032 +}
  1.1033 +
  1.1034 +// Tests a successful EXPECT_PRED3 where the
  1.1035 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1036 +TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {
  1.1037 +  EXPECT_PRED3(PredFunctor3(),
  1.1038 +               Bool(++n1_),
  1.1039 +               Bool(++n2_),
  1.1040 +               Bool(++n3_));
  1.1041 +  finished_ = true;
  1.1042 +}
  1.1043 +
  1.1044 +// Tests a failed EXPECT_PRED3 where the
  1.1045 +// predicate-formatter is a function on a built-in type (int).
  1.1046 +TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {
  1.1047 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1048 +    EXPECT_PRED3(PredFunction3Int,
  1.1049 +                 n1_++,
  1.1050 +                 n2_++,
  1.1051 +                 n3_++);
  1.1052 +    finished_ = true;
  1.1053 +  }, "");
  1.1054 +}
  1.1055 +
  1.1056 +// Tests a failed EXPECT_PRED3 where the
  1.1057 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1058 +TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {
  1.1059 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1060 +    EXPECT_PRED3(PredFunction3Bool,
  1.1061 +                 Bool(n1_++),
  1.1062 +                 Bool(n2_++),
  1.1063 +                 Bool(n3_++));
  1.1064 +    finished_ = true;
  1.1065 +  }, "");
  1.1066 +}
  1.1067 +
  1.1068 +// Tests a failed EXPECT_PRED3 where the
  1.1069 +// predicate-formatter is a functor on a built-in type (int).
  1.1070 +TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {
  1.1071 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1072 +    EXPECT_PRED3(PredFunctor3(),
  1.1073 +                 n1_++,
  1.1074 +                 n2_++,
  1.1075 +                 n3_++);
  1.1076 +    finished_ = true;
  1.1077 +  }, "");
  1.1078 +}
  1.1079 +
  1.1080 +// Tests a failed EXPECT_PRED3 where the
  1.1081 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1082 +TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {
  1.1083 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1084 +    EXPECT_PRED3(PredFunctor3(),
  1.1085 +                 Bool(n1_++),
  1.1086 +                 Bool(n2_++),
  1.1087 +                 Bool(n3_++));
  1.1088 +    finished_ = true;
  1.1089 +  }, "");
  1.1090 +}
  1.1091 +
  1.1092 +// Tests a successful ASSERT_PRED3 where the
  1.1093 +// predicate-formatter is a function on a built-in type (int).
  1.1094 +TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {
  1.1095 +  ASSERT_PRED3(PredFunction3Int,
  1.1096 +               ++n1_,
  1.1097 +               ++n2_,
  1.1098 +               ++n3_);
  1.1099 +  finished_ = true;
  1.1100 +}
  1.1101 +
  1.1102 +// Tests a successful ASSERT_PRED3 where the
  1.1103 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1104 +TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {
  1.1105 +  ASSERT_PRED3(PredFunction3Bool,
  1.1106 +               Bool(++n1_),
  1.1107 +               Bool(++n2_),
  1.1108 +               Bool(++n3_));
  1.1109 +  finished_ = true;
  1.1110 +}
  1.1111 +
  1.1112 +// Tests a successful ASSERT_PRED3 where the
  1.1113 +// predicate-formatter is a functor on a built-in type (int).
  1.1114 +TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {
  1.1115 +  ASSERT_PRED3(PredFunctor3(),
  1.1116 +               ++n1_,
  1.1117 +               ++n2_,
  1.1118 +               ++n3_);
  1.1119 +  finished_ = true;
  1.1120 +}
  1.1121 +
  1.1122 +// Tests a successful ASSERT_PRED3 where the
  1.1123 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1124 +TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {
  1.1125 +  ASSERT_PRED3(PredFunctor3(),
  1.1126 +               Bool(++n1_),
  1.1127 +               Bool(++n2_),
  1.1128 +               Bool(++n3_));
  1.1129 +  finished_ = true;
  1.1130 +}
  1.1131 +
  1.1132 +// Tests a failed ASSERT_PRED3 where the
  1.1133 +// predicate-formatter is a function on a built-in type (int).
  1.1134 +TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {
  1.1135 +  expected_to_finish_ = false;
  1.1136 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1137 +    ASSERT_PRED3(PredFunction3Int,
  1.1138 +                 n1_++,
  1.1139 +                 n2_++,
  1.1140 +                 n3_++);
  1.1141 +    finished_ = true;
  1.1142 +  }, "");
  1.1143 +}
  1.1144 +
  1.1145 +// Tests a failed ASSERT_PRED3 where the
  1.1146 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1147 +TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {
  1.1148 +  expected_to_finish_ = false;
  1.1149 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1150 +    ASSERT_PRED3(PredFunction3Bool,
  1.1151 +                 Bool(n1_++),
  1.1152 +                 Bool(n2_++),
  1.1153 +                 Bool(n3_++));
  1.1154 +    finished_ = true;
  1.1155 +  }, "");
  1.1156 +}
  1.1157 +
  1.1158 +// Tests a failed ASSERT_PRED3 where the
  1.1159 +// predicate-formatter is a functor on a built-in type (int).
  1.1160 +TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {
  1.1161 +  expected_to_finish_ = false;
  1.1162 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1163 +    ASSERT_PRED3(PredFunctor3(),
  1.1164 +                 n1_++,
  1.1165 +                 n2_++,
  1.1166 +                 n3_++);
  1.1167 +    finished_ = true;
  1.1168 +  }, "");
  1.1169 +}
  1.1170 +
  1.1171 +// Tests a failed ASSERT_PRED3 where the
  1.1172 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1173 +TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {
  1.1174 +  expected_to_finish_ = false;
  1.1175 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1176 +    ASSERT_PRED3(PredFunctor3(),
  1.1177 +                 Bool(n1_++),
  1.1178 +                 Bool(n2_++),
  1.1179 +                 Bool(n3_++));
  1.1180 +    finished_ = true;
  1.1181 +  }, "");
  1.1182 +}
  1.1183 +
  1.1184 +// Tests a successful EXPECT_PRED_FORMAT3 where the
  1.1185 +// predicate-formatter is a function on a built-in type (int).
  1.1186 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
  1.1187 +  EXPECT_PRED_FORMAT3(PredFormatFunction3,
  1.1188 +                      ++n1_,
  1.1189 +                      ++n2_,
  1.1190 +                      ++n3_);
  1.1191 +  finished_ = true;
  1.1192 +}
  1.1193 +
  1.1194 +// Tests a successful EXPECT_PRED_FORMAT3 where the
  1.1195 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1196 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
  1.1197 +  EXPECT_PRED_FORMAT3(PredFormatFunction3,
  1.1198 +                      Bool(++n1_),
  1.1199 +                      Bool(++n2_),
  1.1200 +                      Bool(++n3_));
  1.1201 +  finished_ = true;
  1.1202 +}
  1.1203 +
  1.1204 +// Tests a successful EXPECT_PRED_FORMAT3 where the
  1.1205 +// predicate-formatter is a functor on a built-in type (int).
  1.1206 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
  1.1207 +  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1208 +                      ++n1_,
  1.1209 +                      ++n2_,
  1.1210 +                      ++n3_);
  1.1211 +  finished_ = true;
  1.1212 +}
  1.1213 +
  1.1214 +// Tests a successful EXPECT_PRED_FORMAT3 where the
  1.1215 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1216 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
  1.1217 +  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1218 +                      Bool(++n1_),
  1.1219 +                      Bool(++n2_),
  1.1220 +                      Bool(++n3_));
  1.1221 +  finished_ = true;
  1.1222 +}
  1.1223 +
  1.1224 +// Tests a failed EXPECT_PRED_FORMAT3 where the
  1.1225 +// predicate-formatter is a function on a built-in type (int).
  1.1226 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
  1.1227 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1228 +    EXPECT_PRED_FORMAT3(PredFormatFunction3,
  1.1229 +                        n1_++,
  1.1230 +                        n2_++,
  1.1231 +                        n3_++);
  1.1232 +    finished_ = true;
  1.1233 +  }, "");
  1.1234 +}
  1.1235 +
  1.1236 +// Tests a failed EXPECT_PRED_FORMAT3 where the
  1.1237 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1238 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
  1.1239 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1240 +    EXPECT_PRED_FORMAT3(PredFormatFunction3,
  1.1241 +                        Bool(n1_++),
  1.1242 +                        Bool(n2_++),
  1.1243 +                        Bool(n3_++));
  1.1244 +    finished_ = true;
  1.1245 +  }, "");
  1.1246 +}
  1.1247 +
  1.1248 +// Tests a failed EXPECT_PRED_FORMAT3 where the
  1.1249 +// predicate-formatter is a functor on a built-in type (int).
  1.1250 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
  1.1251 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1252 +    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1253 +                        n1_++,
  1.1254 +                        n2_++,
  1.1255 +                        n3_++);
  1.1256 +    finished_ = true;
  1.1257 +  }, "");
  1.1258 +}
  1.1259 +
  1.1260 +// Tests a failed EXPECT_PRED_FORMAT3 where the
  1.1261 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1262 +TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
  1.1263 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1264 +    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1265 +                        Bool(n1_++),
  1.1266 +                        Bool(n2_++),
  1.1267 +                        Bool(n3_++));
  1.1268 +    finished_ = true;
  1.1269 +  }, "");
  1.1270 +}
  1.1271 +
  1.1272 +// Tests a successful ASSERT_PRED_FORMAT3 where the
  1.1273 +// predicate-formatter is a function on a built-in type (int).
  1.1274 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {
  1.1275 +  ASSERT_PRED_FORMAT3(PredFormatFunction3,
  1.1276 +                      ++n1_,
  1.1277 +                      ++n2_,
  1.1278 +                      ++n3_);
  1.1279 +  finished_ = true;
  1.1280 +}
  1.1281 +
  1.1282 +// Tests a successful ASSERT_PRED_FORMAT3 where the
  1.1283 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1284 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {
  1.1285 +  ASSERT_PRED_FORMAT3(PredFormatFunction3,
  1.1286 +                      Bool(++n1_),
  1.1287 +                      Bool(++n2_),
  1.1288 +                      Bool(++n3_));
  1.1289 +  finished_ = true;
  1.1290 +}
  1.1291 +
  1.1292 +// Tests a successful ASSERT_PRED_FORMAT3 where the
  1.1293 +// predicate-formatter is a functor on a built-in type (int).
  1.1294 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {
  1.1295 +  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1296 +                      ++n1_,
  1.1297 +                      ++n2_,
  1.1298 +                      ++n3_);
  1.1299 +  finished_ = true;
  1.1300 +}
  1.1301 +
  1.1302 +// Tests a successful ASSERT_PRED_FORMAT3 where the
  1.1303 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1304 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {
  1.1305 +  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1306 +                      Bool(++n1_),
  1.1307 +                      Bool(++n2_),
  1.1308 +                      Bool(++n3_));
  1.1309 +  finished_ = true;
  1.1310 +}
  1.1311 +
  1.1312 +// Tests a failed ASSERT_PRED_FORMAT3 where the
  1.1313 +// predicate-formatter is a function on a built-in type (int).
  1.1314 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {
  1.1315 +  expected_to_finish_ = false;
  1.1316 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1317 +    ASSERT_PRED_FORMAT3(PredFormatFunction3,
  1.1318 +                        n1_++,
  1.1319 +                        n2_++,
  1.1320 +                        n3_++);
  1.1321 +    finished_ = true;
  1.1322 +  }, "");
  1.1323 +}
  1.1324 +
  1.1325 +// Tests a failed ASSERT_PRED_FORMAT3 where the
  1.1326 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1327 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {
  1.1328 +  expected_to_finish_ = false;
  1.1329 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1330 +    ASSERT_PRED_FORMAT3(PredFormatFunction3,
  1.1331 +                        Bool(n1_++),
  1.1332 +                        Bool(n2_++),
  1.1333 +                        Bool(n3_++));
  1.1334 +    finished_ = true;
  1.1335 +  }, "");
  1.1336 +}
  1.1337 +
  1.1338 +// Tests a failed ASSERT_PRED_FORMAT3 where the
  1.1339 +// predicate-formatter is a functor on a built-in type (int).
  1.1340 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {
  1.1341 +  expected_to_finish_ = false;
  1.1342 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1343 +    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1344 +                        n1_++,
  1.1345 +                        n2_++,
  1.1346 +                        n3_++);
  1.1347 +    finished_ = true;
  1.1348 +  }, "");
  1.1349 +}
  1.1350 +
  1.1351 +// Tests a failed ASSERT_PRED_FORMAT3 where the
  1.1352 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1353 +TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {
  1.1354 +  expected_to_finish_ = false;
  1.1355 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1356 +    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),
  1.1357 +                        Bool(n1_++),
  1.1358 +                        Bool(n2_++),
  1.1359 +                        Bool(n3_++));
  1.1360 +    finished_ = true;
  1.1361 +  }, "");
  1.1362 +}
  1.1363 +// Sample functions/functors for testing 4-ary predicate assertions.
  1.1364 +
  1.1365 +// A 4-ary predicate function.
  1.1366 +template <typename T1, typename T2, typename T3, typename T4>
  1.1367 +bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {
  1.1368 +  return v1 + v2 + v3 + v4 > 0;
  1.1369 +}
  1.1370 +
  1.1371 +// The following two functions are needed to circumvent a bug in
  1.1372 +// gcc 2.95.3, which sometimes has problem with the above template
  1.1373 +// function.
  1.1374 +bool PredFunction4Int(int v1, int v2, int v3, int v4) {
  1.1375 +  return v1 + v2 + v3 + v4 > 0;
  1.1376 +}
  1.1377 +bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {
  1.1378 +  return v1 + v2 + v3 + v4 > 0;
  1.1379 +}
  1.1380 +
  1.1381 +// A 4-ary predicate functor.
  1.1382 +struct PredFunctor4 {
  1.1383 +  template <typename T1, typename T2, typename T3, typename T4>
  1.1384 +  bool operator()(const T1& v1,
  1.1385 +                  const T2& v2,
  1.1386 +                  const T3& v3,
  1.1387 +                  const T4& v4) {
  1.1388 +    return v1 + v2 + v3 + v4 > 0;
  1.1389 +  }
  1.1390 +};
  1.1391 +
  1.1392 +// A 4-ary predicate-formatter function.
  1.1393 +template <typename T1, typename T2, typename T3, typename T4>
  1.1394 +testing::AssertionResult PredFormatFunction4(const char* e1,
  1.1395 +                                             const char* e2,
  1.1396 +                                             const char* e3,
  1.1397 +                                             const char* e4,
  1.1398 +                                             const T1& v1,
  1.1399 +                                             const T2& v2,
  1.1400 +                                             const T3& v3,
  1.1401 +                                             const T4& v4) {
  1.1402 +  if (PredFunction4(v1, v2, v3, v4))
  1.1403 +    return testing::AssertionSuccess();
  1.1404 +
  1.1405 +  return testing::AssertionFailure()
  1.1406 +      << e1 << " + " << e2 << " + " << e3 << " + " << e4
  1.1407 +      << " is expected to be positive, but evaluates to "
  1.1408 +      << v1 + v2 + v3 + v4 << ".";
  1.1409 +}
  1.1410 +
  1.1411 +// A 4-ary predicate-formatter functor.
  1.1412 +struct PredFormatFunctor4 {
  1.1413 +  template <typename T1, typename T2, typename T3, typename T4>
  1.1414 +  testing::AssertionResult operator()(const char* e1,
  1.1415 +                                      const char* e2,
  1.1416 +                                      const char* e3,
  1.1417 +                                      const char* e4,
  1.1418 +                                      const T1& v1,
  1.1419 +                                      const T2& v2,
  1.1420 +                                      const T3& v3,
  1.1421 +                                      const T4& v4) const {
  1.1422 +    return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);
  1.1423 +  }
  1.1424 +};
  1.1425 +
  1.1426 +// Tests for {EXPECT|ASSERT}_PRED_FORMAT4.
  1.1427 +
  1.1428 +class Predicate4Test : public testing::Test {
  1.1429 + protected:
  1.1430 +  virtual void SetUp() {
  1.1431 +    expected_to_finish_ = true;
  1.1432 +    finished_ = false;
  1.1433 +    n1_ = n2_ = n3_ = n4_ = 0;
  1.1434 +  }
  1.1435 +
  1.1436 +  virtual void TearDown() {
  1.1437 +    // Verifies that each of the predicate's arguments was evaluated
  1.1438 +    // exactly once.
  1.1439 +    EXPECT_EQ(1, n1_) <<
  1.1440 +        "The predicate assertion didn't evaluate argument 2 "
  1.1441 +        "exactly once.";
  1.1442 +    EXPECT_EQ(1, n2_) <<
  1.1443 +        "The predicate assertion didn't evaluate argument 3 "
  1.1444 +        "exactly once.";
  1.1445 +    EXPECT_EQ(1, n3_) <<
  1.1446 +        "The predicate assertion didn't evaluate argument 4 "
  1.1447 +        "exactly once.";
  1.1448 +    EXPECT_EQ(1, n4_) <<
  1.1449 +        "The predicate assertion didn't evaluate argument 5 "
  1.1450 +        "exactly once.";
  1.1451 +
  1.1452 +    // Verifies that the control flow in the test function is expected.
  1.1453 +    if (expected_to_finish_ && !finished_) {
  1.1454 +      FAIL() << "The predicate assertion unexpactedly aborted the test.";
  1.1455 +    } else if (!expected_to_finish_ && finished_) {
  1.1456 +      FAIL() << "The failed predicate assertion didn't abort the test "
  1.1457 +                "as expected.";
  1.1458 +    }
  1.1459 +  }
  1.1460 +
  1.1461 +  // true iff the test function is expected to run to finish.
  1.1462 +  static bool expected_to_finish_;
  1.1463 +
  1.1464 +  // true iff the test function did run to finish.
  1.1465 +  static bool finished_;
  1.1466 +
  1.1467 +  static int n1_;
  1.1468 +  static int n2_;
  1.1469 +  static int n3_;
  1.1470 +  static int n4_;
  1.1471 +};
  1.1472 +
  1.1473 +bool Predicate4Test::expected_to_finish_;
  1.1474 +bool Predicate4Test::finished_;
  1.1475 +int Predicate4Test::n1_;
  1.1476 +int Predicate4Test::n2_;
  1.1477 +int Predicate4Test::n3_;
  1.1478 +int Predicate4Test::n4_;
  1.1479 +
  1.1480 +typedef Predicate4Test EXPECT_PRED_FORMAT4Test;
  1.1481 +typedef Predicate4Test ASSERT_PRED_FORMAT4Test;
  1.1482 +typedef Predicate4Test EXPECT_PRED4Test;
  1.1483 +typedef Predicate4Test ASSERT_PRED4Test;
  1.1484 +
  1.1485 +// Tests a successful EXPECT_PRED4 where the
  1.1486 +// predicate-formatter is a function on a built-in type (int).
  1.1487 +TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
  1.1488 +  EXPECT_PRED4(PredFunction4Int,
  1.1489 +               ++n1_,
  1.1490 +               ++n2_,
  1.1491 +               ++n3_,
  1.1492 +               ++n4_);
  1.1493 +  finished_ = true;
  1.1494 +}
  1.1495 +
  1.1496 +// Tests a successful EXPECT_PRED4 where the
  1.1497 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1498 +TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {
  1.1499 +  EXPECT_PRED4(PredFunction4Bool,
  1.1500 +               Bool(++n1_),
  1.1501 +               Bool(++n2_),
  1.1502 +               Bool(++n3_),
  1.1503 +               Bool(++n4_));
  1.1504 +  finished_ = true;
  1.1505 +}
  1.1506 +
  1.1507 +// Tests a successful EXPECT_PRED4 where the
  1.1508 +// predicate-formatter is a functor on a built-in type (int).
  1.1509 +TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
  1.1510 +  EXPECT_PRED4(PredFunctor4(),
  1.1511 +               ++n1_,
  1.1512 +               ++n2_,
  1.1513 +               ++n3_,
  1.1514 +               ++n4_);
  1.1515 +  finished_ = true;
  1.1516 +}
  1.1517 +
  1.1518 +// Tests a successful EXPECT_PRED4 where the
  1.1519 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1520 +TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {
  1.1521 +  EXPECT_PRED4(PredFunctor4(),
  1.1522 +               Bool(++n1_),
  1.1523 +               Bool(++n2_),
  1.1524 +               Bool(++n3_),
  1.1525 +               Bool(++n4_));
  1.1526 +  finished_ = true;
  1.1527 +}
  1.1528 +
  1.1529 +// Tests a failed EXPECT_PRED4 where the
  1.1530 +// predicate-formatter is a function on a built-in type (int).
  1.1531 +TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {
  1.1532 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1533 +    EXPECT_PRED4(PredFunction4Int,
  1.1534 +                 n1_++,
  1.1535 +                 n2_++,
  1.1536 +                 n3_++,
  1.1537 +                 n4_++);
  1.1538 +    finished_ = true;
  1.1539 +  }, "");
  1.1540 +}
  1.1541 +
  1.1542 +// Tests a failed EXPECT_PRED4 where the
  1.1543 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1544 +TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {
  1.1545 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1546 +    EXPECT_PRED4(PredFunction4Bool,
  1.1547 +                 Bool(n1_++),
  1.1548 +                 Bool(n2_++),
  1.1549 +                 Bool(n3_++),
  1.1550 +                 Bool(n4_++));
  1.1551 +    finished_ = true;
  1.1552 +  }, "");
  1.1553 +}
  1.1554 +
  1.1555 +// Tests a failed EXPECT_PRED4 where the
  1.1556 +// predicate-formatter is a functor on a built-in type (int).
  1.1557 +TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {
  1.1558 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1559 +    EXPECT_PRED4(PredFunctor4(),
  1.1560 +                 n1_++,
  1.1561 +                 n2_++,
  1.1562 +                 n3_++,
  1.1563 +                 n4_++);
  1.1564 +    finished_ = true;
  1.1565 +  }, "");
  1.1566 +}
  1.1567 +
  1.1568 +// Tests a failed EXPECT_PRED4 where the
  1.1569 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1570 +TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {
  1.1571 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1572 +    EXPECT_PRED4(PredFunctor4(),
  1.1573 +                 Bool(n1_++),
  1.1574 +                 Bool(n2_++),
  1.1575 +                 Bool(n3_++),
  1.1576 +                 Bool(n4_++));
  1.1577 +    finished_ = true;
  1.1578 +  }, "");
  1.1579 +}
  1.1580 +
  1.1581 +// Tests a successful ASSERT_PRED4 where the
  1.1582 +// predicate-formatter is a function on a built-in type (int).
  1.1583 +TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {
  1.1584 +  ASSERT_PRED4(PredFunction4Int,
  1.1585 +               ++n1_,
  1.1586 +               ++n2_,
  1.1587 +               ++n3_,
  1.1588 +               ++n4_);
  1.1589 +  finished_ = true;
  1.1590 +}
  1.1591 +
  1.1592 +// Tests a successful ASSERT_PRED4 where the
  1.1593 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1594 +TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {
  1.1595 +  ASSERT_PRED4(PredFunction4Bool,
  1.1596 +               Bool(++n1_),
  1.1597 +               Bool(++n2_),
  1.1598 +               Bool(++n3_),
  1.1599 +               Bool(++n4_));
  1.1600 +  finished_ = true;
  1.1601 +}
  1.1602 +
  1.1603 +// Tests a successful ASSERT_PRED4 where the
  1.1604 +// predicate-formatter is a functor on a built-in type (int).
  1.1605 +TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {
  1.1606 +  ASSERT_PRED4(PredFunctor4(),
  1.1607 +               ++n1_,
  1.1608 +               ++n2_,
  1.1609 +               ++n3_,
  1.1610 +               ++n4_);
  1.1611 +  finished_ = true;
  1.1612 +}
  1.1613 +
  1.1614 +// Tests a successful ASSERT_PRED4 where the
  1.1615 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1616 +TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {
  1.1617 +  ASSERT_PRED4(PredFunctor4(),
  1.1618 +               Bool(++n1_),
  1.1619 +               Bool(++n2_),
  1.1620 +               Bool(++n3_),
  1.1621 +               Bool(++n4_));
  1.1622 +  finished_ = true;
  1.1623 +}
  1.1624 +
  1.1625 +// Tests a failed ASSERT_PRED4 where the
  1.1626 +// predicate-formatter is a function on a built-in type (int).
  1.1627 +TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {
  1.1628 +  expected_to_finish_ = false;
  1.1629 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1630 +    ASSERT_PRED4(PredFunction4Int,
  1.1631 +                 n1_++,
  1.1632 +                 n2_++,
  1.1633 +                 n3_++,
  1.1634 +                 n4_++);
  1.1635 +    finished_ = true;
  1.1636 +  }, "");
  1.1637 +}
  1.1638 +
  1.1639 +// Tests a failed ASSERT_PRED4 where the
  1.1640 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1641 +TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {
  1.1642 +  expected_to_finish_ = false;
  1.1643 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1644 +    ASSERT_PRED4(PredFunction4Bool,
  1.1645 +                 Bool(n1_++),
  1.1646 +                 Bool(n2_++),
  1.1647 +                 Bool(n3_++),
  1.1648 +                 Bool(n4_++));
  1.1649 +    finished_ = true;
  1.1650 +  }, "");
  1.1651 +}
  1.1652 +
  1.1653 +// Tests a failed ASSERT_PRED4 where the
  1.1654 +// predicate-formatter is a functor on a built-in type (int).
  1.1655 +TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {
  1.1656 +  expected_to_finish_ = false;
  1.1657 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1658 +    ASSERT_PRED4(PredFunctor4(),
  1.1659 +                 n1_++,
  1.1660 +                 n2_++,
  1.1661 +                 n3_++,
  1.1662 +                 n4_++);
  1.1663 +    finished_ = true;
  1.1664 +  }, "");
  1.1665 +}
  1.1666 +
  1.1667 +// Tests a failed ASSERT_PRED4 where the
  1.1668 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1669 +TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {
  1.1670 +  expected_to_finish_ = false;
  1.1671 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1672 +    ASSERT_PRED4(PredFunctor4(),
  1.1673 +                 Bool(n1_++),
  1.1674 +                 Bool(n2_++),
  1.1675 +                 Bool(n3_++),
  1.1676 +                 Bool(n4_++));
  1.1677 +    finished_ = true;
  1.1678 +  }, "");
  1.1679 +}
  1.1680 +
  1.1681 +// Tests a successful EXPECT_PRED_FORMAT4 where the
  1.1682 +// predicate-formatter is a function on a built-in type (int).
  1.1683 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
  1.1684 +  EXPECT_PRED_FORMAT4(PredFormatFunction4,
  1.1685 +                      ++n1_,
  1.1686 +                      ++n2_,
  1.1687 +                      ++n3_,
  1.1688 +                      ++n4_);
  1.1689 +  finished_ = true;
  1.1690 +}
  1.1691 +
  1.1692 +// Tests a successful EXPECT_PRED_FORMAT4 where the
  1.1693 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1694 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
  1.1695 +  EXPECT_PRED_FORMAT4(PredFormatFunction4,
  1.1696 +                      Bool(++n1_),
  1.1697 +                      Bool(++n2_),
  1.1698 +                      Bool(++n3_),
  1.1699 +                      Bool(++n4_));
  1.1700 +  finished_ = true;
  1.1701 +}
  1.1702 +
  1.1703 +// Tests a successful EXPECT_PRED_FORMAT4 where the
  1.1704 +// predicate-formatter is a functor on a built-in type (int).
  1.1705 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
  1.1706 +  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1707 +                      ++n1_,
  1.1708 +                      ++n2_,
  1.1709 +                      ++n3_,
  1.1710 +                      ++n4_);
  1.1711 +  finished_ = true;
  1.1712 +}
  1.1713 +
  1.1714 +// Tests a successful EXPECT_PRED_FORMAT4 where the
  1.1715 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1716 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
  1.1717 +  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1718 +                      Bool(++n1_),
  1.1719 +                      Bool(++n2_),
  1.1720 +                      Bool(++n3_),
  1.1721 +                      Bool(++n4_));
  1.1722 +  finished_ = true;
  1.1723 +}
  1.1724 +
  1.1725 +// Tests a failed EXPECT_PRED_FORMAT4 where the
  1.1726 +// predicate-formatter is a function on a built-in type (int).
  1.1727 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
  1.1728 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1729 +    EXPECT_PRED_FORMAT4(PredFormatFunction4,
  1.1730 +                        n1_++,
  1.1731 +                        n2_++,
  1.1732 +                        n3_++,
  1.1733 +                        n4_++);
  1.1734 +    finished_ = true;
  1.1735 +  }, "");
  1.1736 +}
  1.1737 +
  1.1738 +// Tests a failed EXPECT_PRED_FORMAT4 where the
  1.1739 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1740 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
  1.1741 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1742 +    EXPECT_PRED_FORMAT4(PredFormatFunction4,
  1.1743 +                        Bool(n1_++),
  1.1744 +                        Bool(n2_++),
  1.1745 +                        Bool(n3_++),
  1.1746 +                        Bool(n4_++));
  1.1747 +    finished_ = true;
  1.1748 +  }, "");
  1.1749 +}
  1.1750 +
  1.1751 +// Tests a failed EXPECT_PRED_FORMAT4 where the
  1.1752 +// predicate-formatter is a functor on a built-in type (int).
  1.1753 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
  1.1754 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1755 +    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1756 +                        n1_++,
  1.1757 +                        n2_++,
  1.1758 +                        n3_++,
  1.1759 +                        n4_++);
  1.1760 +    finished_ = true;
  1.1761 +  }, "");
  1.1762 +}
  1.1763 +
  1.1764 +// Tests a failed EXPECT_PRED_FORMAT4 where the
  1.1765 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1766 +TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
  1.1767 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.1768 +    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1769 +                        Bool(n1_++),
  1.1770 +                        Bool(n2_++),
  1.1771 +                        Bool(n3_++),
  1.1772 +                        Bool(n4_++));
  1.1773 +    finished_ = true;
  1.1774 +  }, "");
  1.1775 +}
  1.1776 +
  1.1777 +// Tests a successful ASSERT_PRED_FORMAT4 where the
  1.1778 +// predicate-formatter is a function on a built-in type (int).
  1.1779 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {
  1.1780 +  ASSERT_PRED_FORMAT4(PredFormatFunction4,
  1.1781 +                      ++n1_,
  1.1782 +                      ++n2_,
  1.1783 +                      ++n3_,
  1.1784 +                      ++n4_);
  1.1785 +  finished_ = true;
  1.1786 +}
  1.1787 +
  1.1788 +// Tests a successful ASSERT_PRED_FORMAT4 where the
  1.1789 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1790 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {
  1.1791 +  ASSERT_PRED_FORMAT4(PredFormatFunction4,
  1.1792 +                      Bool(++n1_),
  1.1793 +                      Bool(++n2_),
  1.1794 +                      Bool(++n3_),
  1.1795 +                      Bool(++n4_));
  1.1796 +  finished_ = true;
  1.1797 +}
  1.1798 +
  1.1799 +// Tests a successful ASSERT_PRED_FORMAT4 where the
  1.1800 +// predicate-formatter is a functor on a built-in type (int).
  1.1801 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {
  1.1802 +  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1803 +                      ++n1_,
  1.1804 +                      ++n2_,
  1.1805 +                      ++n3_,
  1.1806 +                      ++n4_);
  1.1807 +  finished_ = true;
  1.1808 +}
  1.1809 +
  1.1810 +// Tests a successful ASSERT_PRED_FORMAT4 where the
  1.1811 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1812 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {
  1.1813 +  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1814 +                      Bool(++n1_),
  1.1815 +                      Bool(++n2_),
  1.1816 +                      Bool(++n3_),
  1.1817 +                      Bool(++n4_));
  1.1818 +  finished_ = true;
  1.1819 +}
  1.1820 +
  1.1821 +// Tests a failed ASSERT_PRED_FORMAT4 where the
  1.1822 +// predicate-formatter is a function on a built-in type (int).
  1.1823 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {
  1.1824 +  expected_to_finish_ = false;
  1.1825 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1826 +    ASSERT_PRED_FORMAT4(PredFormatFunction4,
  1.1827 +                        n1_++,
  1.1828 +                        n2_++,
  1.1829 +                        n3_++,
  1.1830 +                        n4_++);
  1.1831 +    finished_ = true;
  1.1832 +  }, "");
  1.1833 +}
  1.1834 +
  1.1835 +// Tests a failed ASSERT_PRED_FORMAT4 where the
  1.1836 +// predicate-formatter is a function on a user-defined type (Bool).
  1.1837 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {
  1.1838 +  expected_to_finish_ = false;
  1.1839 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1840 +    ASSERT_PRED_FORMAT4(PredFormatFunction4,
  1.1841 +                        Bool(n1_++),
  1.1842 +                        Bool(n2_++),
  1.1843 +                        Bool(n3_++),
  1.1844 +                        Bool(n4_++));
  1.1845 +    finished_ = true;
  1.1846 +  }, "");
  1.1847 +}
  1.1848 +
  1.1849 +// Tests a failed ASSERT_PRED_FORMAT4 where the
  1.1850 +// predicate-formatter is a functor on a built-in type (int).
  1.1851 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {
  1.1852 +  expected_to_finish_ = false;
  1.1853 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1854 +    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1855 +                        n1_++,
  1.1856 +                        n2_++,
  1.1857 +                        n3_++,
  1.1858 +                        n4_++);
  1.1859 +    finished_ = true;
  1.1860 +  }, "");
  1.1861 +}
  1.1862 +
  1.1863 +// Tests a failed ASSERT_PRED_FORMAT4 where the
  1.1864 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.1865 +TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {
  1.1866 +  expected_to_finish_ = false;
  1.1867 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.1868 +    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),
  1.1869 +                        Bool(n1_++),
  1.1870 +                        Bool(n2_++),
  1.1871 +                        Bool(n3_++),
  1.1872 +                        Bool(n4_++));
  1.1873 +    finished_ = true;
  1.1874 +  }, "");
  1.1875 +}
  1.1876 +// Sample functions/functors for testing 5-ary predicate assertions.
  1.1877 +
  1.1878 +// A 5-ary predicate function.
  1.1879 +template <typename T1, typename T2, typename T3, typename T4, typename T5>
  1.1880 +bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {
  1.1881 +  return v1 + v2 + v3 + v4 + v5 > 0;
  1.1882 +}
  1.1883 +
  1.1884 +// The following two functions are needed to circumvent a bug in
  1.1885 +// gcc 2.95.3, which sometimes has problem with the above template
  1.1886 +// function.
  1.1887 +bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {
  1.1888 +  return v1 + v2 + v3 + v4 + v5 > 0;
  1.1889 +}
  1.1890 +bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {
  1.1891 +  return v1 + v2 + v3 + v4 + v5 > 0;
  1.1892 +}
  1.1893 +
  1.1894 +// A 5-ary predicate functor.
  1.1895 +struct PredFunctor5 {
  1.1896 +  template <typename T1, typename T2, typename T3, typename T4, typename T5>
  1.1897 +  bool operator()(const T1& v1,
  1.1898 +                  const T2& v2,
  1.1899 +                  const T3& v3,
  1.1900 +                  const T4& v4,
  1.1901 +                  const T5& v5) {
  1.1902 +    return v1 + v2 + v3 + v4 + v5 > 0;
  1.1903 +  }
  1.1904 +};
  1.1905 +
  1.1906 +// A 5-ary predicate-formatter function.
  1.1907 +template <typename T1, typename T2, typename T3, typename T4, typename T5>
  1.1908 +testing::AssertionResult PredFormatFunction5(const char* e1,
  1.1909 +                                             const char* e2,
  1.1910 +                                             const char* e3,
  1.1911 +                                             const char* e4,
  1.1912 +                                             const char* e5,
  1.1913 +                                             const T1& v1,
  1.1914 +                                             const T2& v2,
  1.1915 +                                             const T3& v3,
  1.1916 +                                             const T4& v4,
  1.1917 +                                             const T5& v5) {
  1.1918 +  if (PredFunction5(v1, v2, v3, v4, v5))
  1.1919 +    return testing::AssertionSuccess();
  1.1920 +
  1.1921 +  return testing::AssertionFailure()
  1.1922 +      << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5
  1.1923 +      << " is expected to be positive, but evaluates to "
  1.1924 +      << v1 + v2 + v3 + v4 + v5 << ".";
  1.1925 +}
  1.1926 +
  1.1927 +// A 5-ary predicate-formatter functor.
  1.1928 +struct PredFormatFunctor5 {
  1.1929 +  template <typename T1, typename T2, typename T3, typename T4, typename T5>
  1.1930 +  testing::AssertionResult operator()(const char* e1,
  1.1931 +                                      const char* e2,
  1.1932 +                                      const char* e3,
  1.1933 +                                      const char* e4,
  1.1934 +                                      const char* e5,
  1.1935 +                                      const T1& v1,
  1.1936 +                                      const T2& v2,
  1.1937 +                                      const T3& v3,
  1.1938 +                                      const T4& v4,
  1.1939 +                                      const T5& v5) const {
  1.1940 +    return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);
  1.1941 +  }
  1.1942 +};
  1.1943 +
  1.1944 +// Tests for {EXPECT|ASSERT}_PRED_FORMAT5.
  1.1945 +
  1.1946 +class Predicate5Test : public testing::Test {
  1.1947 + protected:
  1.1948 +  virtual void SetUp() {
  1.1949 +    expected_to_finish_ = true;
  1.1950 +    finished_ = false;
  1.1951 +    n1_ = n2_ = n3_ = n4_ = n5_ = 0;
  1.1952 +  }
  1.1953 +
  1.1954 +  virtual void TearDown() {
  1.1955 +    // Verifies that each of the predicate's arguments was evaluated
  1.1956 +    // exactly once.
  1.1957 +    EXPECT_EQ(1, n1_) <<
  1.1958 +        "The predicate assertion didn't evaluate argument 2 "
  1.1959 +        "exactly once.";
  1.1960 +    EXPECT_EQ(1, n2_) <<
  1.1961 +        "The predicate assertion didn't evaluate argument 3 "
  1.1962 +        "exactly once.";
  1.1963 +    EXPECT_EQ(1, n3_) <<
  1.1964 +        "The predicate assertion didn't evaluate argument 4 "
  1.1965 +        "exactly once.";
  1.1966 +    EXPECT_EQ(1, n4_) <<
  1.1967 +        "The predicate assertion didn't evaluate argument 5 "
  1.1968 +        "exactly once.";
  1.1969 +    EXPECT_EQ(1, n5_) <<
  1.1970 +        "The predicate assertion didn't evaluate argument 6 "
  1.1971 +        "exactly once.";
  1.1972 +
  1.1973 +    // Verifies that the control flow in the test function is expected.
  1.1974 +    if (expected_to_finish_ && !finished_) {
  1.1975 +      FAIL() << "The predicate assertion unexpactedly aborted the test.";
  1.1976 +    } else if (!expected_to_finish_ && finished_) {
  1.1977 +      FAIL() << "The failed predicate assertion didn't abort the test "
  1.1978 +                "as expected.";
  1.1979 +    }
  1.1980 +  }
  1.1981 +
  1.1982 +  // true iff the test function is expected to run to finish.
  1.1983 +  static bool expected_to_finish_;
  1.1984 +
  1.1985 +  // true iff the test function did run to finish.
  1.1986 +  static bool finished_;
  1.1987 +
  1.1988 +  static int n1_;
  1.1989 +  static int n2_;
  1.1990 +  static int n3_;
  1.1991 +  static int n4_;
  1.1992 +  static int n5_;
  1.1993 +};
  1.1994 +
  1.1995 +bool Predicate5Test::expected_to_finish_;
  1.1996 +bool Predicate5Test::finished_;
  1.1997 +int Predicate5Test::n1_;
  1.1998 +int Predicate5Test::n2_;
  1.1999 +int Predicate5Test::n3_;
  1.2000 +int Predicate5Test::n4_;
  1.2001 +int Predicate5Test::n5_;
  1.2002 +
  1.2003 +typedef Predicate5Test EXPECT_PRED_FORMAT5Test;
  1.2004 +typedef Predicate5Test ASSERT_PRED_FORMAT5Test;
  1.2005 +typedef Predicate5Test EXPECT_PRED5Test;
  1.2006 +typedef Predicate5Test ASSERT_PRED5Test;
  1.2007 +
  1.2008 +// Tests a successful EXPECT_PRED5 where the
  1.2009 +// predicate-formatter is a function on a built-in type (int).
  1.2010 +TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
  1.2011 +  EXPECT_PRED5(PredFunction5Int,
  1.2012 +               ++n1_,
  1.2013 +               ++n2_,
  1.2014 +               ++n3_,
  1.2015 +               ++n4_,
  1.2016 +               ++n5_);
  1.2017 +  finished_ = true;
  1.2018 +}
  1.2019 +
  1.2020 +// Tests a successful EXPECT_PRED5 where the
  1.2021 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2022 +TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {
  1.2023 +  EXPECT_PRED5(PredFunction5Bool,
  1.2024 +               Bool(++n1_),
  1.2025 +               Bool(++n2_),
  1.2026 +               Bool(++n3_),
  1.2027 +               Bool(++n4_),
  1.2028 +               Bool(++n5_));
  1.2029 +  finished_ = true;
  1.2030 +}
  1.2031 +
  1.2032 +// Tests a successful EXPECT_PRED5 where the
  1.2033 +// predicate-formatter is a functor on a built-in type (int).
  1.2034 +TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
  1.2035 +  EXPECT_PRED5(PredFunctor5(),
  1.2036 +               ++n1_,
  1.2037 +               ++n2_,
  1.2038 +               ++n3_,
  1.2039 +               ++n4_,
  1.2040 +               ++n5_);
  1.2041 +  finished_ = true;
  1.2042 +}
  1.2043 +
  1.2044 +// Tests a successful EXPECT_PRED5 where the
  1.2045 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2046 +TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {
  1.2047 +  EXPECT_PRED5(PredFunctor5(),
  1.2048 +               Bool(++n1_),
  1.2049 +               Bool(++n2_),
  1.2050 +               Bool(++n3_),
  1.2051 +               Bool(++n4_),
  1.2052 +               Bool(++n5_));
  1.2053 +  finished_ = true;
  1.2054 +}
  1.2055 +
  1.2056 +// Tests a failed EXPECT_PRED5 where the
  1.2057 +// predicate-formatter is a function on a built-in type (int).
  1.2058 +TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {
  1.2059 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2060 +    EXPECT_PRED5(PredFunction5Int,
  1.2061 +                 n1_++,
  1.2062 +                 n2_++,
  1.2063 +                 n3_++,
  1.2064 +                 n4_++,
  1.2065 +                 n5_++);
  1.2066 +    finished_ = true;
  1.2067 +  }, "");
  1.2068 +}
  1.2069 +
  1.2070 +// Tests a failed EXPECT_PRED5 where the
  1.2071 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2072 +TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {
  1.2073 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2074 +    EXPECT_PRED5(PredFunction5Bool,
  1.2075 +                 Bool(n1_++),
  1.2076 +                 Bool(n2_++),
  1.2077 +                 Bool(n3_++),
  1.2078 +                 Bool(n4_++),
  1.2079 +                 Bool(n5_++));
  1.2080 +    finished_ = true;
  1.2081 +  }, "");
  1.2082 +}
  1.2083 +
  1.2084 +// Tests a failed EXPECT_PRED5 where the
  1.2085 +// predicate-formatter is a functor on a built-in type (int).
  1.2086 +TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {
  1.2087 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2088 +    EXPECT_PRED5(PredFunctor5(),
  1.2089 +                 n1_++,
  1.2090 +                 n2_++,
  1.2091 +                 n3_++,
  1.2092 +                 n4_++,
  1.2093 +                 n5_++);
  1.2094 +    finished_ = true;
  1.2095 +  }, "");
  1.2096 +}
  1.2097 +
  1.2098 +// Tests a failed EXPECT_PRED5 where the
  1.2099 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2100 +TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {
  1.2101 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2102 +    EXPECT_PRED5(PredFunctor5(),
  1.2103 +                 Bool(n1_++),
  1.2104 +                 Bool(n2_++),
  1.2105 +                 Bool(n3_++),
  1.2106 +                 Bool(n4_++),
  1.2107 +                 Bool(n5_++));
  1.2108 +    finished_ = true;
  1.2109 +  }, "");
  1.2110 +}
  1.2111 +
  1.2112 +// Tests a successful ASSERT_PRED5 where the
  1.2113 +// predicate-formatter is a function on a built-in type (int).
  1.2114 +TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {
  1.2115 +  ASSERT_PRED5(PredFunction5Int,
  1.2116 +               ++n1_,
  1.2117 +               ++n2_,
  1.2118 +               ++n3_,
  1.2119 +               ++n4_,
  1.2120 +               ++n5_);
  1.2121 +  finished_ = true;
  1.2122 +}
  1.2123 +
  1.2124 +// Tests a successful ASSERT_PRED5 where the
  1.2125 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2126 +TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {
  1.2127 +  ASSERT_PRED5(PredFunction5Bool,
  1.2128 +               Bool(++n1_),
  1.2129 +               Bool(++n2_),
  1.2130 +               Bool(++n3_),
  1.2131 +               Bool(++n4_),
  1.2132 +               Bool(++n5_));
  1.2133 +  finished_ = true;
  1.2134 +}
  1.2135 +
  1.2136 +// Tests a successful ASSERT_PRED5 where the
  1.2137 +// predicate-formatter is a functor on a built-in type (int).
  1.2138 +TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {
  1.2139 +  ASSERT_PRED5(PredFunctor5(),
  1.2140 +               ++n1_,
  1.2141 +               ++n2_,
  1.2142 +               ++n3_,
  1.2143 +               ++n4_,
  1.2144 +               ++n5_);
  1.2145 +  finished_ = true;
  1.2146 +}
  1.2147 +
  1.2148 +// Tests a successful ASSERT_PRED5 where the
  1.2149 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2150 +TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {
  1.2151 +  ASSERT_PRED5(PredFunctor5(),
  1.2152 +               Bool(++n1_),
  1.2153 +               Bool(++n2_),
  1.2154 +               Bool(++n3_),
  1.2155 +               Bool(++n4_),
  1.2156 +               Bool(++n5_));
  1.2157 +  finished_ = true;
  1.2158 +}
  1.2159 +
  1.2160 +// Tests a failed ASSERT_PRED5 where the
  1.2161 +// predicate-formatter is a function on a built-in type (int).
  1.2162 +TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {
  1.2163 +  expected_to_finish_ = false;
  1.2164 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2165 +    ASSERT_PRED5(PredFunction5Int,
  1.2166 +                 n1_++,
  1.2167 +                 n2_++,
  1.2168 +                 n3_++,
  1.2169 +                 n4_++,
  1.2170 +                 n5_++);
  1.2171 +    finished_ = true;
  1.2172 +  }, "");
  1.2173 +}
  1.2174 +
  1.2175 +// Tests a failed ASSERT_PRED5 where the
  1.2176 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2177 +TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {
  1.2178 +  expected_to_finish_ = false;
  1.2179 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2180 +    ASSERT_PRED5(PredFunction5Bool,
  1.2181 +                 Bool(n1_++),
  1.2182 +                 Bool(n2_++),
  1.2183 +                 Bool(n3_++),
  1.2184 +                 Bool(n4_++),
  1.2185 +                 Bool(n5_++));
  1.2186 +    finished_ = true;
  1.2187 +  }, "");
  1.2188 +}
  1.2189 +
  1.2190 +// Tests a failed ASSERT_PRED5 where the
  1.2191 +// predicate-formatter is a functor on a built-in type (int).
  1.2192 +TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {
  1.2193 +  expected_to_finish_ = false;
  1.2194 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2195 +    ASSERT_PRED5(PredFunctor5(),
  1.2196 +                 n1_++,
  1.2197 +                 n2_++,
  1.2198 +                 n3_++,
  1.2199 +                 n4_++,
  1.2200 +                 n5_++);
  1.2201 +    finished_ = true;
  1.2202 +  }, "");
  1.2203 +}
  1.2204 +
  1.2205 +// Tests a failed ASSERT_PRED5 where the
  1.2206 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2207 +TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {
  1.2208 +  expected_to_finish_ = false;
  1.2209 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2210 +    ASSERT_PRED5(PredFunctor5(),
  1.2211 +                 Bool(n1_++),
  1.2212 +                 Bool(n2_++),
  1.2213 +                 Bool(n3_++),
  1.2214 +                 Bool(n4_++),
  1.2215 +                 Bool(n5_++));
  1.2216 +    finished_ = true;
  1.2217 +  }, "");
  1.2218 +}
  1.2219 +
  1.2220 +// Tests a successful EXPECT_PRED_FORMAT5 where the
  1.2221 +// predicate-formatter is a function on a built-in type (int).
  1.2222 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
  1.2223 +  EXPECT_PRED_FORMAT5(PredFormatFunction5,
  1.2224 +                      ++n1_,
  1.2225 +                      ++n2_,
  1.2226 +                      ++n3_,
  1.2227 +                      ++n4_,
  1.2228 +                      ++n5_);
  1.2229 +  finished_ = true;
  1.2230 +}
  1.2231 +
  1.2232 +// Tests a successful EXPECT_PRED_FORMAT5 where the
  1.2233 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2234 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
  1.2235 +  EXPECT_PRED_FORMAT5(PredFormatFunction5,
  1.2236 +                      Bool(++n1_),
  1.2237 +                      Bool(++n2_),
  1.2238 +                      Bool(++n3_),
  1.2239 +                      Bool(++n4_),
  1.2240 +                      Bool(++n5_));
  1.2241 +  finished_ = true;
  1.2242 +}
  1.2243 +
  1.2244 +// Tests a successful EXPECT_PRED_FORMAT5 where the
  1.2245 +// predicate-formatter is a functor on a built-in type (int).
  1.2246 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
  1.2247 +  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2248 +                      ++n1_,
  1.2249 +                      ++n2_,
  1.2250 +                      ++n3_,
  1.2251 +                      ++n4_,
  1.2252 +                      ++n5_);
  1.2253 +  finished_ = true;
  1.2254 +}
  1.2255 +
  1.2256 +// Tests a successful EXPECT_PRED_FORMAT5 where the
  1.2257 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2258 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
  1.2259 +  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2260 +                      Bool(++n1_),
  1.2261 +                      Bool(++n2_),
  1.2262 +                      Bool(++n3_),
  1.2263 +                      Bool(++n4_),
  1.2264 +                      Bool(++n5_));
  1.2265 +  finished_ = true;
  1.2266 +}
  1.2267 +
  1.2268 +// Tests a failed EXPECT_PRED_FORMAT5 where the
  1.2269 +// predicate-formatter is a function on a built-in type (int).
  1.2270 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
  1.2271 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2272 +    EXPECT_PRED_FORMAT5(PredFormatFunction5,
  1.2273 +                        n1_++,
  1.2274 +                        n2_++,
  1.2275 +                        n3_++,
  1.2276 +                        n4_++,
  1.2277 +                        n5_++);
  1.2278 +    finished_ = true;
  1.2279 +  }, "");
  1.2280 +}
  1.2281 +
  1.2282 +// Tests a failed EXPECT_PRED_FORMAT5 where the
  1.2283 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2284 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
  1.2285 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2286 +    EXPECT_PRED_FORMAT5(PredFormatFunction5,
  1.2287 +                        Bool(n1_++),
  1.2288 +                        Bool(n2_++),
  1.2289 +                        Bool(n3_++),
  1.2290 +                        Bool(n4_++),
  1.2291 +                        Bool(n5_++));
  1.2292 +    finished_ = true;
  1.2293 +  }, "");
  1.2294 +}
  1.2295 +
  1.2296 +// Tests a failed EXPECT_PRED_FORMAT5 where the
  1.2297 +// predicate-formatter is a functor on a built-in type (int).
  1.2298 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
  1.2299 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2300 +    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2301 +                        n1_++,
  1.2302 +                        n2_++,
  1.2303 +                        n3_++,
  1.2304 +                        n4_++,
  1.2305 +                        n5_++);
  1.2306 +    finished_ = true;
  1.2307 +  }, "");
  1.2308 +}
  1.2309 +
  1.2310 +// Tests a failed EXPECT_PRED_FORMAT5 where the
  1.2311 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2312 +TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
  1.2313 +  EXPECT_NONFATAL_FAILURE({  // NOLINT
  1.2314 +    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2315 +                        Bool(n1_++),
  1.2316 +                        Bool(n2_++),
  1.2317 +                        Bool(n3_++),
  1.2318 +                        Bool(n4_++),
  1.2319 +                        Bool(n5_++));
  1.2320 +    finished_ = true;
  1.2321 +  }, "");
  1.2322 +}
  1.2323 +
  1.2324 +// Tests a successful ASSERT_PRED_FORMAT5 where the
  1.2325 +// predicate-formatter is a function on a built-in type (int).
  1.2326 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {
  1.2327 +  ASSERT_PRED_FORMAT5(PredFormatFunction5,
  1.2328 +                      ++n1_,
  1.2329 +                      ++n2_,
  1.2330 +                      ++n3_,
  1.2331 +                      ++n4_,
  1.2332 +                      ++n5_);
  1.2333 +  finished_ = true;
  1.2334 +}
  1.2335 +
  1.2336 +// Tests a successful ASSERT_PRED_FORMAT5 where the
  1.2337 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2338 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {
  1.2339 +  ASSERT_PRED_FORMAT5(PredFormatFunction5,
  1.2340 +                      Bool(++n1_),
  1.2341 +                      Bool(++n2_),
  1.2342 +                      Bool(++n3_),
  1.2343 +                      Bool(++n4_),
  1.2344 +                      Bool(++n5_));
  1.2345 +  finished_ = true;
  1.2346 +}
  1.2347 +
  1.2348 +// Tests a successful ASSERT_PRED_FORMAT5 where the
  1.2349 +// predicate-formatter is a functor on a built-in type (int).
  1.2350 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {
  1.2351 +  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2352 +                      ++n1_,
  1.2353 +                      ++n2_,
  1.2354 +                      ++n3_,
  1.2355 +                      ++n4_,
  1.2356 +                      ++n5_);
  1.2357 +  finished_ = true;
  1.2358 +}
  1.2359 +
  1.2360 +// Tests a successful ASSERT_PRED_FORMAT5 where the
  1.2361 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2362 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {
  1.2363 +  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2364 +                      Bool(++n1_),
  1.2365 +                      Bool(++n2_),
  1.2366 +                      Bool(++n3_),
  1.2367 +                      Bool(++n4_),
  1.2368 +                      Bool(++n5_));
  1.2369 +  finished_ = true;
  1.2370 +}
  1.2371 +
  1.2372 +// Tests a failed ASSERT_PRED_FORMAT5 where the
  1.2373 +// predicate-formatter is a function on a built-in type (int).
  1.2374 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {
  1.2375 +  expected_to_finish_ = false;
  1.2376 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2377 +    ASSERT_PRED_FORMAT5(PredFormatFunction5,
  1.2378 +                        n1_++,
  1.2379 +                        n2_++,
  1.2380 +                        n3_++,
  1.2381 +                        n4_++,
  1.2382 +                        n5_++);
  1.2383 +    finished_ = true;
  1.2384 +  }, "");
  1.2385 +}
  1.2386 +
  1.2387 +// Tests a failed ASSERT_PRED_FORMAT5 where the
  1.2388 +// predicate-formatter is a function on a user-defined type (Bool).
  1.2389 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {
  1.2390 +  expected_to_finish_ = false;
  1.2391 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2392 +    ASSERT_PRED_FORMAT5(PredFormatFunction5,
  1.2393 +                        Bool(n1_++),
  1.2394 +                        Bool(n2_++),
  1.2395 +                        Bool(n3_++),
  1.2396 +                        Bool(n4_++),
  1.2397 +                        Bool(n5_++));
  1.2398 +    finished_ = true;
  1.2399 +  }, "");
  1.2400 +}
  1.2401 +
  1.2402 +// Tests a failed ASSERT_PRED_FORMAT5 where the
  1.2403 +// predicate-formatter is a functor on a built-in type (int).
  1.2404 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {
  1.2405 +  expected_to_finish_ = false;
  1.2406 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2407 +    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2408 +                        n1_++,
  1.2409 +                        n2_++,
  1.2410 +                        n3_++,
  1.2411 +                        n4_++,
  1.2412 +                        n5_++);
  1.2413 +    finished_ = true;
  1.2414 +  }, "");
  1.2415 +}
  1.2416 +
  1.2417 +// Tests a failed ASSERT_PRED_FORMAT5 where the
  1.2418 +// predicate-formatter is a functor on a user-defined type (Bool).
  1.2419 +TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {
  1.2420 +  expected_to_finish_ = false;
  1.2421 +  EXPECT_FATAL_FAILURE({  // NOLINT
  1.2422 +    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),
  1.2423 +                        Bool(n1_++),
  1.2424 +                        Bool(n2_++),
  1.2425 +                        Bool(n3_++),
  1.2426 +                        Bool(n4_++),
  1.2427 +                        Bool(n5_++));
  1.2428 +    finished_ = true;
  1.2429 +  }, "");
  1.2430 +}

mercurial