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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal/catch_test_case_tracker.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-12-04 21:37:19 +0100
committerMartin Hořeňovský2020-12-04 21:37:24 +0100
commit6350851f9af96a1c35da92b18ca7cb3d90fa67c9 (patch)
tree783930500698885dbe66e96d8012a6d3fd577f86 /src/catch2/internal/catch_test_case_tracker.cpp
parent21c97f2fad9ab9c979b7d1065253bbb4b172b6dc (diff)
downloadcatch3-6350851f9af96a1c35da92b18ca7cb3d90fa67c9.tar.gz
Return plain ptr from ITracker::findChild instead of shared_ptr
This is part of wider rework of trackers to avoid `std::shared_ptr` everywhere. Related to #2088
Diffstat (limited to 'src/catch2/internal/catch_test_case_tracker.cpp')
-rw-r--r--src/catch2/internal/catch_test_case_tracker.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp
index 3891614d..b405ce86 100644
--- a/src/catch2/internal/catch_test_case_tracker.cpp
+++ b/src/catch2/internal/catch_test_case_tracker.cpp
@@ -34,7 +34,7 @@ namespace TestCaseTracking {
m_children.push_back( child );
}
- ITrackerPtr ITracker::findChild( NameAndLocation const& nameAndLocation ) {
+ ITracker* ITracker::findChild( NameAndLocation const& nameAndLocation ) {
auto it = std::find_if(
m_children.begin(),
m_children.end(),
@@ -43,7 +43,7 @@ namespace TestCaseTracking {
nameAndLocation.location &&
tracker->nameAndLocation().name == nameAndLocation.name;
} );
- return ( it != m_children.end() ) ? *it : nullptr;
+ return ( it != m_children.end() ) ? it->get() : nullptr;
}
@@ -195,17 +195,19 @@ namespace TestCaseTracking {
bool SectionTracker::isSectionTracker() const { return true; }
SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) {
- std::shared_ptr<SectionTracker> section;
+ SectionTracker* section;
ITracker& currentTracker = ctx.currentTracker();
- if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {
+ if ( ITracker* childTracker =
+ currentTracker.findChild( nameAndLocation ) ) {
assert( childTracker );
assert( childTracker->isSectionTracker() );
- section = std::static_pointer_cast<SectionTracker>( childTracker );
- }
- else {
- section = std::make_shared<SectionTracker>( nameAndLocation, ctx, &currentTracker );
- currentTracker.addChild( section );
+ section = static_cast<SectionTracker*>( childTracker );
+ } else {
+ auto newSection = std::make_shared<SectionTracker>(
+ nameAndLocation, ctx, &currentTracker );
+ section = newSection.get();
+ currentTracker.addChild( std::move( newSection ) );
}
if( !ctx.completedCycle() )
section->tryOpen();