| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 301541c commit 760b788
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -607,15 +607,15 @@ class GTEST_API_ TestInfo { | |||
| 607 | 607 | friend class internal::UnitTestImpl; | |
| 608 | 608 | friend class internal::StreamingListenerTest; | |
| 609 | 609 | friend TestInfo* internal::MakeAndRegisterTestInfo( | |
| 610 | - const char* test_suite_name, const char* name, const char* type_param, | ||
| 610 | + std::string test_suite_name, const char* name, const char* type_param, | ||
| 611 | 611 | const char* value_param, internal::CodeLocation code_location, | |
| 612 | 612 | internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc, | |
| 613 | 613 | internal::TearDownTestSuiteFunc tear_down_tc, | |
| 614 | 614 | internal::TestFactoryBase* factory); | |
| 615 | 615 | ||
| 616 | 616 | // Constructs a TestInfo object. The newly constructed instance assumes | |
| 617 | 617 | // ownership of the factory object. | |
| 618 | - TestInfo(const std::string& test_suite_name, const std::string& name, | ||
| 618 | + TestInfo(std::string test_suite_name, std::string name, | ||
| 619 | 619 | const char* a_type_param, // NULL if not a type-parameterized test | |
| 620 | 620 | const char* a_value_param, // NULL if not a value-parameterized test | |
| 621 | 621 | internal::CodeLocation a_code_location, | |
@@ -683,7 +683,7 @@ class GTEST_API_ TestSuite { | |||
| 683 | 683 | // this is not a type-parameterized test. | |
| 684 | 684 | // set_up_tc: pointer to the function that sets up the test suite | |
| 685 | 685 | // tear_down_tc: pointer to the function that tears down the test suite | |
| 686 | - TestSuite(const char* name, const char* a_type_param, | ||
| 686 | + TestSuite(const std::string& name, const char* a_type_param, | ||
| 687 | 687 | internal::SetUpTestSuiteFunc set_up_tc, | |
| 688 | 688 | internal::TearDownTestSuiteFunc tear_down_tc); | |
| 689 | 689 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,6 +43,7 @@ | |||
| 43 | 43 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ | |
| 44 | 44 | ||
| 45 | 45 | #include <string> | |
| 46 | + #include <utility> | ||
| 46 | 47 | ||
| 47 | 48 | #include "gtest/internal/gtest-port.h" | |
| 48 | 49 | #include "gtest/internal/gtest-string.h" | |
@@ -70,15 +71,20 @@ class GTEST_API_ FilePath { | |||
| 70 | 71 | public: | |
| 71 | 72 | FilePath() : pathname_("") {} | |
| 72 | 73 | FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {} | |
| 74 | + FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {} | ||
| 73 | 75 | ||
| 74 | - explicit FilePath(const std::string& pathname) : pathname_(pathname) { | ||
| 76 | + explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) { | ||
| 75 | 77 | Normalize(); | |
| 76 | 78 | } | |
| 77 | 79 | ||
| 78 | 80 | FilePath& operator=(const FilePath& rhs) { | |
| 79 | 81 | Set(rhs); | |
| 80 | 82 | return *this; | |
| 81 | 83 | } | |
| 84 | + FilePath& operator=(FilePath&& rhs) { | ||
| 85 | + pathname_ = std::move(rhs.pathname_); | ||
| 86 | + return *this; | ||
| 87 | + } | ||
| 82 | 88 | ||
| 83 | 89 | void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; } | |
| 84 | 90 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -474,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)(); | |||
| 474 | 474 | using TearDownTestSuiteFunc = void (*)(); | |
| 475 | 475 | ||
| 476 | 476 | struct CodeLocation { | |
| 477 | - CodeLocation(const std::string& a_file, int a_line) | ||
| 478 | - : file(a_file), line(a_line) {} | ||
| 477 | + CodeLocation(std::string a_file, int a_line) | ||
| 478 | + : file(std::move(a_file)), line(a_line) {} | ||
| 479 | 479 | ||
| 480 | 480 | std::string file; | |
| 481 | 481 | int line; | |
@@ -564,7 +564,7 @@ struct SuiteApiResolver : T { | |||
| 564 | 564 | // The newly created TestInfo instance will assume | |
| 565 | 565 | // ownership of the factory object. | |
| 566 | 566 | GTEST_API_ TestInfo* MakeAndRegisterTestInfo( | |
| 567 | - const char* test_suite_name, const char* name, const char* type_param, | ||
| 567 | + std::string test_suite_name, const char* name, const char* type_param, | ||
| 568 | 568 | const char* value_param, CodeLocation code_location, | |
| 569 | 569 | TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, | |
| 570 | 570 | TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory); | |
@@ -595,8 +595,7 @@ class GTEST_API_ TypedTestSuitePState { | |||
| 595 | 595 | fflush(stderr); | |
| 596 | 596 | posix::Abort(); | |
| 597 | 597 | } | |
| 598 | - registered_tests_.insert( | ||
| 599 | - ::std::make_pair(test_name, CodeLocation(file, line))); | ||
| 598 | + registered_tests_.emplace(test_name, CodeLocation(file, line)); | ||
| 600 | 599 | return true; | |
| 601 | 600 | } | |
| 602 | 601 | ||
@@ -700,7 +699,7 @@ class TypeParameterizedTest { | |||
| 700 | 699 | // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite, | |
| 701 | 700 | // Types). Valid values for 'index' are [0, N - 1] where N is the | |
| 702 | 701 | // length of Types. | |
| 703 | - static bool Register(const char* prefix, const CodeLocation& code_location, | ||
| 702 | + static bool Register(const char* prefix, CodeLocation code_location, | ||
| 704 | 703 | const char* case_name, const char* test_names, int index, | |
| 705 | 704 | const std::vector<std::string>& type_names = | |
| 706 | 705 | GenerateNames<DefaultNameGenerator, Types>()) { | |
@@ -712,8 +711,7 @@ class TypeParameterizedTest { | |||
| 712 | 711 | // list. | |
| 713 | 712 | MakeAndRegisterTestInfo( | |
| 714 | 713 | (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + | |
| 715 | - "/" + type_names[static_cast<size_t>(index)]) | ||
| 716 | - .c_str(), | ||
| 714 | + "/" + type_names[static_cast<size_t>(index)]), | ||
| 717 | 715 | StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(), | |
| 718 | 716 | GetTypeName<Type>().c_str(), | |
| 719 | 717 | nullptr, // No value parameter. | |
@@ -725,21 +723,17 @@ class TypeParameterizedTest { | |||
| 725 | 723 | new TestFactoryImpl<TestClass>); | |
| 726 | 724 | ||
| 727 | 725 | // Next, recurses (at compile time) with the tail of the type list. | |
| 728 | - return TypeParameterizedTest<Fixture, TestSel, | ||
| 729 | - typename Types::Tail>::Register(prefix, | ||
| 730 | - code_location, | ||
| 731 | - case_name, | ||
| 732 | - test_names, | ||
| 733 | - index + 1, | ||
| 734 | - type_names); | ||
| 726 | + return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>:: | ||
| 727 | + Register(prefix, std::move(code_location), case_name, test_names, | ||
| 728 | + index + 1, type_names); | ||
| 735 | 729 | } | |
| 736 | 730 | }; | |
| 737 | 731 | ||
| 738 | 732 | // The base case for the compile time recursion. | |
| 739 | 733 | template <GTEST_TEMPLATE_ Fixture, class TestSel> | |
| 740 | 734 | class TypeParameterizedTest<Fixture, TestSel, internal::None> { | |
| 741 | 735 | public: | |
| 742 | - static bool Register(const char* /*prefix*/, const CodeLocation&, | ||
| 736 | + static bool Register(const char* /*prefix*/, CodeLocation, | ||
| 743 | 737 | const char* /*case_name*/, const char* /*test_names*/, | |
| 744 | 738 | int /*index*/, | |
| 745 | 739 | const std::vector<std::string>& = | |
@@ -786,7 +780,8 @@ class TypeParameterizedTestSuite { | |||
| 786 | 780 | ||
| 787 | 781 | // Next, recurses (at compile time) with the tail of the test list. | |
| 788 | 782 | return TypeParameterizedTestSuite<Fixture, typename Tests::Tail, | |
| 789 | - Types>::Register(prefix, code_location, | ||
| 783 | + Types>::Register(prefix, | ||
| 784 | + std::move(code_location), | ||
| 790 | 785 | state, case_name, | |
| 791 | 786 | SkipComma(test_names), | |
| 792 | 787 | type_names); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments