Skip to content

Commit

Permalink
refactor: Move definitions of two functions to .cpp file (#1133)
Browse files Browse the repository at this point in the history
This PR moves the definitions of two functions in the `/Tests/CommonHelpers` directory to their `.cpp` file. 

I did this because I tried to add to more than one source file to a unit test, and then got linker errors...
  • Loading branch information
benjaminhuth committed Jan 11, 2022
1 parent 413d030 commit f4cc9e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
29 changes: 29 additions & 0 deletions Tests/CommonHelpers/Acts/Tests/CommonHelpers/TestSourceLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,32 @@ std::ostream& Acts::Test::operator<<(
os << ")";
return os;
}

Acts::BoundVariantMeasurement Acts::Test::testSourceLinkCalibratorReturn(
const Acts::GeometryContext& /*gctx*/,
Acts::MultiTrajectory::TrackStateProxy trackState) {
const auto& sl =
static_cast<const Acts::Test::TestSourceLink&>(trackState.uncalibrated());
if ((sl.indices[0] != Acts::eBoundSize) and
(sl.indices[1] != Acts::eBoundSize)) {
auto meas = makeMeasurement(sl, sl.parameters, sl.covariance, sl.indices[0],
sl.indices[1]);
trackState.setCalibrated(meas);
return meas;
} else if (sl.indices[0] != Acts::eBoundSize) {
auto meas =
makeMeasurement(sl, sl.parameters.head<1>(),
sl.covariance.topLeftCorner<1, 1>(), sl.indices[0]);
trackState.setCalibrated(meas);
return meas;
} else {
throw std::runtime_error(
"Tried to extract measurement from invalid TestSourceLink");
}
}

void Acts::Test::testSourceLinkCalibrator(
const Acts::GeometryContext& gctx,
Acts::MultiTrajectory::TrackStateProxy trackState) {
testSourceLinkCalibratorReturn(gctx, trackState);
}
24 changes: 2 additions & 22 deletions Tests/CommonHelpers/Acts/Tests/CommonHelpers/TestSourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,14 @@ std::ostream& operator<<(std::ostream& os, const TestSourceLink& sourceLink);
/// @return The measurement used
Acts::BoundVariantMeasurement testSourceLinkCalibratorReturn(
const GeometryContext& /*gctx*/,
MultiTrajectory::TrackStateProxy trackState) {
const auto& sl =
static_cast<const TestSourceLink&>(trackState.uncalibrated());
if ((sl.indices[0] != eBoundSize) and (sl.indices[1] != eBoundSize)) {
auto meas = makeMeasurement(sl, sl.parameters, sl.covariance, sl.indices[0],
sl.indices[1]);
trackState.setCalibrated(meas);
return meas;
} else if (sl.indices[0] != eBoundSize) {
auto meas =
makeMeasurement(sl, sl.parameters.head<1>(),
sl.covariance.topLeftCorner<1, 1>(), sl.indices[0]);
trackState.setCalibrated(meas);
return meas;
} else {
throw std::runtime_error(
"Tried to extract measurement from invalid TestSourceLink");
}
}
MultiTrajectory::TrackStateProxy trackState);

/// Extract the measurement from a TestSourceLink.
///
/// @param gctx Unused
/// @param trackState TrackState to calibrated
void testSourceLinkCalibrator(const GeometryContext& gctx,
MultiTrajectory::TrackStateProxy trackState) {
testSourceLinkCalibratorReturn(gctx, trackState);
}
MultiTrajectory::TrackStateProxy trackState);

} // namespace Test
} // namespace Acts

0 comments on commit f4cc9e3

Please sign in to comment.