// Copyright 2005, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// The Google C++ Testing and Mocking Framework (Google Test) // // This header file defines the public API for Google Test. It should be // included by any test program that uses Google Test. // // IMPORTANT NOTE: Due to limitation of the C++ language, we have to // leave some internal implementation details in this header file. // They are clearly marked by comments like this: // // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. // // 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 // program! // // Acknowledgment: Google Test borrowed the idea of automatic test // registration from Barthelemy Dagenais' (barthelemy@prologique.com) // easyUnit framework.
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */)
// Declares the flags.
// This flag temporary enables the disabled tests.
GTEST_DECLARE_bool_(also_run_disabled_tests);
// This flag brings the debugger on an assertion failure.
GTEST_DECLARE_bool_(break_on_failure);
// This flag controls whether Google Test catches all test-thrown exceptions // and logs them as failures.
GTEST_DECLARE_bool_(catch_exceptions);
// This flag enables using colors in terminal output. Available values are // "yes" to enable colors, "no" (disable colors), or "auto" (the default) // to let Google Test decide.
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 // the tests to run. If the filter is not given all tests are executed.
GTEST_DECLARE_string_(filter);
// This flag controls whether Google Test installs a signal handler that dumps // debugging information when fatal signals are raised.
GTEST_DECLARE_bool_(install_failure_signal_handler);
// This flag causes the Google Test to list tests. None of the tests listed // are actually run if the flag is provided.
GTEST_DECLARE_bool_(list_tests);
// This flag controls whether Google Test emits a detailed XML report to a file // in addition to its normal textual 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 // test.
GTEST_DECLARE_bool_(print_time);
// This flags control whether Google Test prints UTF8 characters as text.
GTEST_DECLARE_bool_(print_utf8);
// This flag specifies the random number seed.
GTEST_DECLARE_int32_(random_seed);
// This flag sets how many times the tests are repeated. The default value // is 1. If the value is -1 the tests are repeating forever.
GTEST_DECLARE_int32_(repeat);
// This flag controls whether Google Test Environments are recreated for each // repeat of the tests. The default value is true. If set to false the global // test Environment objects are only set up once, for the first iteration, and // only torn down once, for the last.
GTEST_DECLARE_bool_(recreate_environments_when_repeating);
// This flag controls whether Google Test includes Google Test internal // stack frames in failure stack traces.
GTEST_DECLARE_bool_(show_internal_stack_frames);
// When this flag is specified, tests' order is randomized on every iteration.
GTEST_DECLARE_bool_(shuffle);
// This flag specifies the maximum number of stack frames to be // printed in a failure message.
GTEST_DECLARE_int32_(stack_trace_depth);
// When this flag is specified, a failed assertion will throw an // exception if exceptions are enabled, or exit the program with a // non-zero code otherwise. For use with an external test framework.
GTEST_DECLARE_bool_(throw_on_failure);
// When this flag is set with a "host:port" string, on supported // platforms test results are streamed to the specified port on // the specified host machine.
GTEST_DECLARE_string_(stream_result_to);
// Silence C4100 (unreferenced formal parameter) and 4805 // unsafe mix of type 'const int' and type 'const bool'
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4805 4100)
// The upper limit for valid stack trace depths. constint kMaxStackTraceDepth = 100;
namespace internal {
class AssertHelper; class DefaultGlobalTestPartResultReporter; class ExecDeathTest; class NoExecDeathTest; class FinalSuccessChecker; class GTestFlagSaver; class StreamingListenerTest; class TestResultAccessor; class TestEventListenersAccessor; class TestEventRepeater; class UnitTestRecordPropertyTestHelper; class WindowsDeathTest; class FuchsiaDeathTest; class UnitTestImpl* GetUnitTestImpl(); void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message);
std::set<std::string>* GetIgnoredParameterizedTestSuites();
// A base class that prevents subclasses from being copyable. // We do this instead of using '= delete' so as to avoid triggering warnings // inside user code regarding any of our declarations. class GTestNonCopyable { public:
GTestNonCopyable() = default;
GTestNonCopyable(const GTestNonCopyable&) = delete;
GTestNonCopyable& operator=(const GTestNonCopyable&) = delete;
~GTestNonCopyable() = default;
};
} // namespace internal
// The friend relationship of some of these classes is cyclic. // If we don't forward declare them the compiler might confuse the classes // in friendship clauses with same named classes on the scope. class Test; class TestSuite;
// Old API is still available but deprecated #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ using TestCase = TestSuite; #endif class TestInfo; class UnitTest;
// The abstract class that all tests inherit from. // // In Google Test, a unit test program contains one or many TestSuites, and // each TestSuite contains one or many Tests. // // When you define a test using the TEST macro, you don't need to // explicitly derive from Test - the TEST macro automatically does // this for you. // // The only time you derive from Test is when defining a test fixture // to be used in a TEST_F. For example: // // class FooTest : public testing::Test { // protected: // void SetUp() override { ... } // void TearDown() override { ... } // ... // }; // // TEST_F(FooTest, Bar) { ... } // TEST_F(FooTest, Baz) { ... } // // Test is not copyable. class GTEST_API_ Test { public: friendclass TestInfo;
// The d'tor is virtual as we intend to inherit from Test. virtual ~Test();
// Sets up the stuff shared by all tests in this test suite. // // Google Test will call Foo::SetUpTestSuite() before running the first // test in test suite Foo. Hence a sub-class can define its own // SetUpTestSuite() method to shadow the one defined in the super // class. staticvoid SetUpTestSuite() {}
// Tears down the stuff shared by all tests in this test suite. // // Google Test will call Foo::TearDownTestSuite() after running the last // test in test suite Foo. Hence a sub-class can define its own // TearDownTestSuite() method to shadow the one defined in the super // class. staticvoid TearDownTestSuite() {}
// Legacy API is deprecated but still available. Use SetUpTestSuite and // TearDownTestSuite instead. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ staticvoid TearDownTestCase() {} staticvoid SetUpTestCase() {} #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Returns true if and only if the current test has a fatal failure. staticbool HasFatalFailure();
// Returns true if and only if the current test has a non-fatal failure. staticbool HasNonfatalFailure();
// Returns true if and only if the current test was skipped. staticbool IsSkipped();
// Returns true if and only if the current test has a (either fatal or // non-fatal) failure. staticbool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
// Logs a property for the current test, test suite, or for the entire // invocation of the test program when used outside of the context of a // test suite. Only the last value for a given key is remembered. These // are public static so they can be called from utility functions that are // not members of the test fixture. Calls to RecordProperty made during // lifespan of the test (from the moment its constructor starts to the // moment its destructor finishes) will be output in XML as attributes of // the <testcase> element. Properties recorded from fixture's // SetUpTestSuite or TearDownTestSuite are logged as attributes of the // corresponding <testsuite> element. Calls to RecordProperty made in the // global context (before or after invocation of RUN_ALL_TESTS and from // SetUp/TearDown method of Environment objects registered with Google // Test) will be output as attributes of the <testsuites> element. staticvoid RecordProperty(const std::string& key, const std::string& value); // We do not define a custom serialization except for values that can be // converted to int64_t, but other values could be logged in this way. template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value, bool> = true> staticvoid RecordProperty(const std::string& key, const T& value) {
RecordProperty(key, (Message() << value).GetString());
}
protected: // Creates a Test object.
Test();
// Sets up the test fixture. virtualvoid SetUp();
// Tears down the test fixture. virtualvoid TearDown();
private: // Returns true if and only if the current test has the same fixture class // as the first test in the current test suite. staticbool HasSameFixtureClass();
// Runs the test after the test fixture has been set up. // // A sub-class must implement this to define the test logic. // // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM. // Instead, use the TEST or TEST_F macro.
MOZ_CAN_RUN_SCRIPT virtualvoid TestBody() = 0;
// Sets up, executes, and tears down the test. void Run();
// Deletes self. We deliberately pick an unusual name for this // internal method to avoid clashing with names used in user TESTs. void DeleteSelf_() { deletethis; }
// Often a user misspells SetUp() as Setup() and spends a long time // wondering why it is never called by Google Test. The declaration of // the following method is solely for catching such an error at // compile time: // // - The return type is deliberately chosen to be not void, so it // will be a conflict if void Setup() is declared in the user's // test fixture. // // - This method is private, so it will be another compiler error // if the method is called from the user's test fixture. // // DO NOT OVERRIDE THIS FUNCTION. // // If you see an error about overriding the following function or // about it being private, you have mis-spelled SetUp() as Setup(). struct Setup_should_be_spelled_SetUp {}; virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
// A copyable object representing a user specified test property which can be // output as a key/value string pair. // // Don't inherit from TestProperty as its destructor is not virtual. class TestProperty { public: // C'tor. TestProperty does NOT have a default constructor. // Always use this constructor (with parameters) to create a // TestProperty object.
TestProperty(const std::string& a_key, const std::string& a_value)
: key_(a_key), value_(a_value) {}
// Gets the user supplied key. constchar* key() const { return key_.c_str(); }
// Gets the user supplied value. constchar* value() const { return value_.c_str(); }
// Sets a new value, overriding the one supplied in the constructor. void SetValue(const std::string& new_value) { value_ = new_value; }
private: // The key supplied by the user.
std::string key_; // The value supplied by the user.
std::string value_;
};
// The result of a single Test. This includes a list of // TestPartResults, a list of TestProperties, a count of how many // death tests there are in the Test, and how much time it took to run // the Test. // // TestResult is not copyable. class GTEST_API_ TestResult { public: // Creates an empty TestResult.
TestResult();
// D'tor. Do not inherit from TestResult.
~TestResult();
// Gets the number of all test parts. This is the sum of the number // of successful test parts and the number of failed test parts. int total_part_count() const;
// Returns the number of the test properties. int test_property_count() const;
// Returns true if and only if the test passed (i.e. no test part failed). bool Passed() const { return !Skipped() && !Failed(); }
// Returns true if and only if the test was skipped. bool Skipped() const;
// Returns true if and only if the test failed. bool Failed() const;
// Returns true if and only if the test fatally failed. bool HasFatalFailure() const;
// Returns true if and only if the test has a non-fatal failure. bool HasNonfatalFailure() const;
// Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; }
// Gets the time of the test case start, in ms from the start of the // UNIX epoch.
TimeInMillis start_timestamp() const { return start_timestamp_; }
// Returns the i-th test part result among all the results. i can range from 0 // to total_part_count() - 1. If i is not in that range, aborts the program. const TestPartResult& GetTestPartResult(int i) const;
// Returns the i-th test property. i can range from 0 to // test_property_count() - 1. If i is not in that range, aborts the // program. const TestProperty& GetTestProperty(int i) const;
// Adds a test property to the list. The property is validated and may add // a non-fatal failure if invalid (e.g., if it conflicts with reserved // key names). If a property is already recorded for the same key, the // value will be updated, rather than storing multiple values for the same // key. xml_element specifies the element for which the property is being // recorded and is used for validation. void RecordProperty(const std::string& xml_element, const TestProperty& test_property);
// Adds a failure if the key is a reserved attribute of Google Test // testsuite tags. Returns true if the property is valid. // FIXME: Validate attribute names are legal and human readable. staticbool ValidateTestProperty(const std::string& xml_element, const TestProperty& test_property);
// Adds a test part result to the list. void AddTestPartResult(const TestPartResult& test_part_result);
// Returns the death test count. int death_test_count() const { return death_test_count_; }
// Increments the death test count, returning the new count. int increment_death_test_count() { return ++death_test_count_; }
// Clears the test part results. void ClearTestPartResults();
// Clears the object. void Clear();
// Protects mutable state of the property vector and of owned // properties, whose values may be updated.
internal::Mutex test_properties_mutex_;
// The vector of TestPartResults
std::vector<TestPartResult> test_part_results_; // The vector of TestProperties
std::vector<TestProperty> test_properties_; // Running count of death tests. int death_test_count_; // The start time, in milliseconds since UNIX Epoch.
TimeInMillis start_timestamp_; // The elapsed time, in milliseconds.
TimeInMillis elapsed_time_;
// We disallow copying TestResult.
TestResult(const TestResult&) = delete;
TestResult& operator=(const TestResult&) = delete;
}; // class TestResult
// A TestInfo object stores the following information about a test: // // Test suite name // Test name // Whether the test should be run // A function pointer that creates the test object when invoked // Test result // // The constructor of TestInfo registers itself with the UnitTest // singleton such that the RUN_ALL_TESTS() macro knows which tests to // run. class GTEST_API_ TestInfo { public: // Destructs a TestInfo object. This function is not virtual, so // don't inherit from TestInfo.
~TestInfo();
// Returns the test suite name. constchar* test_suite_name() const { return test_suite_name_.c_str(); }
// Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ constchar* test_case_name() const { return test_suite_name(); } #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Returns the test name. constchar* name() const { return name_.c_str(); }
// Returns the name of the parameter type, or NULL if this is not a typed // or a type-parameterized test. constchar* type_param() const { if (type_param_ != nullptr) return type_param_->c_str(); return nullptr;
}
// Returns the text representation of the value parameter, or NULL if this // is not a value-parameterized test. constchar* value_param() const { if (value_param_ != nullptr) return value_param_->c_str(); return nullptr;
}
// Returns the file name where this test is defined. constchar* file() const { return location_.file.c_str(); }
// Returns the line where this test is defined. int line() const { return location_.line; }
// Return true if this test should not be run because it's in another shard. bool is_in_another_shard() const { return is_in_another_shard_; }
// Returns true if this test should run, that is if the test is not // disabled (or it is disabled but the also_run_disabled_tests flag has // been specified) and its full name matches the user-specified filter. // // Google Test allows the user to filter the tests by their full names. // The full name of a test Bar in test suite Foo is defined as // "Foo.Bar". Only the tests that match the filter will run. // // A filter is a colon-separated list of glob (not regex) patterns, // optionally followed by a '-' and a colon-separated list of // negative patterns (tests to exclude). A test is run if it // matches one of the positive patterns and does not match any of // the negative patterns. // // For example, *A*:Foo.* is a filter that matches any string that // contains the character 'A' or starts with "Foo.". bool should_run() const { return should_run_; }
// Returns true if and only if this test will appear in the XML report. bool is_reportable() const { // The XML report includes tests matching the filter, excluding those // run in other shards. return matches_filter_ && !is_in_another_shard_;
}
// Returns the result of the test. const TestResult* result() const { return &result_; }
// Constructs a TestInfo object. The newly constructed instance assumes // ownership of the factory object.
TestInfo(std::string test_suite_name, std::string name, constchar* a_type_param, // NULL if not a type-parameterized test constchar* a_value_param, // NULL if not a value-parameterized test
internal::CodeLocation a_code_location,
internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory);
// Increments the number of death tests encountered in this test so // far. int increment_death_test_count() { return result_.increment_death_test_count();
}
// Creates the test object, runs it, records its result, and then // deletes it. void Run();
// Skip and records the test result for this object. void Skip();
// These fields are immutable properties of the test. const std::string test_suite_name_; // test suite name const std::string name_; // Test name // Name of the parameter type, or NULL if this is not a typed or a // type-parameterized test. const std::unique_ptr<const ::std::string> type_param_; // Text representation of the value parameter, or NULL if this is not a // value-parameterized test. const std::unique_ptr<const ::std::string> value_param_;
internal::CodeLocation location_; const internal::TypeId fixture_class_id_; // ID of the test fixture class bool should_run_; // True if and only if this test should run bool is_disabled_; // True if and only if this test is disabled bool matches_filter_; // True if this test matches the // user-specified filter. bool is_in_another_shard_; // Will be run in another shard.
internal::TestFactoryBase* const factory_; // The factory that creates // the test object
// This field is mutable and needs to be reset before running the // test for the second time.
TestResult result_;
// A test suite, which consists of a vector of TestInfos. // // TestSuite is not copyable. class GTEST_API_ TestSuite { public: // Creates a TestSuite with the given name. // // TestSuite does NOT have a default constructor. Always use this // constructor to create a TestSuite object. // // Arguments: // // name: name of the test suite // a_type_param: the name of the test's type parameter, or NULL if // this is not a type-parameterized test. // set_up_tc: pointer to the function that sets up the test suite // tear_down_tc: pointer to the function that tears down the test suite
TestSuite(const std::string& name, constchar* a_type_param,
internal::SetUpTestSuiteFunc set_up_tc,
internal::TearDownTestSuiteFunc tear_down_tc);
// Destructor of TestSuite. virtual ~TestSuite();
// Gets the name of the TestSuite. constchar* name() const { return name_.c_str(); }
// Returns the name of the parameter type, or NULL if this is not a // type-parameterized test suite. constchar* type_param() const { if (type_param_ != nullptr) return type_param_->c_str(); return nullptr;
}
// Returns true if any test in this test suite should run. bool should_run() const { return should_run_; }
// Gets the number of successful tests in this test suite. int successful_test_count() const;
// Gets the number of skipped tests in this test suite. int skipped_test_count() const;
// Gets the number of failed tests in this test suite. int failed_test_count() const;
// Gets the number of disabled tests that will be reported in the XML report. int reportable_disabled_test_count() const;
// Gets the number of disabled tests in this test suite. int disabled_test_count() const;
// Gets the number of tests to be printed in the XML report. int reportable_test_count() const;
// Get the number of tests in this test suite that should run. int test_to_run_count() const;
// Gets the number of all tests in this test suite. int total_test_count() const;
// Returns true if and only if the test suite passed. bool Passed() const { return !Failed(); }
// Returns true if and only if the test suite failed. bool Failed() const { return failed_test_count() > 0 || ad_hoc_test_result().Failed();
}
// Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; }
// Gets the time of the test suite start, in ms from the start of the // UNIX epoch.
TimeInMillis start_timestamp() const { return start_timestamp_; }
// 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. const TestInfo* GetTestInfo(int i) const;
// Returns the TestResult that holds test properties recorded during // execution of SetUpTestSuite and TearDownTestSuite. const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
// Gets the (mutable) vector of TestInfos in this TestSuite.
std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
// Gets the (immutable) vector of TestInfos in this TestSuite. const std::vector<TestInfo*>& test_info_list() const { return test_info_list_;
}
// 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.
TestInfo* GetMutableTestInfo(int i);
// Adds a TestInfo to this test suite. Will delete the TestInfo upon // destruction of the TestSuite object. void AddTestInfo(TestInfo* test_info);
// Clears the results of all tests in this test suite. void ClearResult();
// Clears the results of all tests in the given test suite. staticvoid ClearTestSuiteResult(TestSuite* test_suite) {
test_suite->ClearResult();
}
// Runs every test in this TestSuite. void Run();
// Skips the execution of tests under this TestSuite void Skip();
// Runs SetUpTestSuite() for this TestSuite. This wrapper is needed // for catching exceptions thrown from SetUpTestSuite(). void RunSetUpTestSuite() { if (set_up_tc_ != nullptr) {
(*set_up_tc_)();
}
}
// Runs TearDownTestSuite() for this TestSuite. This wrapper is // needed for catching exceptions thrown from TearDownTestSuite(). void RunTearDownTestSuite() { if (tear_down_tc_ != nullptr) {
(*tear_down_tc_)();
}
}
// Returns true if and only if test passed. staticbool TestPassed(const TestInfo* test_info) { return test_info->should_run() && test_info->result()->Passed();
}
// Returns true if and only if test skipped. staticbool TestSkipped(const TestInfo* test_info) { return test_info->should_run() && test_info->result()->Skipped();
}
// Returns true if and only if test failed. staticbool TestFailed(const TestInfo* test_info) { return test_info->should_run() && test_info->result()->Failed();
}
// Returns true if and only if the test is disabled and will be reported in // the XML report. staticbool TestReportableDisabled(const TestInfo* test_info) { return test_info->is_reportable() && test_info->is_disabled_;
}
// Returns true if and only if test is disabled. staticbool TestDisabled(const TestInfo* test_info) { return test_info->is_disabled_;
}
// Returns true if and only if this test will appear in the XML report. staticbool TestReportable(const TestInfo* test_info) { return test_info->is_reportable();
}
// Returns true if the given test should run. staticbool ShouldRunTest(const TestInfo* test_info) { return test_info->should_run();
}
// Shuffles the tests in this test suite. void ShuffleTests(internal::Random* random);
// Restores the test order to before the first shuffle. void UnshuffleTests();
// Name of the test suite.
std::string name_; // Name of the parameter type, or NULL if this is not a typed or a // type-parameterized test. const std::unique_ptr<const ::std::string> type_param_; // The vector of TestInfos in their original order. It owns the // elements in the vector.
std::vector<TestInfo*> test_info_list_; // Provides a level of indirection for the test list to allow easy // shuffling and restoring the test order. The i-th element in this // vector is the index of the i-th test in the shuffled test list.
std::vector<int> test_indices_; // Pointer to the function that sets up the test suite.
internal::SetUpTestSuiteFunc set_up_tc_; // Pointer to the function that tears down the test suite.
internal::TearDownTestSuiteFunc tear_down_tc_; // True if and only if any test in this test suite should run. bool should_run_; // The start time, in milliseconds since UNIX Epoch.
TimeInMillis start_timestamp_; // Elapsed time, in milliseconds.
TimeInMillis elapsed_time_; // Holds test properties recorded during execution of SetUpTestSuite and // TearDownTestSuite.
TestResult ad_hoc_test_result_;
// An Environment object is capable of setting up and tearing down an // environment. You should subclass this to define your own // environment(s). // // An Environment object does the set-up and tear-down in virtual // methods SetUp() and TearDown() instead of the constructor and the // destructor, as: // // 1. You cannot safely throw from a destructor. This is a problem // as in some cases Google Test is used where exceptions are enabled, and // we may want to implement ASSERT_* using exceptions where they are // available. // 2. You cannot use ASSERT_* directly in a constructor or // destructor. class Environment { public: // The d'tor is virtual as we need to subclass Environment. virtual ~Environment() = default;
// Override this to define how to set up the environment. virtualvoid SetUp() {}
// Override this to define how to tear down the environment. virtualvoid TearDown() {}
private: // If you see an error about overriding the following function or // about it being private, you have mis-spelled SetUp() as Setup(). struct Setup_should_be_spelled_SetUp {}; virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
};
#if GTEST_HAS_EXCEPTIONS
// Exception which can be thrown from TestEventListener::OnTestPartResult. class GTEST_API_ AssertionException
: public internal::GoogleTestFailureException { public: explicit AssertionException(const TestPartResult& result)
: GoogleTestFailureException(result) {}
};
#endif// GTEST_HAS_EXCEPTIONS
// The interface for tracing execution of tests. The methods are organized in // the order the corresponding events are fired. class TestEventListener { public: virtual ~TestEventListener() = default;
// Fired before any test activity starts. virtualvoid OnTestProgramStart(const UnitTest& unit_test) = 0;
// Fired before each iteration of tests starts. There may be more than // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration // index, starting from 0. virtualvoid OnTestIterationStart(const UnitTest& unit_test, int iteration) = 0;
// Fired before environment set-up for each iteration of tests starts. virtualvoid OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
// Fired after environment set-up for each iteration of tests ends. virtualvoid OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
// Fired before the test suite starts. virtualvoid OnTestSuiteStart(const TestSuite& /*test_suite*/) {}
// Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ virtualvoid OnTestCaseStart(const TestCase& /*test_case*/) {} #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Fired before the test starts. virtualvoid OnTestStart(const TestInfo& test_info) = 0;
// Fired when a test is disabled virtualvoid OnTestDisabled(const TestInfo& /*test_info*/) {}
// Fired after a failed assertion or a SUCCEED() invocation. // If you want to throw an exception from this function to skip to the next // TEST, it must be AssertionException defined above, or inherited from it. virtualvoid OnTestPartResult(const TestPartResult& test_part_result) = 0;
// Fired after the test ends. virtualvoid OnTestEnd(const TestInfo& test_info) = 0;
// Fired after the test suite ends. virtualvoid OnTestSuiteEnd(const TestSuite& /*test_suite*/) {}
// Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ virtualvoid OnTestCaseEnd(const TestCase& /*test_case*/) {} #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Fired before environment tear-down for each iteration of tests starts. virtualvoid OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
// Fired after environment tear-down for each iteration of tests ends. virtualvoid OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
// Fired after each iteration of tests finishes. virtualvoid OnTestIterationEnd(const UnitTest& unit_test, int iteration) = 0;
// Fired after all test activities have ended. virtualvoid OnTestProgramEnd(const UnitTest& unit_test) = 0;
};
// The convenience class for users who need to override just one or two // methods and are not concerned that a possible change to a signature of // the methods they override will not be caught during the build. For // comments about each method please see the definition of TestEventListener // above. class EmptyTestEventListener : public TestEventListener { public: void OnTestProgramStart(const UnitTest& /*unit_test*/) override {} void OnTestIterationStart(const UnitTest& /*unit_test*/, int/*iteration*/) override {} void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {} void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {} void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {} // Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ void OnTestCaseStart(const TestCase& /*test_case*/) override {} #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// TestEventListeners lets users add listeners to track events in Google Test. class GTEST_API_ TestEventListeners { public:
TestEventListeners();
~TestEventListeners();
// Appends an event listener to the end of the list. Google Test assumes // the ownership of the listener (i.e. it will delete the listener when // the test program finishes). void Append(TestEventListener* listener);
// Removes the given event listener from the list and returns it. It then // becomes the caller's responsibility to delete the listener. Returns // NULL if the listener is not found in the list.
TestEventListener* Release(TestEventListener* listener);
// Returns the standard listener responsible for the default console // output. Can be removed from the listeners list to shut down default // console output. Note that removing this object from the listener list // with Release transfers its ownership to the caller and makes this // function return NULL the next time.
TestEventListener* default_result_printer() const { return default_result_printer_;
}
// Returns the standard listener responsible for the default XML output // controlled by the --gtest_output=xml flag. Can be removed from the // listeners list by users who want to shut down the default XML output // controlled by this flag and substitute it with custom one. Note that // removing this object from the listener list with Release transfers its // ownership to the caller and makes this function return NULL the next // time.
TestEventListener* default_xml_generator() const { return default_xml_generator_;
}
// Controls whether events will be forwarded by the repeater to the // listeners in the list. void SuppressEventForwarding(bool);
// Returns repeater that broadcasts the TestEventListener events to all // subscribers.
TestEventListener* repeater();
// Sets the default_result_printer attribute to the provided listener. // The listener is also added to the listener list and previous // default_result_printer is removed from it and deleted. The listener can // also be NULL in which case it will not be added to the list. Does // nothing if the previous and the current listener objects are the same. void SetDefaultResultPrinter(TestEventListener* listener);
// Sets the default_xml_generator attribute to the provided listener. The // listener is also added to the listener list and previous // default_xml_generator is removed from it and deleted. The listener can // also be NULL in which case it will not be added to the list. Does // nothing if the previous and the current listener objects are the same. void SetDefaultXmlGenerator(TestEventListener* listener);
// Controls whether events will be forwarded by the repeater to the // listeners in the list. bool EventForwardingEnabled() const;
// The actual list of listeners.
internal::TestEventRepeater* repeater_; // Listener responsible for the standard result output.
TestEventListener* default_result_printer_; // Listener responsible for the creation of the XML output file.
TestEventListener* default_xml_generator_;
// A UnitTest consists of a vector of TestSuites. // // This is a singleton class. The only instance of UnitTest is // created when UnitTest::GetInstance() is first called. This // instance is never deleted. // // UnitTest is not copyable. // // This class is thread-safe as long as the methods are called // according to their specification. class GTEST_API_ UnitTest { public: // Gets the singleton UnitTest object. The first time this method // is called, a UnitTest object is constructed and returned. // Consecutive calls will return the same object. static UnitTest* GetInstance();
// Runs all tests in this UnitTest object and prints the result. // Returns 0 if successful, or 1 otherwise. // // This method can only be called from the main thread. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. int Run() GTEST_MUST_USE_RESULT_;
// Returns the working directory when the first TEST() or TEST_F() // was executed. The UnitTest object owns the string. constchar* original_working_dir() const;
// Returns the TestSuite object for the test that's currently running, // or NULL if no test is running. const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
// Legacy API is still available but deprecated #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_); #endif
// Returns the TestInfo object for the test that's currently running, // or NULL if no test is running. const TestInfo* current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_);
// Returns the random seed used at the start of the current test run. int random_seed() const;
// Returns the ParameterizedTestSuiteRegistry object used to keep track of // value-parameterized tests and instantiate and register them. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
GTEST_LOCK_EXCLUDED_(mutex_);
// Gets the number of successful test suites. int successful_test_suite_count() const;
// Gets the number of failed test suites. int failed_test_suite_count() const;
// Gets the number of all test suites. int total_test_suite_count() const;
// Gets the number of all test suites that contain at least one test // that should run. int test_suite_to_run_count() const;
// Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ int successful_test_case_count() const; int failed_test_case_count() const; int total_test_case_count() const; int test_case_to_run_count() const; #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Gets the number of successful tests. int successful_test_count() const;
// Gets the number of skipped tests. int skipped_test_count() const;
// Gets the number of failed tests. int failed_test_count() const;
// Gets the number of disabled tests that will be reported in the XML report. int reportable_disabled_test_count() const;
// Gets the number of disabled tests. int disabled_test_count() const;
// Gets the number of tests to be printed in the XML report. int reportable_test_count() const;
// Gets the number of all tests. int total_test_count() const;
// Gets the number of tests that should run. int test_to_run_count() const;
// Gets the time of the test program start, in ms from the start of the // UNIX epoch.
TimeInMillis start_timestamp() const;
// Gets the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const;
// Returns true if and only if the unit test passed (i.e. all test suites // passed). bool Passed() const;
// Returns true if and only if the unit test failed (i.e. some test suite // failed or something outside of all tests failed). bool Failed() const;
// Gets the i-th test suite among all the test suites. i can range from 0 to // total_test_suite_count() - 1. If i is not in that range, returns NULL. const TestSuite* GetTestSuite(int i) const;
// Legacy API is deprecated but still available #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ const TestCase* GetTestCase(int i) const; #endif// GTEST_REMOVE_LEGACY_TEST_CASEAPI_
// Returns the TestResult containing information on test failures and // properties logged outside of individual test suites. const TestResult& ad_hoc_test_result() const;
// Returns the list of event listeners that can be used to track events // inside Google Test.
TestEventListeners& listeners();
private: // Registers and returns a global test environment. When a test // program is run, all global test environments will be set-up in // the order they were registered. After all tests in the program // have finished, all global test environments will be torn-down in // the *reverse* order they were registered. // // The UnitTest object takes ownership of the given environment. // // This method can only be called from the main thread.
Environment* AddEnvironment(Environment* env);
// Adds a TestPartResult to the current TestResult object. All // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) // eventually call this to report their results. The user code // should use the assertion macros instead of calling this directly. void AddTestPartResult(TestPartResult::Type result_type, constchar* file_name, int line_number, const std::string& message, const std::string& os_stack_trace)
GTEST_LOCK_EXCLUDED_(mutex_);
// Adds a TestProperty to the current TestResult object when invoked from // inside a test, to current TestSuite's ad_hoc_test_result_ when invoked // from SetUpTestSuite or TearDownTestSuite, or to the global property set // when invoked elsewhere. If the result already contains a property with // the same key, the value will be updated. void RecordProperty(const std::string& key, const std::string& value);
// Gets the i-th test suite among all the test suites. i can range from 0 to // total_test_suite_count() - 1. If i is not in that range, returns NULL.
TestSuite* GetMutableTestSuite(int i);
// Invokes OsStackTrackGetterInterface::UponLeavingGTest. UponLeavingGTest() // should be called immediately before Google Test calls user code. It saves // some information about the current stack that CurrentStackTrace() will use // to find and hide Google Test stack frames. void UponLeavingGTest();
// Sets the TestSuite object for the test that's currently running. void set_current_test_suite(TestSuite* a_current_test_suite)
GTEST_LOCK_EXCLUDED_(mutex_);
// Sets the TestInfo object for the test that's currently running. void set_current_test_info(TestInfo* a_current_test_info)
GTEST_LOCK_EXCLUDED_(mutex_);
// Accessors for the implementation object.
internal::UnitTestImpl* impl() { return impl_; } const internal::UnitTestImpl* impl() const { return impl_; }
// These classes and functions are friends as they need to access private // members of UnitTest. friendclass ScopedTrace; friendclass Test; friendclass TestInfo; friendclass TestSuite; friendclass internal::AssertHelper; friendclass internal::StreamingListenerTest; friendclass internal::UnitTestRecordPropertyTestHelper; friend Environment* AddGlobalTestEnvironment(Environment* env); friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites(); friend internal::UnitTestImpl* internal::GetUnitTestImpl(); friendvoid internal::ReportFailureInUnknownLocation(
TestPartResult::Type result_type, const std::string& message);
// Creates an empty UnitTest.
UnitTest();
// D'tor virtual ~UnitTest();
// Pushes a trace defined by SCOPED_TRACE() on to the per-thread // Google Test trace stack. void PushGTestTrace(const internal::TraceInfo& trace)
GTEST_LOCK_EXCLUDED_(mutex_);
// Pops a trace from the per-thread Google Test trace stack. void PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_);
// Protects mutable state in *impl_. This is mutable as some const // methods need to lock it too. mutable internal::Mutex mutex_;
// Opaque implementation object. This field is never changed once // the object is constructed. We don't mark it as const here, as // doing so will cause a warning in the constructor of UnitTest. // Mutable state in *impl_ is protected by mutex_.
internal::UnitTestImpl* impl_;
// A convenient wrapper for adding an environment for the test // program. // // You should call this before RUN_ALL_TESTS() is called, probably in // main(). If you use gtest_main, you need to call this before main() // starts for it to take effect. For example, you can define a global // variable like this: // // testing::Environment* const foo_env = // testing::AddGlobalTestEnvironment(new FooEnvironment); // // However, we strongly recommend you to write your own main() and // call AddGlobalTestEnvironment() there, as relying on initialization // of global variables makes the code harder to read and may cause // problems when you register multiple environments from different // translation units and the environments have dependencies among them // (remember that the compiler doesn't guarantee the order in which // global variables from different translation units are initialized). inline Environment* AddGlobalTestEnvironment(Environment* env) { return UnitTest::GetInstance()->AddEnvironment(env);
}
// Initializes Google Test. This must be called before calling // RUN_ALL_TESTS(). In particular, it parses a command line for the // flags that Google Test recognizes. Whenever a Google Test flag is // seen, it is removed from argv, and *argc is decremented. // // No value is returned. Instead, the Google Test flag variables are // updated. // // Calling the function for the second time has no user-visible effect.
GTEST_API_ void InitGoogleTest(int* argc, char** argv);
// This overloaded version can be used in Windows programs compiled in // UNICODE mode.
GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
// This overloaded version can be used on Arduino/embedded platforms where // there is no argc/argv.
GTEST_API_ void InitGoogleTest();
namespace internal {
// Separate the error generating code from the code path to reduce the stack // frame size of CmpHelperEQ. This helps reduce the overhead of some sanitizers // when calling EXPECT_* in a tight loop. template <typename T1, typename T2>
AssertionResult CmpHelperEQFailure(constchar* lhs_expression, constchar* rhs_expression, const T1& lhs, const T2& rhs) { return EqFailure(lhs_expression, rhs_expression,
FormatForComparisonFailureMessage(lhs, rhs),
FormatForComparisonFailureMessage(rhs, lhs), false);
}
// This block of code defines operator==/!= // to block lexical scope lookup. // It prevents using invalid operator==/!= defined at namespace scope. struct faketype {}; inlinebooloperator==(faketype, faketype) { returntrue; } inlinebooloperator!=(faketype, faketype) { returnfalse; }
// The helper function for {ASSERT|EXPECT}_EQ. template <typename T1, typename T2>
AssertionResult CmpHelperEQ(constchar* lhs_expression, constchar* rhs_expression, const T1& lhs, const T2& rhs) { if (lhs == rhs) { return AssertionSuccess();
}
class EqHelper { public: // This templatized version is for the general case. template < typename T1, typename T2, // Disable this overload for cases where one argument is a pointer // and the other is the null pointer constant. typename std::enable_if<!std::is_integral<T1>::value ||
!std::is_pointer<T2>::value>::type* = nullptr> static AssertionResult Compare(constchar* lhs_expression, constchar* rhs_expression, const T1& lhs, const T2& rhs) { return CmpHelperEQ(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. // // Even though its body looks the same as the above version, we // cannot merge the two, as it will make anonymous enums unhappy. static AssertionResult Compare(constchar* lhs_expression, constchar* rhs_expression, BiggestInt lhs,
BiggestInt rhs) { return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
}
template <typename T> static AssertionResult Compare( constchar* lhs_expression, constchar* rhs_expression, // Handle cases where '0' is used as a null pointer literal.
std::nullptr_t /* lhs */, T* rhs) { // We already know that 'lhs' is a null pointer. return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
rhs);
}
};
// Separate the error generating code from the code path to reduce the stack // frame size of CmpHelperOP. This helps reduce the overhead of some sanitizers // when calling EXPECT_OP in a tight loop. template <typename T1, typename T2>
AssertionResult CmpHelperOpFailure(constchar* expr1, constchar* expr2, const T1& val1, const T2& val2, constchar* op) { return AssertionFailure()
<< "Expected: (" << expr1 << ") " << op << " (" << expr2
<< "), actual: " << FormatForComparisonFailureMessage(val1, val2)
<< " vs " << FormatForComparisonFailureMessage(val2, val1);
}
// A macro for implementing the helper functions needed to implement // ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste // of similar code. // // 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
GTEST_IMPL_CMP_HELPER_(NE, !=) // Implements the helper function for {ASSERT|EXPECT}_LE
GTEST_IMPL_CMP_HELPER_(LE, <=) // Implements the helper function for {ASSERT|EXPECT}_LT
GTEST_IMPL_CMP_HELPER_(LT, <) // Implements the helper function for {ASSERT|EXPECT}_GE
GTEST_IMPL_CMP_HELPER_(GE, >=) // Implements the helper function for {ASSERT|EXPECT}_GT
GTEST_IMPL_CMP_HELPER_(GT, >)
#undef GTEST_IMPL_CMP_HELPER_
// The helper function for {ASSERT|EXPECT}_STREQ. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTREQ(constchar* s1_expression, constchar* s2_expression, constchar* s1, constchar* s2);
// The helper function for {ASSERT|EXPECT}_STRCASEEQ. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(constchar* s1_expression, constchar* s2_expression, constchar* s1, constchar* s2);
// The helper function for {ASSERT|EXPECT}_STRNE. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTRNE(constchar* s1_expression, constchar* s2_expression, constchar* s1, constchar* s2);
// The helper function for {ASSERT|EXPECT}_STRCASENE. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTRCASENE(constchar* s1_expression, constchar* s2_expression, constchar* s1, constchar* s2);
// Helper function for *_STREQ on wide strings. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTREQ(constchar* s1_expression, constchar* s2_expression, constwchar_t* s1, constwchar_t* s2);
// Helper function for *_STRNE on wide strings. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult CmpHelperSTRNE(constchar* s1_expression, constchar* s2_expression, constwchar_t* s1, constwchar_t* s2);
} // namespace internal
// IsSubstring() and IsNotSubstring() are intended to be used as the // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by // themselves. They check whether needle is a substring of haystack // (NULL is considered a substring of itself only), and return an // appropriate error message when they fail. // // The {needle,haystack}_expr arguments are the stringified // expressions that generated the two real arguments.
GTEST_API_ AssertionResult IsSubstring(constchar* needle_expr, constchar* haystack_expr, constchar* needle, constchar* haystack);
GTEST_API_ AssertionResult IsSubstring(constchar* needle_expr, constchar* haystack_expr, constwchar_t* needle, constwchar_t* haystack);
GTEST_API_ AssertionResult IsNotSubstring(constchar* needle_expr, constchar* haystack_expr, constchar* needle, constchar* haystack);
GTEST_API_ AssertionResult IsNotSubstring(constchar* needle_expr, constchar* haystack_expr, constwchar_t* needle, constwchar_t* haystack);
GTEST_API_ AssertionResult IsSubstring(constchar* needle_expr, constchar* haystack_expr, const ::std::string& needle, const ::std::string& haystack);
GTEST_API_ AssertionResult IsNotSubstring(constchar* needle_expr, constchar* haystack_expr, const ::std::string& needle, const ::std::string& haystack);
// Helper template function for comparing floating-points. // // Template parameter: // // RawType: the raw floating-point type (either float or double) // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. template <typename RawType>
AssertionResult CmpHelperFloatingPointEQ(constchar* lhs_expression, constchar* rhs_expression,
RawType lhs_value, RawType rhs_value) { const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
if (lhs.AlmostEquals(rhs)) { return AssertionSuccess();
}
// Helper function for implementing ASSERT_NEAR. // // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
GTEST_API_ AssertionResult DoubleNearPredFormat(constchar* expr1, constchar* expr2, constchar* abs_error_expr, double val1, double val2, double abs_error);
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. // A class that enables one to stream messages to assertion macros class GTEST_API_ AssertHelper { public: // Constructor.
AssertHelper(TestPartResult::Type type, constchar* file, int line, constchar* message);
~AssertHelper();
// Message assignment is a semantic trick to enable assertion // streaming; see the GTEST_MESSAGE_ macro below. voidoperator=(const Message& message) const;
private: // We put our data in a struct so that the size of the AssertHelper class can // be as small as possible. This is important because gcc is incapable of // re-using stack space even for temporary variables, so every EXPECT_EQ // reserves stack space for another AssertHelper. struct AssertHelperData {
AssertHelperData(TestPartResult::Type t, constchar* srcfile, int line_num, constchar* msg)
: type(t), file(srcfile), line(line_num), message(msg) {}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.