"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googletest/include/gtest/gtest.h" between
googletest-release-1.10.0.tar.gz and googletest-release-1.11.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

gtest.h  (googletest-release-1.10.0):gtest.h  (googletest-release-1.11.0)
skipping to change at line 52 skipping to change at line 52
// Such code is NOT meant to be used by a user directly, and is subject // Such code is NOT meant to be used by a user directly, and is subject
// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user // to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
// program! // program!
// //
// Acknowledgment: Google Test borrowed the idea of automatic test // Acknowledgment: Google Test borrowed the idea of automatic test
// registration from Barthelemy Dagenais' (barthelemy@prologique.com) // registration from Barthelemy Dagenais' (barthelemy@prologique.com)
// easyUnit framework. // easyUnit framework.
// GOOGLETEST_CM0001 DO NOT DELETE // GOOGLETEST_CM0001 DO NOT DELETE
#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
#define GTEST_INCLUDE_GTEST_GTEST_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
#include <cstddef> #include <cstddef>
#include <limits> #include <limits>
#include <memory> #include <memory>
#include <ostream> #include <ostream>
#include <type_traits> #include <type_traits>
#include <vector> #include <vector>
#include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-string.h" #include "gtest/internal/gtest-string.h"
skipping to change at line 103 skipping to change at line 103
// This flag controls whether Google Test catches all test-thrown exceptions // This flag controls whether Google Test catches all test-thrown exceptions
// and logs them as failures. // and logs them as failures.
GTEST_DECLARE_bool_(catch_exceptions); GTEST_DECLARE_bool_(catch_exceptions);
// This flag enables using colors in terminal output. Available values are // This flag enables using colors in terminal output. Available values are
// "yes" to enable colors, "no" (disable colors), or "auto" (the default) // "yes" to enable colors, "no" (disable colors), or "auto" (the default)
// to let Google Test decide. // to let Google Test decide.
GTEST_DECLARE_string_(color); GTEST_DECLARE_string_(color);
// This flag controls whether the test runner should continue execution past
// first failure.
GTEST_DECLARE_bool_(fail_fast);
// This flag sets up the filter to select by name using a glob pattern // This flag sets up the filter to select by name using a glob pattern
// the tests to run. If the filter is not given all tests are executed. // the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_(filter); GTEST_DECLARE_string_(filter);
// This flag controls whether Google Test installs a signal handler that dumps // This flag controls whether Google Test installs a signal handler that dumps
// debugging information when fatal signals are raised. // debugging information when fatal signals are raised.
GTEST_DECLARE_bool_(install_failure_signal_handler); GTEST_DECLARE_bool_(install_failure_signal_handler);
// This flag causes the Google Test to list tests. None of the tests listed // This flag causes the Google Test to list tests. None of the tests listed
// are actually run if the flag is provided. // are actually run if the flag is provided.
GTEST_DECLARE_bool_(list_tests); GTEST_DECLARE_bool_(list_tests);
// This flag controls whether Google Test emits a detailed XML report to a file // This flag controls whether Google Test emits a detailed XML report to a file
// in addition to its normal textual output. // in addition to its normal textual output.
GTEST_DECLARE_string_(output); GTEST_DECLARE_string_(output);
// This flags control whether Google Test prints only test failures.
GTEST_DECLARE_bool_(brief);
// This flags control whether Google Test prints the elapsed time for each // This flags control whether Google Test prints the elapsed time for each
// test. // test.
GTEST_DECLARE_bool_(print_time); GTEST_DECLARE_bool_(print_time);
// This flags control whether Google Test prints UTF8 characters as text. // This flags control whether Google Test prints UTF8 characters as text.
GTEST_DECLARE_bool_(print_utf8); GTEST_DECLARE_bool_(print_utf8);
// This flag specifies the random number seed. // This flag specifies the random number seed.
GTEST_DECLARE_int32_(random_seed); GTEST_DECLARE_int32_(random_seed);
skipping to change at line 179 skipping to change at line 186
class StreamingListenerTest; class StreamingListenerTest;
class TestResultAccessor; class TestResultAccessor;
class TestEventListenersAccessor; class TestEventListenersAccessor;
class TestEventRepeater; class TestEventRepeater;
class UnitTestRecordPropertyTestHelper; class UnitTestRecordPropertyTestHelper;
class WindowsDeathTest; class WindowsDeathTest;
class FuchsiaDeathTest; class FuchsiaDeathTest;
class UnitTestImpl* GetUnitTestImpl(); class UnitTestImpl* GetUnitTestImpl();
void ReportFailureInUnknownLocation(TestPartResult::Type result_type, void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const std::string& message); const std::string& message);
std::set<std::string>* GetIgnoredParameterizedTestSuites();
} // namespace internal } // namespace internal
// The friend relationship of some of these classes is cyclic. // The friend relationship of some of these classes is cyclic.
// If we don't forward declare them the compiler might confuse the classes // If we don't forward declare them the compiler might confuse the classes
// in friendship clauses with same named classes on the scope. // in friendship clauses with same named classes on the scope.
class Test; class Test;
class TestSuite; class TestSuite;
// Old API is still available but deprecated // Old API is still available but deprecated
skipping to change at line 280 skipping to change at line 288
// //
// Expected: Foo() is even // Expected: Foo() is even
// Actual: it's 5 // Actual: it's 5
// //
class GTEST_API_ AssertionResult { class GTEST_API_ AssertionResult {
public: public:
// Copy constructor. // Copy constructor.
// Used in EXPECT_TRUE/FALSE(assertion_result). // Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult(const AssertionResult& other); AssertionResult(const AssertionResult& other);
#if defined(_MSC_VER) && _MSC_VER < 1910 // C4800 is a level 3 warning in Visual Studio 2015 and earlier.
// This warning is not emitted in Visual Studio 2017.
// This warning is off by default starting in Visual Studio 2019 but can be
// enabled with command-line options.
#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */) GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 /* forcing value to bool */)
#endif #endif
// Used in the EXPECT_TRUE/FALSE(bool_expression). // Used in the EXPECT_TRUE/FALSE(bool_expression).
// //
// T must be contextually convertible to bool. // T must be contextually convertible to bool.
// //
// The second parameter prevents this overload from being considered if // The second parameter prevents this overload from being considered if
// the argument is implicitly convertible to AssertionResult. In that case // the argument is implicitly convertible to AssertionResult. In that case
// we want AssertionResult's copy constructor to be used. // we want AssertionResult's copy constructor to be used.
template <typename T> template <typename T>
explicit AssertionResult( explicit AssertionResult(
const T& success, const T& success,
typename std::enable_if< typename std::enable_if<
!std::is_convertible<T, AssertionResult>::value>::type* !std::is_convertible<T, AssertionResult>::value>::type*
/*enabler*/ /*enabler*/
= nullptr) = nullptr)
: success_(success) {} : success_(success) {}
#if defined(_MSC_VER) && _MSC_VER < 1910 #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
GTEST_DISABLE_MSC_WARNINGS_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
#endif #endif
// Assignment operator. // Assignment operator.
AssertionResult& operator=(AssertionResult other) { AssertionResult& operator=(AssertionResult other) {
swap(other); swap(other);
return *this; return *this;
} }
// Returns true if and only if the assertion succeeded. // Returns true if and only if the assertion succeeded.
skipping to change at line 408 skipping to change at line 420
// TEST_F(FooTest, Baz) { ... } // TEST_F(FooTest, Baz) { ... }
// //
// Test is not copyable. // Test is not copyable.
class GTEST_API_ Test { class GTEST_API_ Test {
public: public:
friend class TestInfo; friend class TestInfo;
// The d'tor is virtual as we intend to inherit from Test. // The d'tor is virtual as we intend to inherit from Test.
virtual ~Test(); virtual ~Test();
// Sets up the stuff shared by all tests in this test case. // Sets up the stuff shared by all tests in this test suite.
// //
// Google Test will call Foo::SetUpTestSuite() before running the first // Google Test will call Foo::SetUpTestSuite() before running the first
// test in test case Foo. Hence a sub-class can define its own // test in test suite Foo. Hence a sub-class can define its own
// SetUpTestSuite() method to shadow the one defined in the super // SetUpTestSuite() method to shadow the one defined in the super
// class. // class.
// Failures that happen during SetUpTestSuite are logged but otherwise
// ignored.
static void SetUpTestSuite() {} static void SetUpTestSuite() {}
// Tears down the stuff shared by all tests in this test suite. // Tears down the stuff shared by all tests in this test suite.
// //
// Google Test will call Foo::TearDownTestSuite() after running the last // Google Test will call Foo::TearDownTestSuite() after running the last
// test in test case Foo. Hence a sub-class can define its own // test in test suite Foo. Hence a sub-class can define its own
// TearDownTestSuite() method to shadow the one defined in the super // TearDownTestSuite() method to shadow the one defined in the super
// class. // class.
// Failures that happen during TearDownTestSuite are logged but otherwise
// ignored.
static void TearDownTestSuite() {} static void TearDownTestSuite() {}
// Legacy API is deprecated but still available // Legacy API is deprecated but still available. Use SetUpTestSuite and
// TearDownTestSuite instead.
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
static void TearDownTestCase() {} static void TearDownTestCase() {}
static void SetUpTestCase() {} static void SetUpTestCase() {}
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Returns true if and only if the current test has a fatal failure. // Returns true if and only if the current test has a fatal failure.
static bool HasFatalFailure(); static bool HasFatalFailure();
// Returns true if and only if the current test has a non-fatal failure. // Returns true if and only if the current test has a non-fatal failure.
static bool HasNonfatalFailure(); static bool HasNonfatalFailure();
skipping to change at line 666 skipping to change at line 675
int increment_death_test_count() { return ++death_test_count_; } int increment_death_test_count() { return ++death_test_count_; }
// Clears the test part results. // Clears the test part results.
void ClearTestPartResults(); void ClearTestPartResults();
// Clears the object. // Clears the object.
void Clear(); void Clear();
// Protects mutable state of the property vector and of owned // Protects mutable state of the property vector and of owned
// properties, whose values may be updated. // properties, whose values may be updated.
internal::Mutex test_properites_mutex_; internal::Mutex test_properties_mutex_;
// The vector of TestPartResults // The vector of TestPartResults
std::vector<TestPartResult> test_part_results_; std::vector<TestPartResult> test_part_results_;
// The vector of TestProperties // The vector of TestProperties
std::vector<TestProperty> test_properties_; std::vector<TestProperty> test_properties_;
// Running count of death tests. // Running count of death tests.
int death_test_count_; int death_test_count_;
// The start time, in milliseconds since UNIX Epoch. // The start time, in milliseconds since UNIX Epoch.
TimeInMillis start_timestamp_; TimeInMillis start_timestamp_;
// The elapsed time, in milliseconds. // The elapsed time, in milliseconds.
skipping to change at line 796 skipping to change at line 805
// Increments the number of death tests encountered in this test so // Increments the number of death tests encountered in this test so
// far. // far.
int increment_death_test_count() { int increment_death_test_count() {
return result_.increment_death_test_count(); return result_.increment_death_test_count();
} }
// Creates the test object, runs it, records its result, and then // Creates the test object, runs it, records its result, and then
// deletes it. // deletes it.
void Run(); void Run();
// Skip and records the test result for this object.
void Skip();
static void ClearTestResult(TestInfo* test_info) { static void ClearTestResult(TestInfo* test_info) {
test_info->result_.Clear(); test_info->result_.Clear();
} }
// These fields are immutable properties of the test. // These fields are immutable properties of the test.
const std::string test_suite_name_; // test suite name const std::string test_suite_name_; // test suite name
const std::string name_; // Test name const std::string name_; // Test name
// Name of the parameter type, or NULL if this is not a typed or a // Name of the parameter type, or NULL if this is not a typed or a
// type-parameterized test. // type-parameterized test.
const std::unique_ptr<const ::std::string> type_param_; const std::unique_ptr<const ::std::string> type_param_;
skipping to change at line 891 skipping to change at line 903
// Get the number of tests in this test suite that should run. // Get the number of tests in this test suite that should run.
int test_to_run_count() const; int test_to_run_count() const;
// Gets the number of all tests in this test suite. // Gets the number of all tests in this test suite.
int total_test_count() const; int total_test_count() const;
// Returns true if and only if the test suite passed. // Returns true if and only if the test suite passed.
bool Passed() const { return !Failed(); } bool Passed() const { return !Failed(); }
// Returns true if and only if the test suite failed. // Returns true if and only if the test suite failed.
bool Failed() const { return failed_test_count() > 0; } bool Failed() const {
return failed_test_count() > 0 || ad_hoc_test_result().Failed();
}
// Returns the elapsed time, in milliseconds. // Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; } TimeInMillis elapsed_time() const { return elapsed_time_; }
// Gets the time of the test suite start, in ms from the start of the // Gets the time of the test suite start, in ms from the start of the
// UNIX epoch. // UNIX epoch.
TimeInMillis start_timestamp() const { return start_timestamp_; } TimeInMillis start_timestamp() const { return start_timestamp_; }
// Returns the i-th test among all the tests. i can range from 0 to // Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL. // total_test_count() - 1. If i is not in that range, returns NULL.
skipping to change at line 942 skipping to change at line 956
void ClearResult(); void ClearResult();
// Clears the results of all tests in the given test suite. // Clears the results of all tests in the given test suite.
static void ClearTestSuiteResult(TestSuite* test_suite) { static void ClearTestSuiteResult(TestSuite* test_suite) {
test_suite->ClearResult(); test_suite->ClearResult();
} }
// Runs every test in this TestSuite. // Runs every test in this TestSuite.
void Run(); void Run();
// Skips the execution of tests under this TestSuite
void Skip();
// Runs SetUpTestSuite() for this TestSuite. This wrapper is needed // Runs SetUpTestSuite() for this TestSuite. This wrapper is needed
// for catching exceptions thrown from SetUpTestSuite(). // for catching exceptions thrown from SetUpTestSuite().
void RunSetUpTestSuite() { void RunSetUpTestSuite() {
if (set_up_tc_ != nullptr) { if (set_up_tc_ != nullptr) {
(*set_up_tc_)(); (*set_up_tc_)();
} }
} }
// Runs TearDownTestSuite() for this TestSuite. This wrapper is // Runs TearDownTestSuite() for this TestSuite. This wrapper is
// needed for catching exceptions thrown from TearDownTestSuite(). // needed for catching exceptions thrown from TearDownTestSuite().
skipping to change at line 1422 skipping to change at line 1439
const internal::UnitTestImpl* impl() const { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; }
// These classes and functions are friends as they need to access private // These classes and functions are friends as they need to access private
// members of UnitTest. // members of UnitTest.
friend class ScopedTrace; friend class ScopedTrace;
friend class Test; friend class Test;
friend class internal::AssertHelper; friend class internal::AssertHelper;
friend class internal::StreamingListenerTest; friend class internal::StreamingListenerTest;
friend class internal::UnitTestRecordPropertyTestHelper; friend class internal::UnitTestRecordPropertyTestHelper;
friend Environment* AddGlobalTestEnvironment(Environment* env); friend Environment* AddGlobalTestEnvironment(Environment* env);
friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();
friend internal::UnitTestImpl* internal::GetUnitTestImpl(); friend internal::UnitTestImpl* internal::GetUnitTestImpl();
friend void internal::ReportFailureInUnknownLocation( friend void internal::ReportFailureInUnknownLocation(
TestPartResult::Type result_type, TestPartResult::Type result_type,
const std::string& message); const std::string& message);
// Creates an empty UnitTest. // Creates an empty UnitTest.
UnitTest(); UnitTest();
// D'tor // D'tor
virtual ~UnitTest(); virtual ~UnitTest();
skipping to change at line 1533 skipping to change at line 1551
const char* rhs_expression, const char* rhs_expression,
const T1& lhs, const T1& lhs,
const T2& rhs) { const T2& rhs) {
if (lhs == rhs) { if (lhs == rhs) {
return AssertionSuccess(); return AssertionSuccess();
} }
return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs); return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
} }
// With this overloaded version, we allow anonymous enums to be used
// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums
// can be implicitly cast to BiggestInt.
GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
const char* rhs_expression,
BiggestInt lhs,
BiggestInt rhs);
class EqHelper { class EqHelper {
public: public:
// This templatized version is for the general case. // This templatized version is for the general case.
template < template <
typename T1, typename T2, typename T1, typename T2,
// Disable this overload for cases where one argument is a pointer // Disable this overload for cases where one argument is a pointer
// and the other is the null pointer constant. // and the other is the null pointer constant.
typename std::enable_if<!std::is_integral<T1>::value || typename std::enable_if<!std::is_integral<T1>::value ||
!std::is_pointer<T2>::value>::type* = nullptr> !std::is_pointer<T2>::value>::type* = nullptr>
static AssertionResult Compare(const char* lhs_expression, static AssertionResult Compare(const char* lhs_expression,
skipping to change at line 1597 skipping to change at line 1607
return AssertionFailure() return AssertionFailure()
<< "Expected: (" << expr1 << ") " << op << " (" << expr2 << "Expected: (" << expr1 << ") " << op << " (" << expr2
<< "), actual: " << FormatForComparisonFailureMessage(val1, val2) << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
<< " vs " << FormatForComparisonFailureMessage(val2, val1); << " vs " << FormatForComparisonFailureMessage(val2, val1);
} }
// A macro for implementing the helper functions needed to implement // A macro for implementing the helper functions needed to implement
// ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste
// of similar code. // of similar code.
// //
// For each templatized helper function, we also define an overloaded
// version for BiggestInt in order to reduce code bloat and allow
// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
// with gcc 4.
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
template <typename T1, typename T2>\ template <typename T1, typename T2>\
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
const T1& val1, const T2& val2) {\ const T1& val1, const T2& val2) {\
if (val1 op val2) {\ if (val1 op val2) {\
return AssertionSuccess();\ return AssertionSuccess();\
} else {\ } else {\
return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\ return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
}\ }\
}\ }
GTEST_API_ AssertionResult CmpHelper##op_name(\
const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
// Implements the helper function for {ASSERT|EXPECT}_NE // Implements the helper function for {ASSERT|EXPECT}_NE
GTEST_IMPL_CMP_HELPER_(NE, !=); GTEST_IMPL_CMP_HELPER_(NE, !=)
// Implements the helper function for {ASSERT|EXPECT}_LE // Implements the helper function for {ASSERT|EXPECT}_LE
GTEST_IMPL_CMP_HELPER_(LE, <=); GTEST_IMPL_CMP_HELPER_(LE, <=)
// Implements the helper function for {ASSERT|EXPECT}_LT // Implements the helper function for {ASSERT|EXPECT}_LT
GTEST_IMPL_CMP_HELPER_(LT, <); GTEST_IMPL_CMP_HELPER_(LT, <)
// Implements the helper function for {ASSERT|EXPECT}_GE // Implements the helper function for {ASSERT|EXPECT}_GE
GTEST_IMPL_CMP_HELPER_(GE, >=); GTEST_IMPL_CMP_HELPER_(GE, >=)
// Implements the helper function for {ASSERT|EXPECT}_GT // Implements the helper function for {ASSERT|EXPECT}_GT
GTEST_IMPL_CMP_HELPER_(GT, >); GTEST_IMPL_CMP_HELPER_(GT, >)
#undef GTEST_IMPL_CMP_HELPER_ #undef GTEST_IMPL_CMP_HELPER_
// The helper function for {ASSERT|EXPECT}_STREQ. // The helper function for {ASSERT|EXPECT}_STREQ.
// //
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression, GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
const char* s2_expression, const char* s2_expression,
const char* s1, const char* s1,
const char* s2); const char* s2);
skipping to change at line 1804 skipping to change at line 1807
private: private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData); GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
}; };
AssertHelperData* const data_; AssertHelperData* const data_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
}; };
enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW };
GTEST_API_ GTEST_ATTRIBUTE_PRINTF_(2, 3) void ColoredPrintf(GTestColor color,
const char* fmt,
...);
} // namespace internal } // namespace internal
// The pure interface class that all value-parameterized tests inherit from. // The pure interface class that all value-parameterized tests inherit from.
// A value-parameterized class must inherit from both ::testing::Test and // A value-parameterized class must inherit from both ::testing::Test and
// ::testing::WithParamInterface. In most cases that just means inheriting // ::testing::WithParamInterface. In most cases that just means inheriting
// from ::testing::TestWithParam, but more complicated test hierarchies // from ::testing::TestWithParam, but more complicated test hierarchies
// may need to inherit from Test and WithParamInterface at different levels. // may need to inherit from Test and WithParamInterface at different levels.
// //
// This interface has support for accessing the test parameter value via // This interface has support for accessing the test parameter value via
// the GetParam() method. // the GetParam() method.
skipping to change at line 1890 skipping to change at line 1887
template <typename T> template <typename T>
class TestWithParam : public Test, public WithParamInterface<T> { class TestWithParam : public Test, public WithParamInterface<T> {
}; };
// Macros for indicating success/failure in test code. // Macros for indicating success/failure in test code.
// Skips test in runtime. // Skips test in runtime.
// Skipping test aborts current function. // Skipping test aborts current function.
// Skipped tests are neither successful nor failed. // Skipped tests are neither successful nor failed.
#define GTEST_SKIP() GTEST_SKIP_("Skipped") #define GTEST_SKIP() GTEST_SKIP_("")
// ADD_FAILURE unconditionally adds a failure to the current test. // ADD_FAILURE unconditionally adds a failure to the current test.
// SUCCEED generates a success - it doesn't automatically make the // SUCCEED generates a success - it doesn't automatically make the
// current test successful, as a test is only successful when it has // current test successful, as a test is only successful when it has
// no failure. // no failure.
// //
// EXPECT_* verifies that a certain condition is satisfied. If not, // EXPECT_* verifies that a certain condition is satisfied. If not,
// it behaves like ADD_FAILURE. In particular: // it behaves like ADD_FAILURE. In particular:
// //
// EXPECT_TRUE verifies that a Boolean condition is true. // EXPECT_TRUE verifies that a Boolean condition is true.
skipping to change at line 1966 skipping to change at line 1963
#define ASSERT_THROW(statement, expected_exception) \ #define ASSERT_THROW(statement, expected_exception) \
GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
#define ASSERT_NO_THROW(statement) \ #define ASSERT_NO_THROW(statement) \
GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
#define ASSERT_ANY_THROW(statement) \ #define ASSERT_ANY_THROW(statement) \
GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
// Boolean assertions. Condition can be either a Boolean expression or an // Boolean assertions. Condition can be either a Boolean expression or an
// AssertionResult. For more information on how to use AssertionResult with // AssertionResult. For more information on how to use AssertionResult with
// these macros see comments on that class. // these macros see comments on that class.
#define EXPECT_TRUE(condition) \ #define GTEST_EXPECT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
GTEST_NONFATAL_FAILURE_) GTEST_NONFATAL_FAILURE_)
#define EXPECT_FALSE(condition) \ #define GTEST_EXPECT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
GTEST_NONFATAL_FAILURE_) GTEST_NONFATAL_FAILURE_)
#define ASSERT_TRUE(condition) \ #define GTEST_ASSERT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
GTEST_FATAL_FAILURE_) GTEST_FATAL_FAILURE_)
#define ASSERT_FALSE(condition) \ #define GTEST_ASSERT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
GTEST_FATAL_FAILURE_) GTEST_FATAL_FAILURE_)
// Define these macros to 1 to omit the definition of the corresponding
// EXPECT or ASSERT, which clashes with some users' own code.
#if !GTEST_DONT_DEFINE_EXPECT_TRUE
#define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
#endif
#if !GTEST_DONT_DEFINE_EXPECT_FALSE
#define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
#endif
#if !GTEST_DONT_DEFINE_ASSERT_TRUE
#define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
#endif
#if !GTEST_DONT_DEFINE_ASSERT_FALSE
#define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)
#endif
// Macros for testing equalities and inequalities. // Macros for testing equalities and inequalities.
// //
// * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2 // * {ASSERT|EXPECT}_EQ(v1, v2): Tests that v1 == v2
// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 // * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2
// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 // * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2
// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 // * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2
// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 // * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2
// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 // * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2
// //
// When they are not, Google Test prints both the tested expressions and // When they are not, Google Test prints both the tested expressions and
skipping to change at line 2298 skipping to change at line 2314
// void Test1() { Foo<bool> foo; } // void Test1() { Foo<bool> foo; }
// //
// will NOT generate a compiler error, as Foo<bool>::Bar() is never // will NOT generate a compiler error, as Foo<bool>::Bar() is never
// actually instantiated. Instead, you need: // actually instantiated. Instead, you need:
// //
// void Test2() { Foo<bool> foo; foo.Bar(); } // void Test2() { Foo<bool> foo; foo.Bar(); }
// //
// to cause a compiler error. // to cause a compiler error.
template <typename T1, typename T2> template <typename T1, typename T2>
constexpr bool StaticAssertTypeEq() noexcept { constexpr bool StaticAssertTypeEq() noexcept {
static_assert(std::is_same<T1, T2>::value, static_assert(std::is_same<T1, T2>::value, "T1 and T2 are not the same type");
"type1 and type2 are not the same type");
return true; return true;
} }
// Defines a test. // Defines a test.
// //
// The first parameter is the name of the test suite, and the second // The first parameter is the name of the test suite, and the second
// parameter is the name of the test within the test suite. // parameter is the name of the test within the test suite.
// //
// The convention is to end the test suite name with "Test". For // The convention is to end the test suite name with "Test". For
// example, a test suite for the Foo class can be named FooTest. // example, a test suite for the Foo class can be named FooTest.
skipping to change at line 2365 skipping to change at line 2380
// TEST_F(FooTest, InitializesCorrectly) { // TEST_F(FooTest, InitializesCorrectly) {
// EXPECT_TRUE(a_.StatusIsOK()); // EXPECT_TRUE(a_.StatusIsOK());
// } // }
// //
// TEST_F(FooTest, ReturnsElementCountCorrectly) { // TEST_F(FooTest, ReturnsElementCountCorrectly) {
// EXPECT_EQ(a_.size(), 0); // EXPECT_EQ(a_.size(), 0);
// EXPECT_EQ(b_.size(), 1); // EXPECT_EQ(b_.size(), 1);
// } // }
// //
// GOOGLETEST_CM0011 DO NOT DELETE // GOOGLETEST_CM0011 DO NOT DELETE
#if !GTEST_DONT_DEFINE_TEST
#define TEST_F(test_fixture, test_name)\ #define TEST_F(test_fixture, test_name)\
GTEST_TEST_(test_fixture, test_name, test_fixture, \ GTEST_TEST_(test_fixture, test_name, test_fixture, \
::testing::internal::GetTypeId<test_fixture>()) ::testing::internal::GetTypeId<test_fixture>())
#endif // !GTEST_DONT_DEFINE_TEST
// Returns a path to temporary directory. // Returns a path to temporary directory.
// Tries to determine an appropriate directory for the platform. // Tries to determine an appropriate directory for the platform.
GTEST_API_ std::string TempDir(); GTEST_API_ std::string TempDir();
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) # pragma warning(pop)
#endif #endif
// Dynamically registers a test with the framework. // Dynamically registers a test with the framework.
skipping to change at line 2475 skipping to change at line 2492
// This function was formerly a macro; thus, it is in the global // This function was formerly a macro; thus, it is in the global
// namespace and has an all-caps name. // namespace and has an all-caps name.
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_; int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
inline int RUN_ALL_TESTS() { inline int RUN_ALL_TESTS() {
return ::testing::UnitTest::GetInstance()->Run(); return ::testing::UnitTest::GetInstance()->Run();
} }
GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251
#endif // GTEST_INCLUDE_GTEST_GTEST_H_ #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_H_
 End of changes. 36 change blocks. 
48 lines changed or deleted 65 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)