52 #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
53 #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
59 #include <type_traits>
62 #include "gtest/internal/gtest-internal.h"
63 #include "gtest/internal/gtest-string.h"
64 #include "gtest/gtest-death-test.h"
65 #include "gtest/gtest-matchers.h"
66 #include "gtest/gtest-message.h"
67 #include "gtest/gtest-param-test.h"
68 #include "gtest/gtest-printers.h"
69 #include "gtest/gtest_prod.h"
70 #include "gtest/gtest-test-part.h"
71 #include "gtest/gtest-typed-test.h"
81 # pragma warning(push)
82 # pragma warning(disable:4805)
83 # pragma warning(disable:4100)
162 #if GTEST_USE_OWN_FLAGFILE_FLAG_
167 const int kMaxStackTraceDepth = 100;
172 class DefaultGlobalTestPartResultReporter;
174 class NoExecDeathTest;
175 class FinalSuccessChecker;
176 class GTestFlagSaver;
177 class StreamingListenerTest;
178 class TestResultAccessor;
179 class TestEventListenersAccessor;
180 class TestEventRepeater;
181 class UnitTestRecordPropertyTestHelper;
182 class WindowsDeathTest;
183 class FuchsiaDeathTest;
184 class UnitTestImpl* GetUnitTestImpl();
185 void ReportFailureInUnknownLocation(TestPartResult::Type
result_type,
186 const std::string& message);
187 std::set<std::string>* GetIgnoredParameterizedTestSuites();
198 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
199 using TestCase = TestSuite;
287 AssertionResult(
const AssertionResult& other);
293 #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
304 template <
typename T>
305 explicit AssertionResult(
307 typename std::enable_if<
308 !std::is_convertible<T, AssertionResult>::value>::type*
311 : success_(success) {}
313 #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
318 AssertionResult& operator=(AssertionResult other) {
324 operator bool()
const {
return success_; }
327 AssertionResult operator!()
const;
333 const char* message()
const {
334 return message_.get() !=
nullptr ? message_->c_str() :
"";
337 const char* failure_message()
const {
return message(); }
340 template <
typename T> AssertionResult&
operator<<(
const T& value) {
341 AppendMessage(Message() << value);
348 ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
349 AppendMessage(Message() << basic_manipulator);
355 void AppendMessage(
const Message& a_message) {
356 if (message_.get() ==
nullptr) message_.reset(new ::std::string);
357 message_->append(a_message.GetString().c_str());
361 void swap(AssertionResult& other);
369 std::unique_ptr< ::std::string> message_;
373 GTEST_API_ AssertionResult AssertionSuccess();
376 GTEST_API_ AssertionResult AssertionFailure();
380 GTEST_API_ AssertionResult AssertionFailure(
const Message& msg);
387 #include "gtest/gtest_pred_impl.h"
439 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
455 static bool HasFailure() {
return HasFatalFailure() || HasNonfatalFailure(); }
486 static bool HasSameFixtureClass();
494 virtual void TestBody() = 0;
501 void DeleteSelf_() {
delete this; }
503 const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
521 struct Setup_should_be_spelled_SetUp {};
522 virtual Setup_should_be_spelled_SetUp* Setup() {
return nullptr; }
540 key_(a_key), value_(a_value) {
550 return value_.c_str();
587 bool Passed()
const {
return !Skipped() && !Failed(); }
621 friend class internal::DefaultGlobalTestPartResultReporter;
622 friend class internal::ExecDeathTest;
623 friend class internal::TestResultAccessor;
624 friend class internal::UnitTestImpl;
625 friend class internal::WindowsDeathTest;
626 friend class internal::FuchsiaDeathTest;
629 const std::vector<TestPartResult>& test_part_results()
const {
630 return test_part_results_;
634 const std::vector<TestProperty>& test_properties()
const {
635 return test_properties_;
639 void set_start_timestamp(
TimeInMillis start) { start_timestamp_ = start; }
642 void set_elapsed_time(
TimeInMillis elapsed) { elapsed_time_ = elapsed; }
650 void RecordProperty(
const std::string& xml_element,
651 const TestProperty& test_property);
656 static bool ValidateTestProperty(
const std::string& xml_element,
657 const TestProperty& test_property);
660 void AddTestPartResult(
const TestPartResult& test_part_result);
663 int death_test_count()
const {
return death_test_count_; }
666 int increment_death_test_count() {
return ++death_test_count_; }
669 void ClearTestPartResults();
676 internal::Mutex test_properites_mutex_;
679 std::vector<TestPartResult> test_part_results_;
681 std::vector<TestProperty> test_properties_;
683 int death_test_count_;
714 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
719 const char*
name()
const {
return name_.c_str(); }
724 if (type_param_.get() !=
nullptr)
return type_param_->c_str();
731 if (value_param_.get() !=
nullptr)
return value_param_->c_str();
736 const char*
file()
const {
return location_.file.c_str(); }
739 int line()
const {
return location_.line; }
766 return matches_filter_ && !is_in_another_shard_;
773 #if GTEST_HAS_DEATH_TEST
774 friend class internal::DefaultDeathTestFactory;
778 friend class internal::UnitTestImpl;
779 friend class internal::StreamingListenerTest;
781 const char* test_suite_name,
const char* name,
const char* type_param,
789 TestInfo(
const std::string& test_suite_name,
const std::string& name,
790 const char* a_type_param,
791 const char* a_value_param,
798 int increment_death_test_count() {
799 return result_.increment_death_test_count();
809 static void ClearTestResult(
TestInfo* test_info) {
810 test_info->result_.Clear();
814 const std::string test_suite_name_;
815 const std::string name_;
818 const std::unique_ptr<const ::std::string> type_param_;
821 const std::unique_ptr<const ::std::string> value_param_;
822 internal::CodeLocation location_;
826 bool matches_filter_;
828 bool is_in_another_shard_;
829 internal::TestFactoryBase*
const factory_;
864 const char*
name()
const {
return name_.c_str(); }
869 if (type_param_.get() !=
nullptr)
return type_param_->c_str();
901 bool Passed()
const {
return !Failed(); }
905 return failed_test_count() > 0 || ad_hoc_test_result().Failed();
925 friend class internal::UnitTestImpl;
928 std::vector<TestInfo*>& test_info_list() {
return test_info_list_; }
931 const std::vector<TestInfo*>& test_info_list()
const {
932 return test_info_list_;
937 TestInfo* GetMutableTestInfo(
int i);
940 void set_should_run(
bool should) { should_run_ = should; }
944 void AddTestInfo(TestInfo * test_info);
950 static void ClearTestSuiteResult(TestSuite* test_suite) {
951 test_suite->ClearResult();
962 void RunSetUpTestSuite() {
963 if (set_up_tc_ !=
nullptr) {
970 void RunTearDownTestSuite() {
971 if (tear_down_tc_ !=
nullptr) {
977 static bool TestPassed(
const TestInfo* test_info) {
978 return test_info->should_run() && test_info->result()->Passed();
982 static bool TestSkipped(
const TestInfo* test_info) {
983 return test_info->should_run() && test_info->result()->Skipped();
987 static bool TestFailed(
const TestInfo* test_info) {
988 return test_info->should_run() && test_info->result()->Failed();
993 static bool TestReportableDisabled(
const TestInfo* test_info) {
994 return test_info->is_reportable() && test_info->is_disabled_;
998 static bool TestDisabled(
const TestInfo* test_info) {
999 return test_info->is_disabled_;
1003 static bool TestReportable(
const TestInfo* test_info) {
1004 return test_info->is_reportable();
1008 static bool ShouldRunTest(
const TestInfo* test_info) {
1009 return test_info->should_run();
1013 void ShuffleTests(internal::Random* random);
1016 void UnshuffleTests();
1022 const std::unique_ptr<const ::std::string> type_param_;
1025 std::vector<TestInfo*> test_info_list_;
1029 std::vector<int> test_indices_;
1042 TestResult ad_hoc_test_result_;
1075 struct Setup_should_be_spelled_SetUp {};
1076 virtual Setup_should_be_spelled_SetUp* Setup() {
return nullptr; }
1079 #if GTEST_HAS_EXCEPTIONS
1083 :
public internal::GoogleTestFailureException {
1085 explicit AssertionException(
const TestPartResult& result)
1086 : GoogleTestFailureException(result) {}
1116 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1135 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1167 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1175 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1208 return default_result_printer_;
1219 return default_xml_generator_;
1225 friend class internal::DefaultGlobalTestPartResultReporter;
1226 friend class internal::NoExecDeathTest;
1227 friend class internal::TestEventListenersAccessor;
1228 friend class internal::UnitTestImpl;
1250 bool EventForwardingEnabled()
const;
1251 void SuppressEventForwarding();
1254 internal::TestEventRepeater* repeater_;
1291 const
char* original_working_dir() const;
1298 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1308 int random_seed() const;
1314 internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
1318 int successful_test_suite_count() const;
1321 int failed_test_suite_count() const;
1324 int total_test_suite_count() const;
1328 int test_suite_to_run_count() const;
1331 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1382 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
1410 void AddTestPartResult(TestPartResult::Type
result_type,
1411 const char* file_name,
1413 const std::string& message,
1414 const std::string& os_stack_trace)
1422 void RecordProperty(
const std::string& key,
const std::string& value);
1429 internal::UnitTestImpl* impl() {
return impl_; }
1430 const internal::UnitTestImpl* impl()
const {
return impl_; }
1437 friend class internal::StreamingListenerTest;
1438 friend class internal::UnitTestRecordPropertyTestHelper;
1440 friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();
1441 friend internal::UnitTestImpl* internal::GetUnitTestImpl();
1442 friend void internal::ReportFailureInUnknownLocation(
1444 const std::string& message);
1454 void PushGTestTrace(
const internal::TraceInfo& trace)
1458 void PopGTestTrace()
1463 mutable internal::Mutex mutex_;
1469 internal::UnitTestImpl* impl_;
1516 namespace internal {
1521 template <
typename T1,
typename T2>
1523 const char* rhs_expression,
1524 const T1& lhs,
const T2& rhs) {
1540 template <
typename T1,
typename T2>
1542 const char* rhs_expression,
1546 return AssertionSuccess();
1556 typename T1,
typename T2,
1559 typename std::enable_if<!std::is_integral<T1>::value ||
1560 !std::is_pointer<T2>::value>::type* =
nullptr>
1561 static AssertionResult
Compare(
const char* lhs_expression,
1562 const char* rhs_expression,
const T1& lhs,
1564 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
1573 static AssertionResult
Compare(
const char* lhs_expression,
1574 const char* rhs_expression,
1577 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
1580 template <
typename T>
1582 const char* lhs_expression,
const char* rhs_expression,
1584 std::nullptr_t , T* rhs) {
1586 return CmpHelperEQ(lhs_expression, rhs_expression,
static_cast<T*
>(
nullptr),
1594 template <
typename T1,
typename T2>
1596 const T1& val1,
const T2& val2,
1598 return AssertionFailure()
1599 <<
"Expected: (" << expr1 <<
") " << op <<
" (" << expr2
1610 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
1611 template <typename T1, typename T2>\
1612 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
1613 const T1& val1, const T2& val2) {\
1614 if (val1 op val2) {\
1615 return AssertionSuccess();\
1617 return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
1634 #undef GTEST_IMPL_CMP_HELPER_
1640 const char* s2_expression,
1648 const char* s2_expression,
1656 const char* s2_expression,
1664 const char* s2_expression,
1673 const char* s2_expression,
1681 const char* s2_expression,
1696 const char* needle_expr,
const char* haystack_expr,
1697 const char* needle,
const char* haystack);
1699 const char* needle_expr,
const char* haystack_expr,
1700 const wchar_t* needle,
const wchar_t* haystack);
1702 const char* needle_expr,
const char* haystack_expr,
1703 const char* needle,
const char* haystack);
1705 const char* needle_expr,
const char* haystack_expr,
1706 const wchar_t* needle,
const wchar_t* haystack);
1708 const char* needle_expr,
const char* haystack_expr,
1709 const ::std::string& needle, const ::std::string& haystack);
1711 const char* needle_expr,
const char* haystack_expr,
1712 const ::std::string& needle, const ::std::string& haystack);
1714 #if GTEST_HAS_STD_WSTRING
1716 const char* needle_expr,
const char* haystack_expr,
1717 const ::std::wstring& needle, const ::std::wstring& haystack);
1719 const char* needle_expr,
const char* haystack_expr,
1720 const ::std::wstring& needle, const ::std::wstring& haystack);
1723 namespace internal {
1732 template <
typename RawType>
1734 const char* rhs_expression,
1736 RawType rhs_value) {
1739 if (lhs.AlmostEquals(rhs)) {
1740 return AssertionSuccess();
1743 ::std::stringstream lhs_ss;
1744 lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1747 ::std::stringstream rhs_ss;
1748 rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1763 const char* abs_error_expr,
1776 const char* message);
1788 struct AssertHelperData {
1789 AssertHelperData(TestPartResult::Type t,
1790 const char* srcfile,
1793 : type(t), file(srcfile), line(line_num), message(msg) { }
1795 TestPartResult::Type
const type;
1796 const char*
const file;
1798 std::string
const message;
1804 AssertHelperData*
const data_;
1845 template <
typename T>
1855 <<
"GetParam() can only be called inside a value-parameterized test "
1856 <<
"-- did you intend to write TEST_P instead of TEST_F?";
1863 static void SetParam(
const ParamType* parameter) {
1864 parameter_ = parameter;
1868 static const ParamType* parameter_;
1874 template <
typename T>
1880 template <
typename T>
1889 #define GTEST_SKIP() GTEST_SKIP_("")
1909 #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
1913 #define ADD_FAILURE_AT(file, line) \
1914 GTEST_MESSAGE_AT_(file, line, "Failed", \
1915 ::testing::TestPartResult::kNonFatalFailure)
1918 #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
1921 #define GTEST_FAIL_AT(file, line) \
1922 GTEST_MESSAGE_AT_(file, line, "Failed", \
1923 ::testing::TestPartResult::kFatalFailure)
1927 #if !GTEST_DONT_DEFINE_FAIL
1928 # define FAIL() GTEST_FAIL()
1932 #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
1936 #if !GTEST_DONT_DEFINE_SUCCEED
1937 # define SUCCEED() GTEST_SUCCEED()
1949 #define EXPECT_THROW(statement, expected_exception) \
1950 GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
1951 #define EXPECT_NO_THROW(statement) \
1952 GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
1953 #define EXPECT_ANY_THROW(statement) \
1954 GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
1955 #define ASSERT_THROW(statement, expected_exception) \
1956 GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
1957 #define ASSERT_NO_THROW(statement) \
1958 GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
1959 #define ASSERT_ANY_THROW(statement) \
1960 GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
1965 #define EXPECT_TRUE(condition) \
1966 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
1967 GTEST_NONFATAL_FAILURE_)
1968 #define EXPECT_FALSE(condition) \
1969 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1970 GTEST_NONFATAL_FAILURE_)
1971 #define ASSERT_TRUE(condition) \
1972 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
1973 GTEST_FATAL_FAILURE_)
1974 #define ASSERT_FALSE(condition) \
1975 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
1976 GTEST_FATAL_FAILURE_)
2024 #define EXPECT_EQ(val1, val2) \
2025 EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
2026 #define EXPECT_NE(val1, val2) \
2027 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
2028 #define EXPECT_LE(val1, val2) \
2029 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
2030 #define EXPECT_LT(val1, val2) \
2031 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
2032 #define EXPECT_GE(val1, val2) \
2033 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
2034 #define EXPECT_GT(val1, val2) \
2035 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
2037 #define GTEST_ASSERT_EQ(val1, val2) \
2038 ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
2039 #define GTEST_ASSERT_NE(val1, val2) \
2040 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
2041 #define GTEST_ASSERT_LE(val1, val2) \
2042 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
2043 #define GTEST_ASSERT_LT(val1, val2) \
2044 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
2045 #define GTEST_ASSERT_GE(val1, val2) \
2046 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
2047 #define GTEST_ASSERT_GT(val1, val2) \
2048 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
2053 #if !GTEST_DONT_DEFINE_ASSERT_EQ
2054 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
2057 #if !GTEST_DONT_DEFINE_ASSERT_NE
2058 # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
2061 #if !GTEST_DONT_DEFINE_ASSERT_LE
2062 # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
2065 #if !GTEST_DONT_DEFINE_ASSERT_LT
2066 # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
2069 #if !GTEST_DONT_DEFINE_ASSERT_GE
2070 # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
2073 #if !GTEST_DONT_DEFINE_ASSERT_GT
2074 # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
2093 #define EXPECT_STREQ(s1, s2) \
2094 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
2095 #define EXPECT_STRNE(s1, s2) \
2096 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
2097 #define EXPECT_STRCASEEQ(s1, s2) \
2098 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
2099 #define EXPECT_STRCASENE(s1, s2)\
2100 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
2102 #define ASSERT_STREQ(s1, s2) \
2103 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
2104 #define ASSERT_STRNE(s1, s2) \
2105 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
2106 #define ASSERT_STRCASEEQ(s1, s2) \
2107 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
2108 #define ASSERT_STRCASENE(s1, s2)\
2109 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
2125 #define EXPECT_FLOAT_EQ(val1, val2)\
2126 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
2129 #define EXPECT_DOUBLE_EQ(val1, val2)\
2130 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
2133 #define ASSERT_FLOAT_EQ(val1, val2)\
2134 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
2137 #define ASSERT_DOUBLE_EQ(val1, val2)\
2138 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
2141 #define EXPECT_NEAR(val1, val2, abs_error)\
2142 EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
2143 val1, val2, abs_error)
2145 #define ASSERT_NEAR(val1, val2, abs_error)\
2146 ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
2147 val1, val2, abs_error)
2157 float val1,
float val2);
2159 double val1,
double val2);
2162 #if GTEST_OS_WINDOWS
2173 # define EXPECT_HRESULT_SUCCEEDED(expr) \
2174 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
2176 # define ASSERT_HRESULT_SUCCEEDED(expr) \
2177 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
2179 # define EXPECT_HRESULT_FAILED(expr) \
2180 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
2182 # define ASSERT_HRESULT_FAILED(expr) \
2183 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
2197 #define ASSERT_NO_FATAL_FAILURE(statement) \
2198 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
2199 #define EXPECT_NO_FATAL_FAILURE(statement) \
2200 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
2219 template <
typename T>
2221 PushTrace(file, line, (
Message() << message).GetString());
2226 PushTrace(file, line, message ? message :
"(null)");
2230 PushTrace(file, line, message);
2240 void PushTrace(
const char* file,
int line, std::string message);
2262 #define SCOPED_TRACE(message) \
2263 ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
2264 __FILE__, __LINE__, (message))
2296 template <
typename T1,
typename T2>
2298 static_assert(std::is_same<T1, T2>::value,
"T1 and T2 are not the same type");
2327 #define GTEST_TEST(test_suite_name, test_name) \
2328 GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
2329 ::testing::internal::GetTestTypeId())
2333 #if !GTEST_DONT_DEFINE_TEST
2334 #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
2364 #if !GTEST_DONT_DEFINE_TEST
2365 #define TEST_F(test_fixture, test_name)\
2366 GTEST_TEST_(test_fixture, test_name, test_fixture, \
2367 ::testing::internal::GetTypeId<test_fixture>())
2375 # pragma warning(pop)
2435 template <
int&... ExplicitParameterBarrier,
typename Factory>
2437 const char* type_param,
const char* value_param,
2438 const char* file,
int line, Factory factory) {
2439 using TestT =
typename std::remove_pointer<decltype(factory())>::type;
2443 explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
2444 Test* CreateTest()
override {
return factory_(); }
2451 test_suite_name, test_name, type_param, value_param,
2455 new FactoryImpl{std::move(factory)});
2471 return ::testing::UnitTest::GetInstance()->Run();
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1158
void OnTestStart(const TestInfo &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1171
void OnTestSuiteStart(const TestSuite &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1165
void OnTestIterationStart(const UnitTest &, int) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1161
void OnEnvironmentsTearDownStart(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1179
void OnEnvironmentsSetUpStart(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1163
void OnTestEnd(const TestInfo &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1173
void OnTestCaseStart(const TestCase &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1168
void OnEnvironmentsSetUpEnd(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1164
void OnTestProgramEnd(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1183
void OnTestIterationEnd(const UnitTest &, int) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1181
void OnTestPartResult(const TestPartResult &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1172
void OnTestCaseEnd(const TestCase &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1176
void OnTestProgramStart(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1160
void OnEnvironmentsTearDownEnd(const UnitTest &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1180
void OnTestSuiteEnd(const TestSuite &) override
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1174
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1062
virtual void TearDown()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1071
virtual ~Environment()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1065
virtual void SetUp()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1068
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest-message.h:91
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2212
ScopedTrace(const char *file, int line, const std::string &message)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2229
ScopedTrace(const char *file, int line, const T &message)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2220
ScopedTrace(const char *file, int line, const char *message)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2225
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1093
virtual void OnTestPartResult(const TestPartResult &test_part_result)=0
virtual void OnTestSuiteStart(const TestSuite &)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1113
virtual ~TestEventListener()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1095
virtual void OnEnvironmentsTearDownStart(const UnitTest &unit_test)=0
virtual void OnTestIterationEnd(const UnitTest &unit_test, int iteration)=0
virtual void OnTestProgramStart(const UnitTest &unit_test)=0
virtual void OnTestIterationStart(const UnitTest &unit_test, int iteration)=0
virtual void OnTestCaseEnd(const TestCase &)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1136
virtual void OnTestSuiteEnd(const TestSuite &)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1132
virtual void OnEnvironmentsTearDownEnd(const UnitTest &unit_test)=0
virtual void OnEnvironmentsSetUpStart(const UnitTest &unit_test)=0
virtual void OnEnvironmentsSetUpEnd(const UnitTest &unit_test)=0
virtual void OnTestStart(const TestInfo &test_info)=0
virtual void OnTestEnd(const TestInfo &test_info)=0
virtual void OnTestCaseStart(const TestCase &)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1117
virtual void OnTestProgramEnd(const UnitTest &unit_test)=0
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1187
void Append(TestEventListener *listener)
TestEventListener * Release(TestEventListener *listener)
TestEventListener * default_result_printer() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1207
TestEventListener * default_xml_generator() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1218
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:414
static bool HasNonfatalFailure()
static bool HasFatalFailure()
static void SetUpTestCase()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:441
static void TearDownTestSuite()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:435
static bool HasFailure()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:455
static void RecordProperty(const std::string &key, const std::string &value)
static void SetUpTestSuite()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:427
static void TearDownTestCase()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:440
static void RecordProperty(const std::string &key, int value)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:704
const char * test_case_name() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:715
bool is_reportable() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:763
const char * type_param() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:723
const char * test_suite_name() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:711
bool is_in_another_shard() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:742
bool should_run() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:760
const char * file() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:736
const char * value_param() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:730
const char * name() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:719
const TestResult * result() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:770
int line() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:739
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:534
TestProperty(const std::string &a_key, const std::string &a_value)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:539
void SetValue(const std::string &new_value)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:554
const char * value() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:549
const char * key() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:544
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:571
bool HasFatalFailure() const
const TestProperty & GetTestProperty(int i) const
bool HasNonfatalFailure() const
int total_part_count() const
TimeInMillis elapsed_time() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:602
const TestPartResult & GetTestPartResult(int i) const
bool Passed() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:587
TimeInMillis start_timestamp() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:606
int test_property_count() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:842
int test_to_run_count() const
int reportable_test_count() const
TestSuite(const char *name, const char *a_type_param, internal::SetUpTestSuiteFunc set_up_tc, internal::TearDownTestSuiteFunc tear_down_tc)
TimeInMillis elapsed_time() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:909
const TestResult & ad_hoc_test_result() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:921
int total_test_count() const
int successful_test_count() const
bool should_run() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:874
const TestInfo * GetTestInfo(int i) const
int failed_test_count() const
int reportable_disabled_test_count() const
const char * type_param() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:868
const char * name() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:864
TimeInMillis start_timestamp() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:913
int disabled_test_count() const
bool Passed() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:901
bool Failed() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:904
int skipped_test_count() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1881
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1274
int skipped_test_count() const
const TestInfo * current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_)
const TestCase * current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_)
TestEventListeners & listeners()
int reportable_disabled_test_count() const
int Run() GTEST_MUST_USE_RESULT_
TimeInMillis elapsed_time() const
int reportable_test_count() const
int test_to_run_count() const
int successful_test_count() const
const TestSuite * GetTestSuite(int i) const
int total_test_case_count() const
int test_case_to_run_count() const
TimeInMillis start_timestamp() const
int failed_test_case_count() const
int successful_test_case_count() const
int failed_test_count() const
int disabled_test_count() const
const TestCase * GetTestCase(int i) const
static UnitTest * GetInstance()
int total_test_count() const
const TestResult & ad_hoc_test_result() const
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1846
static const ParamType & GetParam()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1853
T ParamType
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1848
virtual ~WithParamInterface()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1849
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1770
void operator=(const Message &message) const
AssertHelper(TestPartResult::Type type, const char *file, int line, const char *message)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1552
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1561
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, std::nullptr_t, T *rhs)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1581
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, BiggestInt lhs, BiggestInt rhs)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1573
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:250
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-param-util.h:394
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:452
#define GTEST_IMPL_CMP_HELPER_(op_name, op)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1610
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2470
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) namespace testing
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:73
#define GTEST_DECLARE_bool_(name)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2198
#define GTEST_LOCK_EXCLUDED_(locks)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2217
#define GTEST_MUST_USE_RESULT_
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:716
#define GTEST_DECLARE_string_(name)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2201
#define GTEST_API_
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:775
#define GTEST_DECLARE_int32_(name)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2199
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:324
#define GTEST_CHECK_(condition)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:1004
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:693
typename std::result_of< Transformer(Input)>::type result_type
Determines the return type of applying a function on a input type.
Definition: patterns.h:105
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
void(*)() SetUpTestSuiteFunc
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:489
long long BiggestInt
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2133
int64_t TimeInMillis
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-port.h:2181
AssertionResult CmpHelperEQFailure(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1522
const void * TypeId
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:417
AssertionResult CmpHelperEQ(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1541
bool operator==(faketype, faketype)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1536
GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
GTEST_API_ AssertionResult CmpHelperSTRNE(const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
AssertionResult CmpHelperOpFailure(const char *expr1, const char *expr2, const T1 &val1, const T2 &val2, const char *op)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1595
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest-printers.h:413
GTEST_API_ TestInfo * MakeAndRegisterTestInfo(const char *test_suite_name, const char *name, const char *type_param, const char *value_param, CodeLocation code_location, TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, TearDownTestSuiteFunc tear_down_tc, TestFactoryBase *factory)
AssertionResult CmpHelperFloatingPointEQ(const char *lhs_expression, const char *rhs_expression, RawType lhs_value, RawType rhs_value)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1733
void(*)() TearDownTestSuiteFunc
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:490
GTEST_API_ AssertionResult EqFailure(const char *expected_expression, const char *actual_expression, const std::string &expected_value, const std::string &actual_value, bool ignoring_case)
GTEST_API_ AssertionResult CmpHelperSTREQ(const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
GTEST_API_ AssertionResult DoubleNearPredFormat(const char *expr1, const char *expr2, const char *abs_error_expr, double val1, double val2, double abs_error)
bool operator!=(faketype, faketype)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1537
Definition: cmake-build-debug/googletest-src/googlemock/include/gmock/gmock-actions.h:154
Environment * AddGlobalTestEnvironment(Environment *env)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1493
std::ostream & operator<<(std::ostream &os, const Message &sb)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest-message.h:199
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)
constexpr bool StaticAssertTypeEq() noexcept
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2297
GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
TestInfo * RegisterTest(const char *test_suite_name, const char *test_name, const char *type_param, const char *value_param, const char *file, int line, Factory factory)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:2436
internal::TimeInMillis TimeInMillis
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:528
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const char *needle, const char *haystack)
GTEST_API_ std::string TempDir()
class GTEST_API_ testing::ScopedTrace GTEST_ATTRIBUTE_UNUSED_
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:492
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/internal/gtest-internal.h:515
Definition: cmake-build-debug/googletest-src/googletest/include/gtest/gtest.h:1535