Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_test_case_info.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-11-04 21:35:57 +0100
committerMartin Hořeňovský2019-11-14 10:52:34 +0100
commit302e2c0b06f131199b97ad33bdebacc359782ff0 (patch)
tree26e80b38b48739573de4225e789096ec83c79357 /include/internal/catch_test_case_info.cpp
parent019b0a0fe0398a5b73937b9a1901b3dfaecac386 (diff)
downloadcatch3-302e2c0b06f131199b97ad33bdebacc359782ff0.tar.gz
Do not copy around TestCaseInfo
Now a `TEST_CASE` macro should create a single TestCaseInfo and then it should never be copied around. This, together with latter changes, should significantly decrease the number of allocations made before `main` is even entered.
Diffstat (limited to 'include/internal/catch_test_case_info.cpp')
-rw-r--r--include/internal/catch_test_case_info.cpp36
1 files changed, 14 insertions, 22 deletions
diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp
index b610d7a4..7ea729fa 100644
--- a/include/internal/catch_test_case_info.cpp
+++ b/include/internal/catch_test_case_info.cpp
@@ -53,10 +53,10 @@ namespace Catch {
}
}
- TestCase makeTestCase( ITestInvoker* _testCase,
- std::string const& _className,
- NameAndTags const& nameAndTags,
- SourceLineInfo const& _lineInfo )
+ std::unique_ptr<TestCaseInfo>
+ makeTestCaseInfo(std::string const& _className,
+ NameAndTags const& nameAndTags,
+ SourceLineInfo const& _lineInfo )
{
bool isHidden = false;
@@ -95,8 +95,8 @@ namespace Catch {
tags.push_back( "." );
}
- TestCaseInfo info( static_cast<std::string>(nameAndTags.name), _className, tags, _lineInfo );
- return TestCase( _testCase, std::move(info) );
+ return std::make_unique<TestCaseInfo>(static_cast<std::string>(nameAndTags.name),
+ _className, tags, _lineInfo);
}
void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ) {
@@ -155,26 +155,18 @@ namespace Catch {
}
- TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {}
-
-
- void TestCase::invoke() const {
- test->invoke();
+ bool TestCaseHandle::operator == ( TestCaseHandle const& rhs ) const {
+ return m_invoker == rhs.m_invoker
+ && m_info->name == rhs.m_info->name
+ && m_info->className == rhs.m_info->className;
}
- bool TestCase::operator == ( TestCase const& other ) const {
- return test.get() == other.test.get() &&
- name == other.name &&
- className == other.className;
+ bool TestCaseHandle::operator < ( TestCaseHandle const& rhs ) const {
+ return m_info->name < rhs.m_info->name;
}
- bool TestCase::operator < ( TestCase const& other ) const {
- return name < other.name;
- }
-
- TestCaseInfo const& TestCase::getTestCaseInfo() const
- {
- return *this;
+ TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const {
+ return *m_info;
}
} // end namespace Catch