52 #ifndef GTEST_INCLUDE_GTEST_GTEST_H_ 53 #define GTEST_INCLUDE_GTEST_GTEST_H_ 59 #include <type_traits> 81 # pragma warning(push) 82 # pragma warning(disable:4805) 83 # pragma warning(disable:4100) 155 #if GTEST_USE_OWN_FLAGFILE_FLAG_ 157 #endif // GTEST_USE_OWN_FLAGFILE_FLAG_ 160 const int kMaxStackTraceDepth = 100;
165 class DefaultGlobalTestPartResultReporter;
167 class NoExecDeathTest;
168 class FinalSuccessChecker;
169 class GTestFlagSaver;
170 class StreamingListenerTest;
171 class TestResultAccessor;
172 class TestEventListenersAccessor;
173 class TestEventRepeater;
174 class UnitTestRecordPropertyTestHelper;
175 class WindowsDeathTest;
176 class FuchsiaDeathTest;
177 class UnitTestImpl* GetUnitTestImpl();
190 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 279 AssertionResult(
const AssertionResult& other);
281 #if defined(_MSC_VER) && _MSC_VER < 1910 292 template <
typename T>
293 explicit AssertionResult(
295 typename internal::EnableIf<
299 : success_(success) {}
301 #if defined(_MSC_VER) && _MSC_VER < 1910 306 AssertionResult& operator=(AssertionResult other) {
312 operator bool()
const {
return success_; }
315 AssertionResult operator!()
const;
322 return message_.get() !=
nullptr ? message_->c_str() :
"";
325 const char* failure_message()
const {
return message(); }
329 AppendMessage(Message() << value);
336 ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
337 AppendMessage(Message() << basic_manipulator);
343 void AppendMessage(
const Message& a_message) {
344 if (message_.get() ==
nullptr) message_.reset(new ::std::string);
345 message_->append(a_message.GetString().c_str());
349 void swap(AssertionResult& other);
357 std::unique_ptr< ::std::string> message_;
426 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 429 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 432 static bool HasFatalFailure();
435 static bool HasNonfatalFailure();
438 static bool IsSkipped();
442 static bool HasFailure() {
return HasFatalFailure() || HasNonfatalFailure(); }
457 static void RecordProperty(
const std::string& key,
const std::string&
value);
458 static void RecordProperty(
const std::string& key,
int value);
465 virtual void SetUp();
468 virtual void TearDown();
473 static bool HasSameFixtureClass();
481 virtual void TestBody() = 0;
488 void DeleteSelf_() {
delete this; }
490 const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
508 struct Setup_should_be_spelled_SetUp {};
509 virtual Setup_should_be_spelled_SetUp* Setup() {
return nullptr; }
527 key_(a_key), value_(a_value) {
537 return value_.c_str();
568 int total_part_count()
const;
571 int test_property_count()
const;
574 bool Passed()
const {
return !Skipped() && !Failed(); }
577 bool Skipped()
const;
583 bool HasFatalFailure()
const;
586 bool HasNonfatalFailure()
const;
593 const TestPartResult& GetTestPartResult(
int i)
const;
604 friend class internal::DefaultGlobalTestPartResultReporter;
605 friend class internal::ExecDeathTest;
606 friend class internal::TestResultAccessor;
607 friend class internal::UnitTestImpl;
608 friend class internal::WindowsDeathTest;
609 friend class internal::FuchsiaDeathTest;
612 const std::vector<TestPartResult>& test_part_results()
const {
613 return test_part_results_;
617 const std::vector<TestProperty>& test_properties()
const {
618 return test_properties_;
622 void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
630 void RecordProperty(
const std::string& xml_element,
636 static bool ValidateTestProperty(
const std::string& xml_element,
640 void AddTestPartResult(
const TestPartResult& test_part_result);
643 int death_test_count()
const {
return death_test_count_; }
646 int increment_death_test_count() {
return ++death_test_count_; }
649 void ClearTestPartResults();
659 std::vector<TestPartResult> test_part_results_;
661 std::vector<TestProperty> test_properties_;
663 int death_test_count_;
665 TimeInMillis elapsed_time_;
692 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 694 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 697 const char*
name()
const {
return name_.c_str(); }
702 if (type_param_.get() !=
nullptr)
return type_param_->c_str();
709 if (value_param_.get() !=
nullptr)
return value_param_->c_str();
714 const char*
file()
const {
return location_.file.c_str(); }
717 int line()
const {
return location_.line; }
744 return matches_filter_ && !is_in_another_shard_;
751 #if GTEST_HAS_DEATH_TEST 752 friend class internal::DefaultDeathTestFactory;
753 #endif // GTEST_HAS_DEATH_TEST 756 friend class internal::UnitTestImpl;
757 friend class internal::StreamingListenerTest;
759 const char* test_suite_name,
const char* name,
const char* type_param,
767 TestInfo(
const std::string& test_suite_name,
const std::string& name,
768 const char* a_type_param,
769 const char* a_value_param,
776 int increment_death_test_count() {
777 return result_.increment_death_test_count();
784 static void ClearTestResult(
TestInfo* test_info) {
785 test_info->result_.Clear();
789 const std::string test_suite_name_;
790 const std::string name_;
793 const std::unique_ptr<const ::std::string> type_param_;
796 const std::unique_ptr<const ::std::string> value_param_;
801 bool matches_filter_;
803 bool is_in_another_shard_;
831 TestSuite(
const char* name,
const char* a_type_param,
839 const char*
name()
const {
return name_.c_str(); }
844 if (type_param_.get() !=
nullptr)
return type_param_->c_str();
852 int successful_test_count()
const;
855 int skipped_test_count()
const;
858 int failed_test_count()
const;
861 int reportable_disabled_test_count()
const;
864 int disabled_test_count()
const;
867 int reportable_test_count()
const;
870 int test_to_run_count()
const;
873 int total_test_count()
const;
876 bool Passed()
const {
return !Failed(); }
879 bool Failed()
const {
return failed_test_count() > 0; }
886 const TestInfo* GetTestInfo(
int i)
const;
894 friend class internal::UnitTestImpl;
897 std::vector<TestInfo*>& test_info_list() {
return test_info_list_; }
900 const std::vector<TestInfo*>& test_info_list()
const {
901 return test_info_list_;
906 TestInfo* GetMutableTestInfo(
int i);
909 void set_should_run(
bool should) { should_run_ = should; }
913 void AddTestInfo(
TestInfo * test_info);
919 static void ClearTestSuiteResult(
TestSuite* test_suite) {
920 test_suite->ClearResult();
928 void RunSetUpTestSuite() {
929 if (set_up_tc_ !=
nullptr) {
936 void RunTearDownTestSuite() {
937 if (tear_down_tc_ !=
nullptr) {
943 static bool TestPassed(
const TestInfo* test_info) {
948 static bool TestSkipped(
const TestInfo* test_info) {
953 static bool TestFailed(
const TestInfo* test_info) {
959 static bool TestReportableDisabled(
const TestInfo* test_info) {
960 return test_info->
is_reportable() && test_info->is_disabled_;
964 static bool TestDisabled(
const TestInfo* test_info) {
965 return test_info->is_disabled_;
969 static bool TestReportable(
const TestInfo* test_info) {
974 static bool ShouldRunTest(
const TestInfo* test_info) {
982 void UnshuffleTests();
988 const std::unique_ptr<const ::std::string> type_param_;
991 std::vector<TestInfo*> test_info_list_;
995 std::vector<int> test_indices_;
1003 TimeInMillis elapsed_time_;
1039 struct Setup_should_be_spelled_SetUp {};
1040 virtual Setup_should_be_spelled_SetUp* Setup() {
return nullptr; }
1043 #if GTEST_HAS_EXCEPTIONS 1047 :
public internal::GoogleTestFailureException {
1049 explicit AssertionException(
const TestPartResult& result)
1050 : GoogleTestFailureException(result) {}
1053 #endif // GTEST_HAS_EXCEPTIONS 1062 virtual void OnTestProgramStart(
const UnitTest& unit_test) = 0;
1067 virtual void OnTestIterationStart(
const UnitTest& unit_test,
1071 virtual void OnEnvironmentsSetUpStart(
const UnitTest& unit_test) = 0;
1074 virtual void OnEnvironmentsSetUpEnd(
const UnitTest& unit_test) = 0;
1080 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1082 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1085 virtual void OnTestStart(
const TestInfo& test_info) = 0;
1090 virtual void OnTestPartResult(
const TestPartResult& test_part_result) = 0;
1093 virtual void OnTestEnd(
const TestInfo& test_info) = 0;
1099 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1101 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1104 virtual void OnEnvironmentsTearDownStart(
const UnitTest& unit_test) = 0;
1107 virtual void OnEnvironmentsTearDownEnd(
const UnitTest& unit_test) = 0;
1110 virtual void OnTestIterationEnd(
const UnitTest& unit_test,
1114 virtual void OnTestProgramEnd(
const UnitTest& unit_test) = 0;
1131 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1133 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1139 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1141 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1172 return default_result_printer_;
1183 return default_xml_generator_;
1189 friend class internal::DefaultGlobalTestPartResultReporter;
1190 friend class internal::NoExecDeathTest;
1192 friend class internal::UnitTestImpl;
1214 bool EventForwardingEnabled()
const;
1215 void SuppressEventForwarding();
1255 const char* original_working_dir()
const;
1262 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1268 const TestInfo* current_test_info()
const 1272 int random_seed()
const;
1282 int successful_test_suite_count()
const;
1285 int failed_test_suite_count()
const;
1288 int total_test_suite_count()
const;
1292 int test_suite_to_run_count()
const;
1295 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1296 int successful_test_case_count()
const;
1297 int failed_test_case_count()
const;
1298 int total_test_case_count()
const;
1299 int test_case_to_run_count()
const;
1300 #endif // EMOVE_LEGACY_TEST_CASEAPI 1303 int successful_test_count()
const;
1306 int skipped_test_count()
const;
1309 int failed_test_count()
const;
1312 int reportable_disabled_test_count()
const;
1315 int disabled_test_count()
const;
1318 int reportable_test_count()
const;
1321 int total_test_count()
const;
1324 int test_to_run_count()
const;
1328 TimeInMillis start_timestamp()
const;
1331 TimeInMillis elapsed_time()
const;
1334 bool Passed()
const;
1338 bool Failed()
const;
1342 const TestSuite* GetTestSuite(
int i)
const;
1345 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1346 const TestCase* GetTestCase(
int i)
const;
1347 #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ 1351 const TestResult& ad_hoc_test_result()
const;
1373 void AddTestPartResult(TestPartResult::Type result_type,
1374 const char* file_name,
1377 const std::string& os_stack_trace)
1385 void RecordProperty(
const std::string& key,
const std::string&
value);
1392 internal::UnitTestImpl* impl() {
return impl_; }
1393 const internal::UnitTestImpl* impl()
const {
return impl_; }
1400 friend class internal::StreamingListenerTest;
1403 friend internal::UnitTestImpl* internal::GetUnitTestImpl();
1405 TestPartResult::Type result_type,
1406 const std::string& message);
1416 void PushGTestTrace(
const internal::TraceInfo& trace)
1420 void PopGTestTrace()
1421 GTEST_LOCK_EXCLUDED_(mutex_);
1425 mutable internal::Mutex mutex_;
1431 internal::UnitTestImpl* impl_;
1456 return UnitTest::GetInstance()->AddEnvironment(env);
1478 namespace internal {
1483 template <
typename T1,
typename T2>
1485 const char* rhs_expression,
1486 const T1& lhs,
const T2& rhs) {
1502 template <
typename T1,
typename T2>
1504 const char* rhs_expression,
1518 const char* rhs_expression,
1526 typename T1,
typename T2,
1531 static AssertionResult
Compare(
const char* lhs_expression,
1532 const char* rhs_expression,
const T1& lhs,
1534 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
1543 static AssertionResult
Compare(
const char* lhs_expression,
1544 const char* rhs_expression,
1547 return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
1550 template <
typename T>
1552 const char* lhs_expression,
const char* rhs_expression,
1554 std::nullptr_t , T* rhs) {
1556 return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(
nullptr),
1564 template <
typename T1,
typename T2>
1566 const T1& val1,
const T2& val2,
1569 <<
"Expected: (" << expr1 <<
") " << op <<
" (" << expr2
1585 #define GTEST_IMPL_CMP_HELPER_(op_name, op)\ 1586 template <typename T1, typename T2>\ 1587 AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ 1588 const T1& val1, const T2& val2) {\ 1589 if (val1 op val2) {\ 1590 return AssertionSuccess();\ 1592 return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\ 1595 GTEST_API_ AssertionResult CmpHelper##op_name(\ 1596 const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) 1611 #undef GTEST_IMPL_CMP_HELPER_ 1617 const char* s2_expression,
1625 const char* s2_expression,
1633 const char* s2_expression,
1641 const char* s2_expression,
1650 const char* s2_expression,
1658 const char* s2_expression,
1673 const char* needle_expr,
const char* haystack_expr,
1674 const char* needle,
const char* haystack);
1676 const char* needle_expr,
const char* haystack_expr,
1677 const wchar_t* needle,
const wchar_t* haystack);
1679 const char* needle_expr,
const char* haystack_expr,
1680 const char* needle,
const char* haystack);
1682 const char* needle_expr,
const char* haystack_expr,
1683 const wchar_t* needle,
const wchar_t* haystack);
1685 const char* needle_expr,
const char* haystack_expr,
1686 const ::std::string& needle, const ::std::string& haystack);
1688 const char* needle_expr,
const char* haystack_expr,
1689 const ::std::string& needle, const ::std::string& haystack);
1691 #if GTEST_HAS_STD_WSTRING 1693 const char* needle_expr,
const char* haystack_expr,
1694 const ::std::wstring& needle, const ::std::wstring& haystack);
1696 const char* needle_expr,
const char* haystack_expr,
1697 const ::std::wstring& needle, const ::std::wstring& haystack);
1698 #endif // GTEST_HAS_STD_WSTRING 1700 namespace internal {
1709 template <
typename RawType>
1711 const char* rhs_expression,
1713 RawType rhs_value) {
1716 if (lhs.AlmostEquals(rhs)) {
1720 ::std::stringstream lhs_ss;
1721 lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1724 ::std::stringstream rhs_ss;
1725 rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
1740 const char* abs_error_expr,
1753 const char* message);
1758 void operator=(
const Message& message)
const;
1765 struct AssertHelperData {
1766 AssertHelperData(TestPartResult::Type
t,
1767 const char* srcfile,
1770 :
type(t), file(srcfile), line(line_num),
message(msg) { }
1772 TestPartResult::Type
const type;
1773 const char*
const file;
1781 AssertHelperData*
const data_;
1828 template <
typename T>
1838 <<
"GetParam() can only be called inside a value-parameterized test " 1839 <<
"-- did you intend to write TEST_P instead of TEST_F?";
1846 static void SetParam(
const ParamType* parameter) {
1847 parameter_ = parameter;
1851 static const ParamType* parameter_;
1857 template <
typename T>
1863 template <
typename T>
1872 #define GTEST_SKIP() GTEST_SKIP_("Skipped") 1892 #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed") 1896 #define ADD_FAILURE_AT(file, line) \ 1897 GTEST_MESSAGE_AT_(file, line, "Failed", \ 1898 ::testing::TestPartResult::kNonFatalFailure) 1901 #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed") 1904 #define GTEST_FAIL_AT(file, line) \ 1905 GTEST_MESSAGE_AT_(file, line, "Failed", \ 1906 ::testing::TestPartResult::kFatalFailure) 1910 #if !GTEST_DONT_DEFINE_FAIL 1911 # define FAIL() GTEST_FAIL() 1915 #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded") 1919 #if !GTEST_DONT_DEFINE_SUCCEED 1920 # define SUCCEED() GTEST_SUCCEED() 1932 #define EXPECT_THROW(statement, expected_exception) \ 1933 GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_) 1934 #define EXPECT_NO_THROW(statement) \ 1935 GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_) 1936 #define EXPECT_ANY_THROW(statement) \ 1937 GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_) 1938 #define ASSERT_THROW(statement, expected_exception) \ 1939 GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) 1940 #define ASSERT_NO_THROW(statement) \ 1941 GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) 1942 #define ASSERT_ANY_THROW(statement) \ 1943 GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) 1948 #define EXPECT_TRUE(condition) \ 1949 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ 1950 GTEST_NONFATAL_FAILURE_) 1951 #define EXPECT_FALSE(condition) \ 1952 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ 1953 GTEST_NONFATAL_FAILURE_) 1954 #define ASSERT_TRUE(condition) \ 1955 GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ 1956 GTEST_FATAL_FAILURE_) 1957 #define ASSERT_FALSE(condition) \ 1958 GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ 1959 GTEST_FATAL_FAILURE_) 2007 #define EXPECT_EQ(val1, val2) \ 2008 EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) 2009 #define EXPECT_NE(val1, val2) \ 2010 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) 2011 #define EXPECT_LE(val1, val2) \ 2012 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) 2013 #define EXPECT_LT(val1, val2) \ 2014 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) 2015 #define EXPECT_GE(val1, val2) \ 2016 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) 2017 #define EXPECT_GT(val1, val2) \ 2018 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) 2020 #define GTEST_ASSERT_EQ(val1, val2) \ 2021 ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2) 2022 #define GTEST_ASSERT_NE(val1, val2) \ 2023 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) 2024 #define GTEST_ASSERT_LE(val1, val2) \ 2025 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) 2026 #define GTEST_ASSERT_LT(val1, val2) \ 2027 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) 2028 #define GTEST_ASSERT_GE(val1, val2) \ 2029 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) 2030 #define GTEST_ASSERT_GT(val1, val2) \ 2031 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) 2036 #if !GTEST_DONT_DEFINE_ASSERT_EQ 2037 # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) 2040 #if !GTEST_DONT_DEFINE_ASSERT_NE 2041 # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) 2044 #if !GTEST_DONT_DEFINE_ASSERT_LE 2045 # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) 2048 #if !GTEST_DONT_DEFINE_ASSERT_LT 2049 # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) 2052 #if !GTEST_DONT_DEFINE_ASSERT_GE 2053 # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) 2056 #if !GTEST_DONT_DEFINE_ASSERT_GT 2057 # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) 2076 #define EXPECT_STREQ(s1, s2) \ 2077 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) 2078 #define EXPECT_STRNE(s1, s2) \ 2079 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) 2080 #define EXPECT_STRCASEEQ(s1, s2) \ 2081 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) 2082 #define EXPECT_STRCASENE(s1, s2)\ 2083 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) 2085 #define ASSERT_STREQ(s1, s2) \ 2086 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2) 2087 #define ASSERT_STRNE(s1, s2) \ 2088 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) 2089 #define ASSERT_STRCASEEQ(s1, s2) \ 2090 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2) 2091 #define ASSERT_STRCASENE(s1, s2)\ 2092 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) 2108 #define EXPECT_FLOAT_EQ(val1, val2)\ 2109 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \ 2112 #define EXPECT_DOUBLE_EQ(val1, val2)\ 2113 EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \ 2116 #define ASSERT_FLOAT_EQ(val1, val2)\ 2117 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \ 2120 #define ASSERT_DOUBLE_EQ(val1, val2)\ 2121 ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \ 2124 #define EXPECT_NEAR(val1, val2, abs_error)\ 2125 EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ 2126 val1, val2, abs_error) 2128 #define ASSERT_NEAR(val1, val2, abs_error)\ 2129 ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ 2130 val1, val2, abs_error) 2140 float val1,
float val2);
2142 double val1,
double val2);
2145 #if GTEST_OS_WINDOWS 2156 # define EXPECT_HRESULT_SUCCEEDED(expr) \ 2157 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) 2159 # define ASSERT_HRESULT_SUCCEEDED(expr) \ 2160 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) 2162 # define EXPECT_HRESULT_FAILED(expr) \ 2163 EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) 2165 # define ASSERT_HRESULT_FAILED(expr) \ 2166 ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) 2168 #endif // GTEST_OS_WINDOWS 2180 #define ASSERT_NO_FATAL_FAILURE(statement) \ 2181 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_) 2182 #define EXPECT_NO_FATAL_FAILURE(statement) \ 2183 GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) 2202 template <
typename T>
2204 PushTrace(file, line, (
Message() << message).GetString());
2209 PushTrace(file, line, message ? message :
"(null)");
2213 PushTrace(file, line, message);
2223 void PushTrace(
const char* file,
int line, std::string
message);
2245 #define SCOPED_TRACE(message) \ 2246 ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ 2247 __FILE__, __LINE__, (message)) 2280 template <
typename T1,
typename T2>
2311 #define GTEST_TEST(test_suite_name, test_name) \ 2312 GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \ 2313 ::testing::internal::GetTestTypeId()) 2317 #if !GTEST_DONT_DEFINE_TEST 2318 #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name) 2348 #define TEST_F(test_fixture, test_name)\ 2349 GTEST_TEST_(test_fixture, test_name, test_fixture, \ 2350 ::testing::internal::GetTypeId<test_fixture>()) 2357 # pragma warning(pop) 2417 template <
int&... ExplicitParameterBarrier,
typename Factory>
2419 const char* type_param,
const char* value_param,
2420 const char* file,
int line, Factory factory) {
2425 explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
2426 Test* CreateTest()
override {
return factory_(); }
2433 test_suite_name, test_name, type_param, value_param,
2437 new FactoryImpl{std::move(factory)});
2453 return ::testing::UnitTest::GetInstance()->Run();
2458 #endif // GTEST_INCLUDE_GTEST_GTEST_H_ const char * file() const
Definition: gtest.h:714
void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string &message)
Definition: gtest.cc:2295
Environment * AddGlobalTestEnvironment(Environment *env)
Definition: gtest.h:1455
virtual void SetUp()
Definition: gtest.h:1032
Definition: gmock-actions.h:59
static void SetUpTestCase()
Definition: gtest.h:428
virtual void OnTestCaseStart(const TestCase &)
Definition: gtest.h:1081
AssertionResult AssertionFailure()
Definition: gtest.cc:1028
#define GTEST_DECLARE_bool_(name)
Definition: gtest-port.h:2237
Definition: gtest_unittest.cc:152
virtual ~TestEventListener()
Definition: gtest.h:1059
#define GTEST_ATTRIBUTE_UNUSED_
Definition: gtest-port.h:660
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition: gtest-port.h:314
bool operator==(faketype, faketype)
Definition: gtest.h:1498
bool should_run() const
Definition: gtest.h:849
GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: gtest.cc:1516
tuple message
Definition: googletest-output-test.py:337
Definition: gtest-internal.h:503
GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char *s1_expression, const char *s2_expression, const char *s1, const char *s2)
Definition: gtest.cc:1546
bool operator!=(faketype, faketype)
Definition: gtest.h:1499
const char * key() const
Definition: gtest.h:531
void OnTestCaseStart(const TestCase &) override
Definition: gtest.h:1132
static bool HasFailure()
Definition: gtest.h:442
GTEST_API_ AssertionResult CmpHelperEQ(const char *lhs_expression, const char *rhs_expression, BiggestInt lhs, BiggestInt rhs)
Definition: gtest.cc:1450
void ColoredPrintf(GTestColor color, const char *fmt,...)
Definition: gtest.cc:3042
Definition: gtest-internal.h:833
TestEventListener * default_xml_generator() const
Definition: gtest.h:1182
GTEST_API_ AssertionResult DoubleNearPredFormat(const char *expr1, const char *expr2, const char *abs_error_expr, double val1, double val2, double abs_error)
Definition: gtest.cc:1377
GTestColor
Definition: gtest.h:1786
void OnEnvironmentsSetUpEnd(const UnitTest &) override
Definition: gtest.h:1128
void OnTestEnd(const TestInfo &) override
Definition: gtest.h:1137
const char * name() const
Definition: gtest.h:839
void OnTestIterationStart(const UnitTest &, int) override
Definition: gtest.h:1125
#define GTEST_API_
Definition: gtest-port.h:759
bool Failed() const
Definition: gtest.h:879
std::string FormatForComparisonFailureMessage(const T1 &value, const T2 &)
Definition: gtest-printers.h:376
GTEST_API_ AssertionResult IsNotSubstring(const char *needle_expr, const char *haystack_expr, const ::std::string &needle, const ::std::string &haystack)
Definition: gtest.cc:1647
TypeWithSize< 8 >::Int TimeInMillis
Definition: gtest-port.h:2220
std::ostream & operator<<(std::ostream &os, const Message &sb)
Definition: gtest-message.h:198
int i
Definition: gmock-matchers_test.cc:711
#define GTEST_LOCK_EXCLUDED_(locks)
Definition: gtest-port.h:2256
clear all close all load ct GNMSLog0 mat reformat t
GTEST_API_ AssertionResult IsSubstring(const char *needle_expr, const char *haystack_expr, const ::std::string &needle, const ::std::string &haystack)
Definition: gtest.cc:1641
void(*)( TearDownTestSuiteFunc)
Definition: gtest-internal.h:478
Definition: gtest-message.h:90
Definition: gtest-internal.h:440
void SetValue(const std::string &new_value)
Definition: gtest.h:541
bool Skipped() const
Definition: gtest.cc:2210
internal::TimeInMillis TimeInMillis
Definition: gtest.h:515
void OnTestStart(const TestInfo &) override
Definition: gtest.h:1135
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, BiggestInt lhs, BiggestInt rhs)
Definition: gtest.h:1543
const void * TypeId
Definition: gtest-internal.h:405
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, std::nullptr_t, T *rhs)
Definition: gtest.h:1551
#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check)
Definition: gtest-port.h:677
AssertionResult CmpHelperFloatingPointEQ(const char *lhs_expression, const char *rhs_expression, RawType lhs_value, RawType rhs_value)
Definition: gtest.h:1710
void OnTestCaseEnd(const TestCase &) override
Definition: gtest.h:1140
TestCase
Definition: gmock_test_utils.py:97
bool Failed() const
Definition: gtest.cc:2215
Definition: gtest-internal.h:480
#define GTEST_IMPL_CMP_HELPER_(op_name, op)
Definition: gtest.h:1585
void OnEnvironmentsSetUpStart(const UnitTest &) override
Definition: gtest.h:1127
void OnTestSuiteStart(const TestSuite &) override
Definition: gtest.h:1129
GTEST_API_ const char * fmt
Definition: gtest.h:1789
Definition: gtest_unittest.cc:176
bool is_reportable() const
Definition: gtest.h:741
const char * name() const
Definition: gtest.h:697
AssertionResult AssertionSuccess()
Definition: gtest.cc:1023
void OnTestProgramStart(const UnitTest &) override
Definition: gtest.h:1124
bool Passed() const
Definition: gtest.h:574
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)
Definition: gtest.cc:2595
GTEST_API_ AssertionResult CmpHelperSTRNE(const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
Definition: gtest.cc:1899
#define GTEST_CHECK_(condition)
Definition: gtest-port.h:1014
Definition: gtest-param-util.h:392
#define GTEST_DECLARE_int32_(name)
Definition: gtest-port.h:2238
static void TearDownTestSuite()
Definition: gtest.h:423
Definition: gtest-port.h:1880
bool Passed() const
Definition: gtest.h:876
AssertionResult CmpHelperOpFailure(const char *expr1, const char *expr2, const T1 &val1, const T2 &val2, const char *op)
Definition: gtest.h:1565
const char * type_param() const
Definition: gtest.h:843
Definition: gtest.cc:3359
virtual void OnTestSuiteEnd(const TestSuite &)
Definition: gtest.h:1096
Definition: gtest-port.h:865
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: gtest.h:2418
void OnTestPartResult(const TestPartResult &) override
Definition: gtest.h:1136
long long BiggestInt
Definition: gtest-port.h:1964
virtual void OnTestSuiteStart(const TestSuite &)
Definition: gtest.h:1077
Definition: gtest-param-util.h:654
const char * value_param() const
Definition: gtest.h:708
GTEST_API_ AssertionResult CmpHelperSTREQ(const char *s1_expression, const char *s2_expression, const wchar_t *s1, const wchar_t *s2)
Definition: gtest.cc:1883
virtual ~WithParamInterface()
Definition: gtest.h:1832
const char * test_case_name() const
Definition: gtest.h:693
#define GTEST_DECLARE_string_(name)
Definition: gtest-port.h:2240
Definition: gtest-internal.h:238
virtual ~Environment()
Definition: gtest.h:1029
int value
Definition: gmock-matchers_test.cc:657
const char * test_suite_name() const
Definition: gtest.h:689
output
Definition: gmock_output_test.py:173
AssertionResult CmpHelperEQFailure(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: gtest.h:1484
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)
Definition: gtest.cc:1326
type
Definition: upload.py:443
TestProperty(const std::string &a_key, const std::string &a_value)
Definition: gtest.h:526
ScopedTrace(const char *file, int line, const T &message)
Definition: gtest.h:2203
#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)
Definition: gtest-port.h:688
void OnTestProgramEnd(const UnitTest &) override
Definition: gtest.h:1147
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
Definition: gtest.cc:1999
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition: gtest.h:2452
bool StaticAssertTypeEq()
Definition: gtest.h:2281
virtual void OnTestCaseEnd(const TestCase &)
Definition: gtest.h:1100
GTEST_API_ AssertionResult DoubleLE(const char *expr1, const char *expr2, double val1, double val2)
Definition: gtest.cc:1441
static const ParamType & GetParam()
Definition: gtest.h:1836
const TestResult * result() const
Definition: gtest.h:748
static AssertionResult Compare(const char *lhs_expression, const char *rhs_expression, const T1 &lhs, const T2 &rhs)
Definition: gtest.h:1531
static void SetUpTestSuite()
Definition: gtest.h:415
GTEST_API_ void InitGoogleTest()
Definition: gtest.cc:6069
TestEventListener * default_result_printer() const
Definition: gtest.h:1171
void(*)( SetUpTestSuiteFunc)
Definition: gtest-internal.h:477
const char * type_param() const
Definition: gtest.h:701
bool should_run() const
Definition: gtest.h:738
void OnTestSuiteEnd(const TestSuite &) override
Definition: gtest.h:1138
void OnTestIterationEnd(const UnitTest &, int) override
Definition: gtest.h:1145
def Run(command)
Definition: googletest-break-on-failure-unittest.py:76
const char * value() const
Definition: gtest.h:536
ScopedTrace(const char *file, int line, const char *message)
Definition: gtest.h:2208
TimeInMillis elapsed_time() const
Definition: gtest.h:882
const TestResult & ad_hoc_test_result() const
Definition: gtest.h:890
int line() const
Definition: gtest.h:717
bool is_in_another_shard() const
Definition: gtest.h:720
T ParamType
Definition: gtest.h:1831
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251) namespace testing
Definition: gtest.h:73
void OnEnvironmentsTearDownStart(const UnitTest &) override
Definition: gtest.h:1143
static void TearDownTestCase()
Definition: gtest.h:427
#define GTEST_MUST_USE_RESULT_
Definition: gtest-port.h:700
void OnEnvironmentsTearDownEnd(const UnitTest &) override
Definition: gtest.h:1144
virtual void TearDown()
Definition: gtest.h:1035
GTEST_API_ AssertionResult FloatLE(const char *expr1, const char *expr2, float val1, float val2)
Definition: gtest.cc:1434
ScopedTrace(const char *file, int line, const std::string &message)
Definition: gtest.h:2212
GTEST_API_ std::string TempDir()
Definition: gtest.cc:6083
TimeInMillis elapsed_time() const
Definition: gtest.h:589