12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495 |
- #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_H_
- #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_
- #include <cstddef>
- #include <limits>
- #include <memory>
- #include <ostream>
- #include <type_traits>
- #include <vector>
- #include "gtest/internal/gtest-internal.h"
- #include "gtest/internal/gtest-string.h"
- #include "gtest/gtest-death-test.h"
- #include "gtest/gtest-matchers.h"
- #include "gtest/gtest-message.h"
- #include "gtest/gtest-param-test.h"
- #include "gtest/gtest-printers.h"
- #include "gtest/gtest_prod.h"
- #include "gtest/gtest-test-part.h"
- #include "gtest/gtest-typed-test.h"
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
- )
- namespace testing {
- #ifdef _MSC_VER
- # pragma warning(push)
- # pragma warning(disable:4805)
- # pragma warning(disable:4100)
- #endif
- GTEST_DECLARE_bool_(also_run_disabled_tests);
- GTEST_DECLARE_bool_(break_on_failure);
- GTEST_DECLARE_bool_(catch_exceptions);
- GTEST_DECLARE_string_(color);
- GTEST_DECLARE_bool_(fail_fast);
- GTEST_DECLARE_string_(filter);
- GTEST_DECLARE_bool_(install_failure_signal_handler);
- GTEST_DECLARE_bool_(list_tests);
- GTEST_DECLARE_string_(output);
- GTEST_DECLARE_bool_(brief);
- GTEST_DECLARE_bool_(print_time);
- GTEST_DECLARE_bool_(print_utf8);
- GTEST_DECLARE_int32_(random_seed);
- GTEST_DECLARE_int32_(repeat);
- GTEST_DECLARE_bool_(show_internal_stack_frames);
- GTEST_DECLARE_bool_(shuffle);
- GTEST_DECLARE_int32_(stack_trace_depth);
- GTEST_DECLARE_bool_(throw_on_failure);
- GTEST_DECLARE_string_(stream_result_to);
- #if GTEST_USE_OWN_FLAGFILE_FLAG_
- GTEST_DECLARE_string_(flagfile);
- #endif
- const int 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();
- }
- class Test;
- class TestSuite;
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- using TestCase = TestSuite;
- #endif
- class TestInfo;
- class UnitTest;
- class GTEST_API_ AssertionResult {
- public:
-
-
- AssertionResult(const AssertionResult& other);
- #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
- GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800 )
- #endif
-
-
-
-
-
-
-
- template <typename T>
- explicit AssertionResult(
- const T& success,
- typename std::enable_if<
- !std::is_convertible<T, AssertionResult>::value>::type*
-
- = nullptr)
- : success_(success) {}
- #if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
-
- AssertionResult& operator=(AssertionResult other) {
- swap(other);
- return *this;
- }
-
- operator bool() const { return success_; }
-
- AssertionResult operator!() const;
-
-
-
-
- const char* message() const {
- return message_.get() != nullptr ? message_->c_str() : "";
- }
-
- const char* failure_message() const { return message(); }
-
- template <typename T> AssertionResult& operator<<(const T& value) {
- AppendMessage(Message() << value);
- return *this;
- }
-
-
- AssertionResult& operator<<(
- ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {
- AppendMessage(Message() << basic_manipulator);
- return *this;
- }
- private:
-
- void AppendMessage(const Message& a_message) {
- if (message_.get() == nullptr) message_.reset(new ::std::string);
- message_->append(a_message.GetString().c_str());
- }
-
- void swap(AssertionResult& other);
-
- bool success_;
-
-
-
-
- std::unique_ptr< ::std::string> message_;
- };
- GTEST_API_ AssertionResult AssertionSuccess();
- GTEST_API_ AssertionResult AssertionFailure();
- GTEST_API_ AssertionResult AssertionFailure(const Message& msg);
- }
- #include "gtest/gtest_pred_impl.h"
- namespace testing {
- class GTEST_API_ Test {
- public:
- friend class TestInfo;
-
- virtual ~Test();
-
-
-
-
-
-
- static void SetUpTestSuite() {}
-
-
-
-
-
-
- static void TearDownTestSuite() {}
-
-
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- static void TearDownTestCase() {}
- static void SetUpTestCase() {}
- #endif
-
- static bool HasFatalFailure();
-
- static bool HasNonfatalFailure();
-
- static bool IsSkipped();
-
-
- static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
-
-
-
-
-
-
-
-
-
-
-
-
-
- static void RecordProperty(const std::string& key, const std::string& value);
- static void RecordProperty(const std::string& key, int value);
- protected:
-
- Test();
-
- virtual void SetUp();
-
- virtual void TearDown();
- private:
-
-
- static bool HasSameFixtureClass();
-
-
-
-
-
-
- virtual void TestBody() = 0;
-
- void Run();
-
-
- void DeleteSelf_() { delete this; }
- const std::unique_ptr<GTEST_FLAG_SAVER_> gtest_flag_saver_;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- struct Setup_should_be_spelled_SetUp {};
- virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);
- };
- typedef internal::TimeInMillis TimeInMillis;
- class TestProperty {
- public:
-
-
-
- TestProperty(const std::string& a_key, const std::string& a_value) :
- key_(a_key), value_(a_value) {
- }
-
- const char* key() const {
- return key_.c_str();
- }
-
- const char* value() const {
- return value_.c_str();
- }
-
- void SetValue(const std::string& new_value) {
- value_ = new_value;
- }
- private:
-
- std::string key_;
-
- std::string value_;
- };
- class GTEST_API_ TestResult {
- public:
-
- TestResult();
-
- ~TestResult();
-
-
- int total_part_count() const;
-
- int test_property_count() const;
-
- bool Passed() const { return !Skipped() && !Failed(); }
-
- bool Skipped() const;
-
- bool Failed() const;
-
- bool HasFatalFailure() const;
-
- bool HasNonfatalFailure() const;
-
- TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-
- TimeInMillis start_timestamp() const { return start_timestamp_; }
-
-
- const TestPartResult& GetTestPartResult(int i) const;
-
-
-
- const TestProperty& GetTestProperty(int i) const;
- private:
- friend class TestInfo;
- friend class TestSuite;
- friend class UnitTest;
- friend class internal::DefaultGlobalTestPartResultReporter;
- friend class internal::ExecDeathTest;
- friend class internal::TestResultAccessor;
- friend class internal::UnitTestImpl;
- friend class internal::WindowsDeathTest;
- friend class internal::FuchsiaDeathTest;
-
- const std::vector<TestPartResult>& test_part_results() const {
- return test_part_results_;
- }
-
- const std::vector<TestProperty>& test_properties() const {
- return test_properties_;
- }
-
- void set_start_timestamp(TimeInMillis start) { start_timestamp_ = start; }
-
- void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }
-
-
-
-
-
-
- void RecordProperty(const std::string& xml_element,
- const TestProperty& test_property);
-
-
-
- static bool ValidateTestProperty(const std::string& xml_element,
- const TestProperty& test_property);
-
- void AddTestPartResult(const TestPartResult& test_part_result);
-
- int death_test_count() const { return death_test_count_; }
-
- int increment_death_test_count() { return ++death_test_count_; }
-
- void ClearTestPartResults();
-
- void Clear();
-
-
- internal::Mutex test_properties_mutex_;
-
- std::vector<TestPartResult> test_part_results_;
-
- std::vector<TestProperty> test_properties_;
-
- int death_test_count_;
-
- TimeInMillis start_timestamp_;
-
- TimeInMillis elapsed_time_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);
- };
- class GTEST_API_ TestInfo {
- public:
-
-
- ~TestInfo();
-
- const char* test_suite_name() const { return test_suite_name_.c_str(); }
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const char* test_case_name() const { return test_suite_name(); }
- #endif
-
- const char* name() const { return name_.c_str(); }
-
-
- const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
- return nullptr;
- }
-
-
- const char* value_param() const {
- if (value_param_.get() != nullptr) return value_param_->c_str();
- return nullptr;
- }
-
- const char* file() const { return location_.file.c_str(); }
-
- int line() const { return location_.line; }
-
- bool is_in_another_shard() const { return is_in_another_shard_; }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- bool should_run() const { return should_run_; }
-
- bool is_reportable() const {
-
-
- return matches_filter_ && !is_in_another_shard_;
- }
-
- const TestResult* result() const { return &result_; }
- private:
- #if GTEST_HAS_DEATH_TEST
- friend class internal::DefaultDeathTestFactory;
- #endif
- friend class Test;
- friend class TestSuite;
- friend class internal::UnitTestImpl;
- friend class internal::StreamingListenerTest;
- friend TestInfo* internal::MakeAndRegisterTestInfo(
- const char* test_suite_name, const char* name, const char* type_param,
- const char* value_param, internal::CodeLocation code_location,
- internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
- internal::TearDownTestSuiteFunc tear_down_tc,
- internal::TestFactoryBase* factory);
-
-
- TestInfo(const std::string& test_suite_name, const std::string& name,
- const char* a_type_param,
- const char* a_value_param,
- internal::CodeLocation a_code_location,
- internal::TypeId fixture_class_id,
- internal::TestFactoryBase* factory);
-
-
- int increment_death_test_count() {
- return result_.increment_death_test_count();
- }
-
-
- void Run();
-
- void Skip();
- static void ClearTestResult(TestInfo* test_info) {
- test_info->result_.Clear();
- }
-
- const std::string test_suite_name_;
- const std::string name_;
-
-
- const std::unique_ptr<const ::std::string> type_param_;
-
-
- const std::unique_ptr<const ::std::string> value_param_;
- internal::CodeLocation location_;
- const internal::TypeId fixture_class_id_;
- bool should_run_;
- bool is_disabled_;
- bool matches_filter_;
-
- bool is_in_another_shard_;
- internal::TestFactoryBase* const factory_;
-
-
-
- TestResult result_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);
- };
- class GTEST_API_ TestSuite {
- public:
-
-
-
-
-
-
-
-
-
-
-
-
- TestSuite(const char* name, const char* a_type_param,
- internal::SetUpTestSuiteFunc set_up_tc,
- internal::TearDownTestSuiteFunc tear_down_tc);
-
- virtual ~TestSuite();
-
- const char* name() const { return name_.c_str(); }
-
-
- const char* type_param() const {
- if (type_param_.get() != nullptr) return type_param_->c_str();
- return nullptr;
- }
-
- bool should_run() const { return should_run_; }
-
- int successful_test_count() const;
-
- int skipped_test_count() const;
-
- int failed_test_count() const;
-
- int reportable_disabled_test_count() const;
-
- int disabled_test_count() const;
-
- int reportable_test_count() const;
-
- int test_to_run_count() const;
-
- int total_test_count() const;
-
- bool Passed() const { return !Failed(); }
-
- bool Failed() const {
- return failed_test_count() > 0 || ad_hoc_test_result().Failed();
- }
-
- TimeInMillis elapsed_time() const { return elapsed_time_; }
-
-
- TimeInMillis start_timestamp() const { return start_timestamp_; }
-
-
- const TestInfo* GetTestInfo(int i) const;
-
-
- const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }
- private:
- friend class Test;
- friend class internal::UnitTestImpl;
-
- std::vector<TestInfo*>& test_info_list() { return test_info_list_; }
-
- const std::vector<TestInfo*>& test_info_list() const {
- return test_info_list_;
- }
-
-
- TestInfo* GetMutableTestInfo(int i);
-
- void set_should_run(bool should) { should_run_ = should; }
-
-
- void AddTestInfo(TestInfo * test_info);
-
- void ClearResult();
-
- static void ClearTestSuiteResult(TestSuite* test_suite) {
- test_suite->ClearResult();
- }
-
- void Run();
-
- void Skip();
-
-
- void RunSetUpTestSuite() {
- if (set_up_tc_ != nullptr) {
- (*set_up_tc_)();
- }
- }
-
-
- void RunTearDownTestSuite() {
- if (tear_down_tc_ != nullptr) {
- (*tear_down_tc_)();
- }
- }
-
- static bool TestPassed(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Passed();
- }
-
- static bool TestSkipped(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Skipped();
- }
-
- static bool TestFailed(const TestInfo* test_info) {
- return test_info->should_run() && test_info->result()->Failed();
- }
-
-
- static bool TestReportableDisabled(const TestInfo* test_info) {
- return test_info->is_reportable() && test_info->is_disabled_;
- }
-
- static bool TestDisabled(const TestInfo* test_info) {
- return test_info->is_disabled_;
- }
-
- static bool TestReportable(const TestInfo* test_info) {
- return test_info->is_reportable();
- }
-
- static bool ShouldRunTest(const TestInfo* test_info) {
- return test_info->should_run();
- }
-
- void ShuffleTests(internal::Random* random);
-
- void UnshuffleTests();
-
- std::string name_;
-
-
- const std::unique_ptr<const ::std::string> type_param_;
-
-
- std::vector<TestInfo*> test_info_list_;
-
-
-
- std::vector<int> test_indices_;
-
- internal::SetUpTestSuiteFunc set_up_tc_;
-
- internal::TearDownTestSuiteFunc tear_down_tc_;
-
- bool should_run_;
-
- TimeInMillis start_timestamp_;
-
- TimeInMillis elapsed_time_;
-
-
- TestResult ad_hoc_test_result_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestSuite);
- };
- class Environment {
- public:
-
- virtual ~Environment() {}
-
- virtual void SetUp() {}
-
- virtual void TearDown() {}
- private:
-
-
- struct Setup_should_be_spelled_SetUp {};
- virtual Setup_should_be_spelled_SetUp* Setup() { return nullptr; }
- };
- #if GTEST_HAS_EXCEPTIONS
- class GTEST_API_ AssertionException
- : public internal::GoogleTestFailureException {
- public:
- explicit AssertionException(const TestPartResult& result)
- : GoogleTestFailureException(result) {}
- };
- #endif
- class TestEventListener {
- public:
- virtual ~TestEventListener() {}
-
- virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
-
-
-
- virtual void OnTestIterationStart(const UnitTest& unit_test,
- int iteration) = 0;
-
- virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;
-
- virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;
-
- virtual void OnTestSuiteStart(const TestSuite& ) {}
-
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- virtual void OnTestCaseStart(const TestCase& ) {}
- #endif
-
- virtual void OnTestStart(const TestInfo& test_info) = 0;
-
-
-
- virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;
-
- virtual void OnTestEnd(const TestInfo& test_info) = 0;
-
- virtual void OnTestSuiteEnd(const TestSuite& ) {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- virtual void OnTestCaseEnd(const TestCase& ) {}
- #endif
-
- virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;
-
- virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;
-
- virtual void OnTestIterationEnd(const UnitTest& unit_test,
- int iteration) = 0;
-
- virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;
- };
- class EmptyTestEventListener : public TestEventListener {
- public:
- void OnTestProgramStart(const UnitTest& ) override {}
- void OnTestIterationStart(const UnitTest& ,
- int ) override {}
- void OnEnvironmentsSetUpStart(const UnitTest& ) override {}
- void OnEnvironmentsSetUpEnd(const UnitTest& ) override {}
- void OnTestSuiteStart(const TestSuite& ) override {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- void OnTestCaseStart(const TestCase& ) override {}
- #endif
- void OnTestStart(const TestInfo& ) override {}
- void OnTestPartResult(const TestPartResult& ) override {}
- void OnTestEnd(const TestInfo& ) override {}
- void OnTestSuiteEnd(const TestSuite& ) override {}
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- void OnTestCaseEnd(const TestCase& ) override {}
- #endif
- void OnEnvironmentsTearDownStart(const UnitTest& ) override {}
- void OnEnvironmentsTearDownEnd(const UnitTest& ) override {}
- void OnTestIterationEnd(const UnitTest& ,
- int ) override {}
- void OnTestProgramEnd(const UnitTest& ) override {}
- };
- class GTEST_API_ TestEventListeners {
- public:
- TestEventListeners();
- ~TestEventListeners();
-
-
-
- void Append(TestEventListener* listener);
-
-
-
- TestEventListener* Release(TestEventListener* listener);
-
-
-
-
-
- TestEventListener* default_result_printer() const {
- return default_result_printer_;
- }
-
-
-
-
-
-
-
- TestEventListener* default_xml_generator() const {
- return default_xml_generator_;
- }
- private:
- friend class TestSuite;
- friend class TestInfo;
- friend class internal::DefaultGlobalTestPartResultReporter;
- friend class internal::NoExecDeathTest;
- friend class internal::TestEventListenersAccessor;
- friend class internal::UnitTestImpl;
-
-
- TestEventListener* repeater();
-
-
-
-
-
- void SetDefaultResultPrinter(TestEventListener* listener);
-
-
-
-
-
- void SetDefaultXmlGenerator(TestEventListener* listener);
-
-
- bool EventForwardingEnabled() const;
- void SuppressEventForwarding();
-
- internal::TestEventRepeater* repeater_;
-
- TestEventListener* default_result_printer_;
-
- TestEventListener* default_xml_generator_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);
- };
- class GTEST_API_ UnitTest {
- public:
-
-
-
- static UnitTest* GetInstance();
-
-
-
-
-
-
- int Run() GTEST_MUST_USE_RESULT_;
-
-
- const char* original_working_dir() const;
-
-
- const TestSuite* current_test_suite() const GTEST_LOCK_EXCLUDED_(mutex_);
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const TestCase* current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_);
- #endif
-
-
- const TestInfo* current_test_info() const
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- int random_seed() const;
-
-
-
-
- internal::ParameterizedTestSuiteRegistry& parameterized_test_registry()
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- int successful_test_suite_count() const;
-
- int failed_test_suite_count() const;
-
- int total_test_suite_count() const;
-
-
- int test_suite_to_run_count() const;
-
- #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
-
- int successful_test_count() const;
-
- int skipped_test_count() const;
-
- int failed_test_count() const;
-
- int reportable_disabled_test_count() const;
-
- int disabled_test_count() const;
-
- int reportable_test_count() const;
-
- int total_test_count() const;
-
- int test_to_run_count() const;
-
-
- TimeInMillis start_timestamp() const;
-
- TimeInMillis elapsed_time() const;
-
-
- bool Passed() const;
-
-
- bool Failed() const;
-
-
- const TestSuite* GetTestSuite(int i) const;
- #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
- const TestCase* GetTestCase(int i) const;
- #endif
-
-
- const TestResult& ad_hoc_test_result() const;
-
-
- TestEventListeners& listeners();
- private:
-
-
-
-
-
-
-
-
-
- Environment* AddEnvironment(Environment* env);
-
-
-
-
- void AddTestPartResult(TestPartResult::Type result_type,
- const char* file_name,
- int line_number,
- const std::string& message,
- const std::string& os_stack_trace)
- GTEST_LOCK_EXCLUDED_(mutex_);
-
-
-
-
-
- void RecordProperty(const std::string& key, const std::string& value);
-
-
- TestSuite* GetMutableTestSuite(int i);
-
- internal::UnitTestImpl* impl() { return impl_; }
- const internal::UnitTestImpl* impl() const { return impl_; }
-
-
- friend class ScopedTrace;
- friend class Test;
- friend class internal::AssertHelper;
- friend class internal::StreamingListenerTest;
- friend class internal::UnitTestRecordPropertyTestHelper;
- friend Environment* AddGlobalTestEnvironment(Environment* env);
- friend std::set<std::string>* internal::GetIgnoredParameterizedTestSuites();
- friend internal::UnitTestImpl* internal::GetUnitTestImpl();
- friend void internal::ReportFailureInUnknownLocation(
- TestPartResult::Type result_type,
- const std::string& message);
-
- UnitTest();
-
- virtual ~UnitTest();
-
-
- void PushGTestTrace(const internal::TraceInfo& trace)
- GTEST_LOCK_EXCLUDED_(mutex_);
-
- void PopGTestTrace()
- GTEST_LOCK_EXCLUDED_(mutex_);
-
-
- mutable internal::Mutex mutex_;
-
-
-
-
- internal::UnitTestImpl* impl_;
-
- GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);
- };
- inline Environment* AddGlobalTestEnvironment(Environment* env) {
- return UnitTest::GetInstance()->AddEnvironment(env);
- }
- GTEST_API_ void InitGoogleTest(int* argc, char** argv);
- GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);
- GTEST_API_ void InitGoogleTest();
- namespace internal {
- template <typename T1, typename T2>
- AssertionResult CmpHelperEQFailure(const char* lhs_expression,
- const char* rhs_expression,
- const T1& lhs, const T2& rhs) {
- return EqFailure(lhs_expression,
- rhs_expression,
- FormatForComparisonFailureMessage(lhs, rhs),
- FormatForComparisonFailureMessage(rhs, lhs),
- false);
- }
- struct faketype {};
- inline bool operator==(faketype, faketype) { return true; }
- inline bool operator!=(faketype, faketype) { return false; }
- template <typename T1, typename T2>
- AssertionResult CmpHelperEQ(const char* lhs_expression,
- const char* rhs_expression,
- const T1& lhs,
- const T2& rhs) {
- if (lhs == rhs) {
- return AssertionSuccess();
- }
- return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
- }
- class EqHelper {
- public:
-
- template <
- typename T1, typename T2,
-
-
- typename std::enable_if<!std::is_integral<T1>::value ||
- !std::is_pointer<T2>::value>::type* = nullptr>
- static AssertionResult Compare(const char* lhs_expression,
- const char* rhs_expression, const T1& lhs,
- const T2& rhs) {
- return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
- }
-
-
-
-
-
-
- static AssertionResult Compare(const char* lhs_expression,
- const char* rhs_expression,
- BiggestInt lhs,
- BiggestInt rhs) {
- return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
- }
- template <typename T>
- static AssertionResult Compare(
- const char* lhs_expression, const char* rhs_expression,
-
- std::nullptr_t , T* rhs) {
-
- return CmpHelperEQ(lhs_expression, rhs_expression, static_cast<T*>(nullptr),
- rhs);
- }
- };
- template <typename T1, typename T2>
- AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
- const T1& val1, const T2& val2,
- const char* op) {
- return AssertionFailure()
- << "Expected: (" << expr1 << ") " << op << " (" << expr2
- << "), actual: " << FormatForComparisonFailureMessage(val1, val2)
- << " vs " << FormatForComparisonFailureMessage(val2, val1);
- }
- #define GTEST_IMPL_CMP_HELPER_(op_name, op)\
- template <typename T1, typename T2>\
- AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
- const T1& val1, const T2& val2) {\
- if (val1 op val2) {\
- return AssertionSuccess();\
- } else {\
- return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
- }\
- }
- GTEST_IMPL_CMP_HELPER_(NE, !=)
- GTEST_IMPL_CMP_HELPER_(LE, <=)
- GTEST_IMPL_CMP_HELPER_(LT, <)
- GTEST_IMPL_CMP_HELPER_(GE, >=)
- GTEST_IMPL_CMP_HELPER_(GT, >)
- #undef GTEST_IMPL_CMP_HELPER_
- GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(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 char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
- const char* s2_expression,
- const char* s1,
- const char* s2);
- GTEST_API_ AssertionResult CmpHelperSTREQ(const char* s1_expression,
- const char* s2_expression,
- const wchar_t* s1,
- const wchar_t* s2);
- GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,
- const char* s2_expression,
- const wchar_t* s1,
- const wchar_t* s2);
- }
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const char* needle, const char* haystack);
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const wchar_t* needle, const wchar_t* haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const char* needle, const char* haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const wchar_t* needle, const wchar_t* haystack);
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::string& needle, const ::std::string& haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::string& needle, const ::std::string& haystack);
- #if GTEST_HAS_STD_WSTRING
- GTEST_API_ AssertionResult IsSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::wstring& needle, const ::std::wstring& haystack);
- GTEST_API_ AssertionResult IsNotSubstring(
- const char* needle_expr, const char* haystack_expr,
- const ::std::wstring& needle, const ::std::wstring& haystack);
- #endif
- namespace internal {
- template <typename RawType>
- AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
- const char* rhs_expression,
- RawType lhs_value,
- RawType rhs_value) {
- const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
- if (lhs.AlmostEquals(rhs)) {
- return AssertionSuccess();
- }
- ::std::stringstream lhs_ss;
- lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << lhs_value;
- ::std::stringstream rhs_ss;
- rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
- << rhs_value;
- return EqFailure(lhs_expression,
- rhs_expression,
- StringStreamToString(&lhs_ss),
- StringStreamToString(&rhs_ss),
- false);
- }
- GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,
- const char* expr2,
- const char* abs_error_expr,
- double val1,
- double val2,
- double abs_error);
- class GTEST_API_ AssertHelper {
- public:
-
- AssertHelper(TestPartResult::Type type,
- const char* file,
- int line,
- const char* message);
- ~AssertHelper();
-
-
- void operator=(const Message& message) const;
- private:
-
-
-
-
- struct AssertHelperData {
- AssertHelperData(TestPartResult::Type t,
- const char* srcfile,
- int line_num,
- const char* msg)
- : type(t), file(srcfile), line(line_num), message(msg) { }
- TestPartResult::Type const type;
- const char* const file;
- int const line;
- std::string const message;
- private:
- GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);
- };
- AssertHelperData* const data_;
- GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);
- };
- }
- template <typename T>
- class WithParamInterface {
- public:
- typedef T ParamType;
- virtual ~WithParamInterface() {}
-
-
- static const ParamType& GetParam() {
- GTEST_CHECK_(parameter_ != nullptr)
- << "GetParam() can only be called inside a value-parameterized test "
- << "-- did you intend to write TEST_P instead of TEST_F?";
- return *parameter_;
- }
- private:
-
-
- static void SetParam(const ParamType* parameter) {
- parameter_ = parameter;
- }
-
- static const ParamType* parameter_;
-
- template <class TestClass> friend class internal::ParameterizedTestFactory;
- };
- template <typename T>
- const T* WithParamInterface<T>::parameter_ = nullptr;
- template <typename T>
- class TestWithParam : public Test, public WithParamInterface<T> {
- };
- #define GTEST_SKIP() GTEST_SKIP_("")
- #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
- #define ADD_FAILURE_AT(file, line) \
- GTEST_MESSAGE_AT_(file, line, "Failed", \
- ::testing::TestPartResult::kNonFatalFailure)
- #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed")
- #define GTEST_FAIL_AT(file, line) \
- GTEST_MESSAGE_AT_(file, line, "Failed", \
- ::testing::TestPartResult::kFatalFailure)
- #if !GTEST_DONT_DEFINE_FAIL
- # define FAIL() GTEST_FAIL()
- #endif
- #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded")
- #if !GTEST_DONT_DEFINE_SUCCEED
- # define SUCCEED() GTEST_SUCCEED()
- #endif
- #define EXPECT_THROW(statement, expected_exception) \
- GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_NO_THROW(statement) \
- GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)
- #define EXPECT_ANY_THROW(statement) \
- GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)
- #define ASSERT_THROW(statement, expected_exception) \
- GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
- #define ASSERT_NO_THROW(statement) \
- GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)
- #define ASSERT_ANY_THROW(statement) \
- GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)
- #define GTEST_EXPECT_TRUE(condition) \
- GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
- GTEST_NONFATAL_FAILURE_)
- #define GTEST_EXPECT_FALSE(condition) \
- GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
- GTEST_NONFATAL_FAILURE_)
- #define GTEST_ASSERT_TRUE(condition) \
- GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
- GTEST_FATAL_FAILURE_)
- #define GTEST_ASSERT_FALSE(condition) \
- GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
- GTEST_FATAL_FAILURE_)
- #if !GTEST_DONT_DEFINE_EXPECT_TRUE
- #define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_EXPECT_FALSE
- #define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_TRUE
- #define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_FALSE
- #define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition)
- #endif
- #define EXPECT_EQ(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
- #define EXPECT_NE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
- #define EXPECT_LE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
- #define EXPECT_LT(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
- #define EXPECT_GE(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
- #define EXPECT_GT(val1, val2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
- #define GTEST_ASSERT_EQ(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
- #define GTEST_ASSERT_NE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
- #define GTEST_ASSERT_LE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)
- #define GTEST_ASSERT_LT(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)
- #define GTEST_ASSERT_GE(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)
- #define GTEST_ASSERT_GT(val1, val2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)
- #if !GTEST_DONT_DEFINE_ASSERT_EQ
- # define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_NE
- # define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_LE
- # define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_LT
- # define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_GE
- # define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)
- #endif
- #if !GTEST_DONT_DEFINE_ASSERT_GT
- # define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)
- #endif
- #define EXPECT_STREQ(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
- #define EXPECT_STRNE(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
- #define EXPECT_STRCASEEQ(s1, s2) \
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
- #define EXPECT_STRCASENE(s1, s2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
- #define ASSERT_STREQ(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, s1, s2)
- #define ASSERT_STRNE(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)
- #define ASSERT_STRCASEEQ(s1, s2) \
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, s1, s2)
- #define ASSERT_STRCASENE(s1, s2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)
- #define EXPECT_FLOAT_EQ(val1, val2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
- val1, val2)
- #define EXPECT_DOUBLE_EQ(val1, val2)\
- EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
- val1, val2)
- #define ASSERT_FLOAT_EQ(val1, val2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \
- val1, val2)
- #define ASSERT_DOUBLE_EQ(val1, val2)\
- ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \
- val1, val2)
- #define EXPECT_NEAR(val1, val2, abs_error)\
- EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
- val1, val2, abs_error)
- #define ASSERT_NEAR(val1, val2, abs_error)\
- ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \
- val1, val2, abs_error)
- GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,
- float val1, float val2);
- GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
- double val1, double val2);
- #if GTEST_OS_WINDOWS
- # define EXPECT_HRESULT_SUCCEEDED(expr) \
- EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
- # define ASSERT_HRESULT_SUCCEEDED(expr) \
- ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))
- # define EXPECT_HRESULT_FAILED(expr) \
- EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
- # define ASSERT_HRESULT_FAILED(expr) \
- ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))
- #endif
- #define ASSERT_NO_FATAL_FAILURE(statement) \
- GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)
- #define EXPECT_NO_FATAL_FAILURE(statement) \
- GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)
- class GTEST_API_ ScopedTrace {
- public:
-
-
-
-
- template <typename T>
- ScopedTrace(const char* file, int line, const T& message) {
- PushTrace(file, line, (Message() << message).GetString());
- }
-
- ScopedTrace(const char* file, int line, const char* message) {
- PushTrace(file, line, message ? message : "(null)");
- }
- ScopedTrace(const char* file, int line, const std::string& message) {
- PushTrace(file, line, message);
- }
-
-
-
-
- ~ScopedTrace();
- private:
- void PushTrace(const char* file, int line, std::string message);
- GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);
- } GTEST_ATTRIBUTE_UNUSED_;
-
-
- #define SCOPED_TRACE(message) \
- ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\
- __FILE__, __LINE__, (message))
- template <typename T1, typename T2>
- constexpr bool StaticAssertTypeEq() noexcept {
- static_assert(std::is_same<T1, T2>::value, "T1 and T2 are not the same type");
- return true;
- }
- #define GTEST_TEST(test_suite_name, test_name) \
- GTEST_TEST_(test_suite_name, test_name, ::testing::Test, \
- ::testing::internal::GetTestTypeId())
- #if !GTEST_DONT_DEFINE_TEST
- #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name)
- #endif
- #if !GTEST_DONT_DEFINE_TEST
- #define TEST_F(test_fixture, test_name)\
- GTEST_TEST_(test_fixture, test_name, test_fixture, \
- ::testing::internal::GetTypeId<test_fixture>())
- #endif
- GTEST_API_ std::string TempDir();
- #ifdef _MSC_VER
- # pragma warning(pop)
- #endif
- template <int&... ExplicitParameterBarrier, typename Factory>
- 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) {
- using TestT = typename std::remove_pointer<decltype(factory())>::type;
- class FactoryImpl : public internal::TestFactoryBase {
- public:
- explicit FactoryImpl(Factory f) : factory_(std::move(f)) {}
- Test* CreateTest() override { return factory_(); }
- private:
- Factory factory_;
- };
- return internal::MakeAndRegisterTestInfo(
- test_suite_name, test_name, type_param, value_param,
- internal::CodeLocation(file, line), internal::GetTypeId<TestT>(),
- internal::SuiteApiResolver<TestT>::GetSetUpCaseOrSuite(file, line),
- internal::SuiteApiResolver<TestT>::GetTearDownCaseOrSuite(file, line),
- new FactoryImpl{std::move(factory)});
- }
- }
- int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;
- inline int RUN_ALL_TESTS() {
- return ::testing::UnitTest::GetInstance()->Run();
- }
- GTEST_DISABLE_MSC_WARNINGS_POP_()
- #endif
|