michael@0: // Copyright 2006, Google Inc. michael@0: // All rights reserved. michael@0: // michael@0: // Redistribution and use in source and binary forms, with or without michael@0: // modification, are permitted provided that the following conditions are michael@0: // met: michael@0: // michael@0: // * Redistributions of source code must retain the above copyright michael@0: // notice, this list of conditions and the following disclaimer. michael@0: // * Redistributions in binary form must reproduce the above michael@0: // copyright notice, this list of conditions and the following disclaimer michael@0: // in the documentation and/or other materials provided with the michael@0: // distribution. michael@0: // * Neither the name of Google Inc. nor the names of its michael@0: // contributors may be used to endorse or promote products derived from michael@0: // this software without specific prior written permission. michael@0: // michael@0: // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT michael@0: // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, michael@0: // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT michael@0: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, michael@0: // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY michael@0: // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: michael@0: // This file is AUTOMATICALLY GENERATED on 10/31/2011 by command michael@0: // 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! michael@0: michael@0: // Regression test for gtest_pred_impl.h michael@0: // michael@0: // This file is generated by a script and quite long. If you intend to michael@0: // learn how Google Test works by reading its unit tests, read michael@0: // gtest_unittest.cc instead. michael@0: // michael@0: // This is intended as a regression test for the Google Test predicate michael@0: // assertions. We compile it as part of the gtest_unittest target michael@0: // only to keep the implementation tidy and compact, as it is quite michael@0: // involved to set up the stage for testing Google Test using Google michael@0: // Test itself. michael@0: // michael@0: // Currently, gtest_unittest takes ~11 seconds to run in the testing michael@0: // daemon. In the future, if it grows too large and needs much more michael@0: // time to finish, we should consider separating this file into a michael@0: // stand-alone regression test. michael@0: michael@0: #include michael@0: michael@0: #include "gtest/gtest.h" michael@0: #include "gtest/gtest-spi.h" michael@0: michael@0: // A user-defined data type. michael@0: struct Bool { michael@0: explicit Bool(int val) : value(val != 0) {} michael@0: michael@0: bool operator>(int n) const { return value > Bool(n).value; } michael@0: michael@0: Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); } michael@0: michael@0: bool operator==(const Bool& rhs) const { return value == rhs.value; } michael@0: michael@0: bool value; michael@0: }; michael@0: michael@0: // Enables Bool to be used in assertions. michael@0: std::ostream& operator<<(std::ostream& os, const Bool& x) { michael@0: return os << (x.value ? "true" : "false"); michael@0: } michael@0: michael@0: // Sample functions/functors for testing unary predicate assertions. michael@0: michael@0: // A unary predicate function. michael@0: template michael@0: bool PredFunction1(T1 v1) { michael@0: return v1 > 0; michael@0: } michael@0: michael@0: // The following two functions are needed to circumvent a bug in michael@0: // gcc 2.95.3, which sometimes has problem with the above template michael@0: // function. michael@0: bool PredFunction1Int(int v1) { michael@0: return v1 > 0; michael@0: } michael@0: bool PredFunction1Bool(Bool v1) { michael@0: return v1 > 0; michael@0: } michael@0: michael@0: // A unary predicate functor. michael@0: struct PredFunctor1 { michael@0: template michael@0: bool operator()(const T1& v1) { michael@0: return v1 > 0; michael@0: } michael@0: }; michael@0: michael@0: // A unary predicate-formatter function. michael@0: template michael@0: testing::AssertionResult PredFormatFunction1(const char* e1, michael@0: const T1& v1) { michael@0: if (PredFunction1(v1)) michael@0: return testing::AssertionSuccess(); michael@0: michael@0: return testing::AssertionFailure() michael@0: << e1 michael@0: << " is expected to be positive, but evaluates to " michael@0: << v1 << "."; michael@0: } michael@0: michael@0: // A unary predicate-formatter functor. michael@0: struct PredFormatFunctor1 { michael@0: template michael@0: testing::AssertionResult operator()(const char* e1, michael@0: const T1& v1) const { michael@0: return PredFormatFunction1(e1, v1); michael@0: } michael@0: }; michael@0: michael@0: // Tests for {EXPECT|ASSERT}_PRED_FORMAT1. michael@0: michael@0: class Predicate1Test : public testing::Test { michael@0: protected: michael@0: virtual void SetUp() { michael@0: expected_to_finish_ = true; michael@0: finished_ = false; michael@0: n1_ = 0; michael@0: } michael@0: michael@0: virtual void TearDown() { michael@0: // Verifies that each of the predicate's arguments was evaluated michael@0: // exactly once. michael@0: EXPECT_EQ(1, n1_) << michael@0: "The predicate assertion didn't evaluate argument 2 " michael@0: "exactly once."; michael@0: michael@0: // Verifies that the control flow in the test function is expected. michael@0: if (expected_to_finish_ && !finished_) { michael@0: FAIL() << "The predicate assertion unexpactedly aborted the test."; michael@0: } else if (!expected_to_finish_ && finished_) { michael@0: FAIL() << "The failed predicate assertion didn't abort the test " michael@0: "as expected."; michael@0: } michael@0: } michael@0: michael@0: // true iff the test function is expected to run to finish. michael@0: static bool expected_to_finish_; michael@0: michael@0: // true iff the test function did run to finish. michael@0: static bool finished_; michael@0: michael@0: static int n1_; michael@0: }; michael@0: michael@0: bool Predicate1Test::expected_to_finish_; michael@0: bool Predicate1Test::finished_; michael@0: int Predicate1Test::n1_; michael@0: michael@0: typedef Predicate1Test EXPECT_PRED_FORMAT1Test; michael@0: typedef Predicate1Test ASSERT_PRED_FORMAT1Test; michael@0: typedef Predicate1Test EXPECT_PRED1Test; michael@0: typedef Predicate1Test ASSERT_PRED1Test; michael@0: michael@0: // Tests a successful EXPECT_PRED1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED1(PredFunction1Int, michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED1(PredFunction1Bool, michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED1(PredFunctor1(), michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED1(PredFunctor1(), michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED1(PredFunction1Int, michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED1(PredFunction1Bool, michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED1(PredFunctor1(), michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED1(PredFunctor1(), michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED1(PredFunction1Int, michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED1(PredFunction1Bool, michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED1(PredFunctor1(), michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED1(PredFunctor1(), michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED1(PredFunction1Int, michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED1(PredFunction1Bool, michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED1(PredFunctor1(), michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED1(PredFunctor1(), michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT1(PredFormatFunction1, michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT1(PredFormatFunction1, michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT1(PredFormatFunction1, michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT1(PredFormatFunction1, michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT1(PredFormatFunction1, michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT1(PredFormatFunction1, michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: ++n1_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: Bool(++n1_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT1(PredFormatFunction1, michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT1(PredFormatFunction1, michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: n1_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT1 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT1(PredFormatFunctor1(), michael@0: Bool(n1_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: // Sample functions/functors for testing binary predicate assertions. michael@0: michael@0: // A binary predicate function. michael@0: template michael@0: bool PredFunction2(T1 v1, T2 v2) { michael@0: return v1 + v2 > 0; michael@0: } michael@0: michael@0: // The following two functions are needed to circumvent a bug in michael@0: // gcc 2.95.3, which sometimes has problem with the above template michael@0: // function. michael@0: bool PredFunction2Int(int v1, int v2) { michael@0: return v1 + v2 > 0; michael@0: } michael@0: bool PredFunction2Bool(Bool v1, Bool v2) { michael@0: return v1 + v2 > 0; michael@0: } michael@0: michael@0: // A binary predicate functor. michael@0: struct PredFunctor2 { michael@0: template michael@0: bool operator()(const T1& v1, michael@0: const T2& v2) { michael@0: return v1 + v2 > 0; michael@0: } michael@0: }; michael@0: michael@0: // A binary predicate-formatter function. michael@0: template michael@0: testing::AssertionResult PredFormatFunction2(const char* e1, michael@0: const char* e2, michael@0: const T1& v1, michael@0: const T2& v2) { michael@0: if (PredFunction2(v1, v2)) michael@0: return testing::AssertionSuccess(); michael@0: michael@0: return testing::AssertionFailure() michael@0: << e1 << " + " << e2 michael@0: << " is expected to be positive, but evaluates to " michael@0: << v1 + v2 << "."; michael@0: } michael@0: michael@0: // A binary predicate-formatter functor. michael@0: struct PredFormatFunctor2 { michael@0: template michael@0: testing::AssertionResult operator()(const char* e1, michael@0: const char* e2, michael@0: const T1& v1, michael@0: const T2& v2) const { michael@0: return PredFormatFunction2(e1, e2, v1, v2); michael@0: } michael@0: }; michael@0: michael@0: // Tests for {EXPECT|ASSERT}_PRED_FORMAT2. michael@0: michael@0: class Predicate2Test : public testing::Test { michael@0: protected: michael@0: virtual void SetUp() { michael@0: expected_to_finish_ = true; michael@0: finished_ = false; michael@0: n1_ = n2_ = 0; michael@0: } michael@0: michael@0: virtual void TearDown() { michael@0: // Verifies that each of the predicate's arguments was evaluated michael@0: // exactly once. michael@0: EXPECT_EQ(1, n1_) << michael@0: "The predicate assertion didn't evaluate argument 2 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n2_) << michael@0: "The predicate assertion didn't evaluate argument 3 " michael@0: "exactly once."; michael@0: michael@0: // Verifies that the control flow in the test function is expected. michael@0: if (expected_to_finish_ && !finished_) { michael@0: FAIL() << "The predicate assertion unexpactedly aborted the test."; michael@0: } else if (!expected_to_finish_ && finished_) { michael@0: FAIL() << "The failed predicate assertion didn't abort the test " michael@0: "as expected."; michael@0: } michael@0: } michael@0: michael@0: // true iff the test function is expected to run to finish. michael@0: static bool expected_to_finish_; michael@0: michael@0: // true iff the test function did run to finish. michael@0: static bool finished_; michael@0: michael@0: static int n1_; michael@0: static int n2_; michael@0: }; michael@0: michael@0: bool Predicate2Test::expected_to_finish_; michael@0: bool Predicate2Test::finished_; michael@0: int Predicate2Test::n1_; michael@0: int Predicate2Test::n2_; michael@0: michael@0: typedef Predicate2Test EXPECT_PRED_FORMAT2Test; michael@0: typedef Predicate2Test ASSERT_PRED_FORMAT2Test; michael@0: typedef Predicate2Test EXPECT_PRED2Test; michael@0: typedef Predicate2Test ASSERT_PRED2Test; michael@0: michael@0: // Tests a successful EXPECT_PRED2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED2(PredFunction2Int, michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED2(PredFunction2Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED2(PredFunctor2(), michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED2(PredFunctor2(), michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED2(PredFunction2Int, michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED2(PredFunction2Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED2(PredFunctor2(), michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED2(PredFunctor2(), michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED2(PredFunction2Int, michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED2(PredFunction2Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED2(PredFunctor2(), michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED2(PredFunctor2(), michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED2(PredFunction2Int, michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED2(PredFunction2Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED2(PredFunctor2(), michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED2(PredFunctor2(), michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT2(PredFormatFunction2, michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT2(PredFormatFunction2, michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT2(PredFormatFunction2, michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT2(PredFormatFunction2, michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT2(PredFormatFunction2, michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT2(PredFormatFunction2, michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: ++n1_, michael@0: ++n2_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: Bool(++n1_), michael@0: Bool(++n2_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT2(PredFormatFunction2, michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT2(PredFormatFunction2, michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: n1_++, michael@0: n2_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT2 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT2(PredFormatFunctor2(), michael@0: Bool(n1_++), michael@0: Bool(n2_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: // Sample functions/functors for testing ternary predicate assertions. michael@0: michael@0: // A ternary predicate function. michael@0: template michael@0: bool PredFunction3(T1 v1, T2 v2, T3 v3) { michael@0: return v1 + v2 + v3 > 0; michael@0: } michael@0: michael@0: // The following two functions are needed to circumvent a bug in michael@0: // gcc 2.95.3, which sometimes has problem with the above template michael@0: // function. michael@0: bool PredFunction3Int(int v1, int v2, int v3) { michael@0: return v1 + v2 + v3 > 0; michael@0: } michael@0: bool PredFunction3Bool(Bool v1, Bool v2, Bool v3) { michael@0: return v1 + v2 + v3 > 0; michael@0: } michael@0: michael@0: // A ternary predicate functor. michael@0: struct PredFunctor3 { michael@0: template michael@0: bool operator()(const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3) { michael@0: return v1 + v2 + v3 > 0; michael@0: } michael@0: }; michael@0: michael@0: // A ternary predicate-formatter function. michael@0: template michael@0: testing::AssertionResult PredFormatFunction3(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3) { michael@0: if (PredFunction3(v1, v2, v3)) michael@0: return testing::AssertionSuccess(); michael@0: michael@0: return testing::AssertionFailure() michael@0: << e1 << " + " << e2 << " + " << e3 michael@0: << " is expected to be positive, but evaluates to " michael@0: << v1 + v2 + v3 << "."; michael@0: } michael@0: michael@0: // A ternary predicate-formatter functor. michael@0: struct PredFormatFunctor3 { michael@0: template michael@0: testing::AssertionResult operator()(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3) const { michael@0: return PredFormatFunction3(e1, e2, e3, v1, v2, v3); michael@0: } michael@0: }; michael@0: michael@0: // Tests for {EXPECT|ASSERT}_PRED_FORMAT3. michael@0: michael@0: class Predicate3Test : public testing::Test { michael@0: protected: michael@0: virtual void SetUp() { michael@0: expected_to_finish_ = true; michael@0: finished_ = false; michael@0: n1_ = n2_ = n3_ = 0; michael@0: } michael@0: michael@0: virtual void TearDown() { michael@0: // Verifies that each of the predicate's arguments was evaluated michael@0: // exactly once. michael@0: EXPECT_EQ(1, n1_) << michael@0: "The predicate assertion didn't evaluate argument 2 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n2_) << michael@0: "The predicate assertion didn't evaluate argument 3 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n3_) << michael@0: "The predicate assertion didn't evaluate argument 4 " michael@0: "exactly once."; michael@0: michael@0: // Verifies that the control flow in the test function is expected. michael@0: if (expected_to_finish_ && !finished_) { michael@0: FAIL() << "The predicate assertion unexpactedly aborted the test."; michael@0: } else if (!expected_to_finish_ && finished_) { michael@0: FAIL() << "The failed predicate assertion didn't abort the test " michael@0: "as expected."; michael@0: } michael@0: } michael@0: michael@0: // true iff the test function is expected to run to finish. michael@0: static bool expected_to_finish_; michael@0: michael@0: // true iff the test function did run to finish. michael@0: static bool finished_; michael@0: michael@0: static int n1_; michael@0: static int n2_; michael@0: static int n3_; michael@0: }; michael@0: michael@0: bool Predicate3Test::expected_to_finish_; michael@0: bool Predicate3Test::finished_; michael@0: int Predicate3Test::n1_; michael@0: int Predicate3Test::n2_; michael@0: int Predicate3Test::n3_; michael@0: michael@0: typedef Predicate3Test EXPECT_PRED_FORMAT3Test; michael@0: typedef Predicate3Test ASSERT_PRED_FORMAT3Test; michael@0: typedef Predicate3Test EXPECT_PRED3Test; michael@0: typedef Predicate3Test ASSERT_PRED3Test; michael@0: michael@0: // Tests a successful EXPECT_PRED3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED3(PredFunction3Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED3(PredFunction3Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED3(PredFunctor3(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED3(PredFunctor3(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED3(PredFunction3Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED3(PredFunction3Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED3(PredFunctor3(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED3(PredFunctor3(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED3(PredFunction3Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED3(PredFunction3Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED3(PredFunctor3(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED3(PredFunctor3(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED3(PredFunction3Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED3(PredFunction3Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED3(PredFunctor3(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED3(PredFunctor3(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT3(PredFormatFunction3, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT3(PredFormatFunction3, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT3(PredFormatFunction3, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT3(PredFormatFunction3, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT3(PredFormatFunction3, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT3(PredFormatFunction3, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT3(PredFormatFunction3, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT3(PredFormatFunction3, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT3 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT3(PredFormatFunctor3(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: // Sample functions/functors for testing 4-ary predicate assertions. michael@0: michael@0: // A 4-ary predicate function. michael@0: template michael@0: bool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) { michael@0: return v1 + v2 + v3 + v4 > 0; michael@0: } michael@0: michael@0: // The following two functions are needed to circumvent a bug in michael@0: // gcc 2.95.3, which sometimes has problem with the above template michael@0: // function. michael@0: bool PredFunction4Int(int v1, int v2, int v3, int v4) { michael@0: return v1 + v2 + v3 + v4 > 0; michael@0: } michael@0: bool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) { michael@0: return v1 + v2 + v3 + v4 > 0; michael@0: } michael@0: michael@0: // A 4-ary predicate functor. michael@0: struct PredFunctor4 { michael@0: template michael@0: bool operator()(const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4) { michael@0: return v1 + v2 + v3 + v4 > 0; michael@0: } michael@0: }; michael@0: michael@0: // A 4-ary predicate-formatter function. michael@0: template michael@0: testing::AssertionResult PredFormatFunction4(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const char* e4, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4) { michael@0: if (PredFunction4(v1, v2, v3, v4)) michael@0: return testing::AssertionSuccess(); michael@0: michael@0: return testing::AssertionFailure() michael@0: << e1 << " + " << e2 << " + " << e3 << " + " << e4 michael@0: << " is expected to be positive, but evaluates to " michael@0: << v1 + v2 + v3 + v4 << "."; michael@0: } michael@0: michael@0: // A 4-ary predicate-formatter functor. michael@0: struct PredFormatFunctor4 { michael@0: template michael@0: testing::AssertionResult operator()(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const char* e4, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4) const { michael@0: return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4); michael@0: } michael@0: }; michael@0: michael@0: // Tests for {EXPECT|ASSERT}_PRED_FORMAT4. michael@0: michael@0: class Predicate4Test : public testing::Test { michael@0: protected: michael@0: virtual void SetUp() { michael@0: expected_to_finish_ = true; michael@0: finished_ = false; michael@0: n1_ = n2_ = n3_ = n4_ = 0; michael@0: } michael@0: michael@0: virtual void TearDown() { michael@0: // Verifies that each of the predicate's arguments was evaluated michael@0: // exactly once. michael@0: EXPECT_EQ(1, n1_) << michael@0: "The predicate assertion didn't evaluate argument 2 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n2_) << michael@0: "The predicate assertion didn't evaluate argument 3 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n3_) << michael@0: "The predicate assertion didn't evaluate argument 4 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n4_) << michael@0: "The predicate assertion didn't evaluate argument 5 " michael@0: "exactly once."; michael@0: michael@0: // Verifies that the control flow in the test function is expected. michael@0: if (expected_to_finish_ && !finished_) { michael@0: FAIL() << "The predicate assertion unexpactedly aborted the test."; michael@0: } else if (!expected_to_finish_ && finished_) { michael@0: FAIL() << "The failed predicate assertion didn't abort the test " michael@0: "as expected."; michael@0: } michael@0: } michael@0: michael@0: // true iff the test function is expected to run to finish. michael@0: static bool expected_to_finish_; michael@0: michael@0: // true iff the test function did run to finish. michael@0: static bool finished_; michael@0: michael@0: static int n1_; michael@0: static int n2_; michael@0: static int n3_; michael@0: static int n4_; michael@0: }; michael@0: michael@0: bool Predicate4Test::expected_to_finish_; michael@0: bool Predicate4Test::finished_; michael@0: int Predicate4Test::n1_; michael@0: int Predicate4Test::n2_; michael@0: int Predicate4Test::n3_; michael@0: int Predicate4Test::n4_; michael@0: michael@0: typedef Predicate4Test EXPECT_PRED_FORMAT4Test; michael@0: typedef Predicate4Test ASSERT_PRED_FORMAT4Test; michael@0: typedef Predicate4Test EXPECT_PRED4Test; michael@0: typedef Predicate4Test ASSERT_PRED4Test; michael@0: michael@0: // Tests a successful EXPECT_PRED4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED4(PredFunction4Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED4(PredFunction4Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED4(PredFunctor4(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED4(PredFunctor4(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED4(PredFunction4Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED4(PredFunction4Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED4(PredFunctor4(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED4(PredFunctor4(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED4(PredFunction4Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED4(PredFunction4Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED4(PredFunctor4(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED4(PredFunctor4(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED4(PredFunction4Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED4(PredFunction4Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED4(PredFunctor4(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED4(PredFunctor4(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT4(PredFormatFunction4, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT4(PredFormatFunction4, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT4(PredFormatFunction4, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT4(PredFormatFunction4, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT4(PredFormatFunction4, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT4(PredFormatFunction4, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT4(PredFormatFunction4, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT4(PredFormatFunction4, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT4 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT4(PredFormatFunctor4(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: // Sample functions/functors for testing 5-ary predicate assertions. michael@0: michael@0: // A 5-ary predicate function. michael@0: template michael@0: bool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) { michael@0: return v1 + v2 + v3 + v4 + v5 > 0; michael@0: } michael@0: michael@0: // The following two functions are needed to circumvent a bug in michael@0: // gcc 2.95.3, which sometimes has problem with the above template michael@0: // function. michael@0: bool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) { michael@0: return v1 + v2 + v3 + v4 + v5 > 0; michael@0: } michael@0: bool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) { michael@0: return v1 + v2 + v3 + v4 + v5 > 0; michael@0: } michael@0: michael@0: // A 5-ary predicate functor. michael@0: struct PredFunctor5 { michael@0: template michael@0: bool operator()(const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4, michael@0: const T5& v5) { michael@0: return v1 + v2 + v3 + v4 + v5 > 0; michael@0: } michael@0: }; michael@0: michael@0: // A 5-ary predicate-formatter function. michael@0: template michael@0: testing::AssertionResult PredFormatFunction5(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const char* e4, michael@0: const char* e5, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4, michael@0: const T5& v5) { michael@0: if (PredFunction5(v1, v2, v3, v4, v5)) michael@0: return testing::AssertionSuccess(); michael@0: michael@0: return testing::AssertionFailure() michael@0: << e1 << " + " << e2 << " + " << e3 << " + " << e4 << " + " << e5 michael@0: << " is expected to be positive, but evaluates to " michael@0: << v1 + v2 + v3 + v4 + v5 << "."; michael@0: } michael@0: michael@0: // A 5-ary predicate-formatter functor. michael@0: struct PredFormatFunctor5 { michael@0: template michael@0: testing::AssertionResult operator()(const char* e1, michael@0: const char* e2, michael@0: const char* e3, michael@0: const char* e4, michael@0: const char* e5, michael@0: const T1& v1, michael@0: const T2& v2, michael@0: const T3& v3, michael@0: const T4& v4, michael@0: const T5& v5) const { michael@0: return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5); michael@0: } michael@0: }; michael@0: michael@0: // Tests for {EXPECT|ASSERT}_PRED_FORMAT5. michael@0: michael@0: class Predicate5Test : public testing::Test { michael@0: protected: michael@0: virtual void SetUp() { michael@0: expected_to_finish_ = true; michael@0: finished_ = false; michael@0: n1_ = n2_ = n3_ = n4_ = n5_ = 0; michael@0: } michael@0: michael@0: virtual void TearDown() { michael@0: // Verifies that each of the predicate's arguments was evaluated michael@0: // exactly once. michael@0: EXPECT_EQ(1, n1_) << michael@0: "The predicate assertion didn't evaluate argument 2 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n2_) << michael@0: "The predicate assertion didn't evaluate argument 3 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n3_) << michael@0: "The predicate assertion didn't evaluate argument 4 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n4_) << michael@0: "The predicate assertion didn't evaluate argument 5 " michael@0: "exactly once."; michael@0: EXPECT_EQ(1, n5_) << michael@0: "The predicate assertion didn't evaluate argument 6 " michael@0: "exactly once."; michael@0: michael@0: // Verifies that the control flow in the test function is expected. michael@0: if (expected_to_finish_ && !finished_) { michael@0: FAIL() << "The predicate assertion unexpactedly aborted the test."; michael@0: } else if (!expected_to_finish_ && finished_) { michael@0: FAIL() << "The failed predicate assertion didn't abort the test " michael@0: "as expected."; michael@0: } michael@0: } michael@0: michael@0: // true iff the test function is expected to run to finish. michael@0: static bool expected_to_finish_; michael@0: michael@0: // true iff the test function did run to finish. michael@0: static bool finished_; michael@0: michael@0: static int n1_; michael@0: static int n2_; michael@0: static int n3_; michael@0: static int n4_; michael@0: static int n5_; michael@0: }; michael@0: michael@0: bool Predicate5Test::expected_to_finish_; michael@0: bool Predicate5Test::finished_; michael@0: int Predicate5Test::n1_; michael@0: int Predicate5Test::n2_; michael@0: int Predicate5Test::n3_; michael@0: int Predicate5Test::n4_; michael@0: int Predicate5Test::n5_; michael@0: michael@0: typedef Predicate5Test EXPECT_PRED_FORMAT5Test; michael@0: typedef Predicate5Test ASSERT_PRED_FORMAT5Test; michael@0: typedef Predicate5Test EXPECT_PRED5Test; michael@0: typedef Predicate5Test ASSERT_PRED5Test; michael@0: michael@0: // Tests a successful EXPECT_PRED5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED5(PredFunction5Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED5(PredFunction5Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED5(PredFunctor5(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED5(PredFunctor5(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED5(PredFunction5Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED5(PredFunction5Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED5(PredFunctor5(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED5(PredFunctor5(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED5(PredFunction5Int, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED5(PredFunction5Bool, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED5(PredFunctor5(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED5(PredFunctor5(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED5(PredFunction5Int, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED5(PredFunction5Bool, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED5(PredFunctor5(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED5(PredFunctor5(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT5(PredFormatFunction5, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT5(PredFormatFunction5, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) { michael@0: EXPECT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) { michael@0: EXPECT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT5(PredFormatFunction5, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT5(PredFormatFunction5, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed EXPECT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) { michael@0: EXPECT_NONFATAL_FAILURE({ // NOLINT michael@0: EXPECT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT5(PredFormatFunction5, michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT5(PredFormatFunction5, michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) { michael@0: ASSERT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: ++n1_, michael@0: ++n2_, michael@0: ++n3_, michael@0: ++n4_, michael@0: ++n5_); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a successful ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) { michael@0: ASSERT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: Bool(++n1_), michael@0: Bool(++n2_), michael@0: Bool(++n3_), michael@0: Bool(++n4_), michael@0: Bool(++n5_)); michael@0: finished_ = true; michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT5(PredFormatFunction5, michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a function on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT5(PredFormatFunction5, michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a built-in type (int). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: n1_++, michael@0: n2_++, michael@0: n3_++, michael@0: n4_++, michael@0: n5_++); michael@0: finished_ = true; michael@0: }, ""); michael@0: } michael@0: michael@0: // Tests a failed ASSERT_PRED_FORMAT5 where the michael@0: // predicate-formatter is a functor on a user-defined type (Bool). michael@0: TEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) { michael@0: expected_to_finish_ = false; michael@0: EXPECT_FATAL_FAILURE({ // NOLINT michael@0: ASSERT_PRED_FORMAT5(PredFormatFunctor5(), michael@0: Bool(n1_++), michael@0: Bool(n2_++), michael@0: Bool(n3_++), michael@0: Bool(n4_++), michael@0: Bool(n5_++)); michael@0: finished_ = true; michael@0: }, ""); michael@0: }