From 75401b9958901ea79fce3b460c5f463f90660322 Mon Sep 17 00:00:00 2001 From: AJPfleger Date: Sun, 27 Oct 2024 12:28:38 +0100 Subject: [PATCH] update Surface tests --- .../Core/Surfaces/AnnulusBoundsTests.cpp | 17 ++- .../Core/Surfaces/BoundaryToleranceTests.cpp | 7 +- .../Core/Surfaces/ConeBoundsTests.cpp | 45 ++++---- .../Core/Surfaces/ConeSurfaceTests.cpp | 52 +++++---- .../Core/Surfaces/CylinderBoundsTests.cpp | 102 +++++++++--------- .../Core/Surfaces/CylinderSurfaceTests.cpp | 10 +- .../Core/Surfaces/DiamondBoundsTests.cpp | 74 +++++++------ .../Core/Surfaces/DiscSurfaceTests.cpp | 38 ++++--- .../Surfaces/DiscTrapezoidBoundsTests.cpp | 70 ++++++------ .../Core/Surfaces/EllipseBoundsTests.cpp | 25 +++-- .../Core/Surfaces/InfiniteBoundsTests.cpp | 12 +-- .../Core/Surfaces/LineBoundsTests.cpp | 78 +++++++------- .../Core/Surfaces/LineSurfaceTests.cpp | 68 ++++++------ .../Core/Surfaces/PerigeeSurfaceTests.cpp | 24 +++-- .../Core/Surfaces/PlaneSurfaceTests.cpp | 77 +++++++------ .../Core/Surfaces/RadialBoundsTests.cpp | 24 +++-- .../Core/Surfaces/RectangleBoundsTests.cpp | 46 ++++---- .../Core/Surfaces/StrawSurfaceTests.cpp | 42 ++++---- .../Core/Surfaces/SurfaceArrayTests.cpp | 9 +- .../Core/Surfaces/SurfaceBoundsTests.cpp | 7 ++ .../Surfaces/SurfaceIntersectionTests.cpp | 14 +-- .../SurfaceLocalToGlobalRoundtripTests.cpp | 16 +-- Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp | 2 +- .../UnitTests/Core/Surfaces/SurfaceTests.cpp | 42 ++++---- .../Core/Surfaces/TrapezoidBoundsTests.cpp | 59 +++++----- .../Core/Surfaces/VerticesHelperTests.cpp | 2 +- 26 files changed, 501 insertions(+), 461 deletions(-) diff --git a/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp index 9f09fb2c213..60ecc7f84e4 100644 --- a/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/AnnulusBoundsTests.cpp @@ -23,12 +23,12 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) -ActsScalar minRadius = 7.2; -ActsScalar maxRadius = 12.0; -ActsScalar minPhi = 0.74195; -ActsScalar maxPhi = 1.33970; +const ActsScalar minRadius = 7.2; +const ActsScalar maxRadius = 12.0; +const ActsScalar minPhi = 0.74195; +const ActsScalar maxPhi = 1.33970; -Vector2 offset(-2., 2.); +const Vector2 offset(-2., 2.); // Unit tests for AnnulusBounds constructors BOOST_AUTO_TEST_CASE(AnnulusBoundsConstruction) { @@ -60,13 +60,13 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsExcpetion) { // Exception for swapped radii BOOST_CHECK_THROW(AnnulusBounds(maxRadius, minRadius, minPhi, maxPhi, offset), std::logic_error); - // Exception for out of range min phi + // Exception for out of range min phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, -4., maxPhi, offset), std::logic_error); - // Exception for out of range max phi + // Exception for out of range max phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, minPhi, 4., offset), std::logic_error); - // Exception for out of range max phi + // Exception for out of range max phi BOOST_CHECK_THROW(AnnulusBounds(minRadius, maxRadius, maxPhi, minPhi, offset), std::logic_error); } @@ -76,7 +76,6 @@ BOOST_AUTO_TEST_CASE(AnnulusBoundsProperties) { /// Test construction with radii and default sector AnnulusBounds aBounds(minRadius, maxRadius, minPhi, maxPhi, offset); - // /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(aBounds.type(), SurfaceBounds::eAnnulus); diff --git a/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp b/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp index cd49b409f5b..edc401e9b83 100644 --- a/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/BoundaryToleranceTests.cpp @@ -20,8 +20,6 @@ #include #include -#include "BoundaryToleranceTestsRefs.hpp" - namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) @@ -42,6 +40,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckBoxSimple) { BOOST_CHECK( !detail::insideAlignedBox(ll, ur, tolerance, {2, 0}, std::nullopt)); } + // Aligned box w/ tolerance check along first axis BOOST_AUTO_TEST_CASE(BoundaryCheckBoxToleranceLoc0) { boost::execution_monitor em; @@ -73,7 +72,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckBoxCovariance) { cov << 1, 0.5, 0.5, 2; Vector2 ll(-1, -1); Vector2 ur(1, 1); - auto tolerance = BoundaryTolerance::Chi2Bound(cov.inverse(), 3.0); + auto tolerance = BoundaryTolerance::Chi2Bound(cov.inverse(), 3.); BOOST_CHECK( detail::insideAlignedBox(ll, ur, tolerance, {0, 0}, std::nullopt)); BOOST_CHECK( @@ -190,7 +189,7 @@ BOOST_AUTO_TEST_CASE(BoundaryCheckDifferentTolerances) { { auto tolerance = - BoundaryTolerance::Chi2Bound(SquareMatrix2::Identity(), 1.0); + BoundaryTolerance::Chi2Bound(SquareMatrix2::Identity(), 1.); BOOST_CHECK( detail::insideAlignedBox(ll, ur, tolerance, {0, 0}, std::nullopt)); BOOST_CHECK( diff --git a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp index 02ee3639482..ba38f5d11c1 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeBoundsTests.cpp @@ -24,10 +24,11 @@ // Note on nomenclature: // - alpha = cone opening half angle // - z is the axis of symmetry -// - zmin, zmax define limits for truncated cone +// - zMin, zMax define limits for truncated cone // - phi is clock angle around cone, with x axis corresponding to phi=0 -// - Cone segments may be defined with the avphi (central position of segment) -// and halfphi (extent in phi of cone segment either side of the avphi) +// - Cone segments may be defined with the averagePhi (central position of +// segment) and halfPhi (extent in phi of cone segment either side of the +// averagePhi) // - Local coords are z, rphi namespace Acts::Test { @@ -41,10 +42,10 @@ const double halfPhi = std::numbers::pi / 4.; const double averagePhi = 0.; const bool symmetric = false; -// Unit test for creating compliant/non-compliant ConeBounds object +/// Unit test for creating compliant/non-compliant ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { - // test default construction - // ConeBounds defaultConstructedConeBounds; // deleted + /// Test default construction + // default construction is deleted BOOST_TEST_CHECKPOINT("Four parameter constructor (last two at default)"); ConeBounds defaultConeBounds(alpha, symmetric); @@ -69,7 +70,7 @@ BOOST_AUTO_TEST_CASE(ConeBoundsConstruction) { BOOST_CHECK_EQUAL(copyConstructedConeBounds, fiveParamConstructedConeBounds); } -// Streaning and recreation test +/// Streaning and recreation test BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) { ConeBounds original(alpha, zMin, zMax, halfPhi, averagePhi); auto valvector = original.values(); @@ -80,7 +81,7 @@ BOOST_AUTO_TEST_CASE(ConeBoundsRecreation) { BOOST_CHECK_EQUAL(recreated, original); } -// Unit tests for AnnulusBounds exception throwing +/// Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { // Exception for opening angle smaller 0 BOOST_CHECK_THROW(ConeBounds(-alpha, zMin, zMax, halfPhi, averagePhi), @@ -99,47 +100,47 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { BOOST_CHECK_THROW(ConeBounds(alpha, zMin, zMax, -halfPhi, averagePhi), std::logic_error); - // Exception for out of range phi positioning + // Exception for out of range phi positioning BOOST_CHECK_THROW( ConeBounds(alpha, zMin, zMax, halfPhi, 2 * std::numbers::pi), std::logic_error); } -// Unit tests for properties of ConeBounds object +/// Unit tests for properties of ConeBounds object BOOST_AUTO_TEST_CASE(ConeBoundsProperties) { const Vector2 origin(0, 0); const Vector2 somewhere(4., 4.); ConeBounds coneBoundsObject(alpha, zMin, zMax, halfPhi, averagePhi); - // test for type (redundant) + /// Test for type (redundant) BOOST_CHECK_EQUAL(coneBoundsObject.type(), SurfaceBounds::eCone); - // test for inside + /// Test for inside BOOST_CHECK(!coneBoundsObject.inside(origin)); - // test for r + /// Test for r CHECK_CLOSE_REL(coneBoundsObject.r(zMin), zMin * std::tan(alpha), 1e-6); - // test for tanAlpha + /// Test for tanAlpha CHECK_CLOSE_REL(coneBoundsObject.tanAlpha(), std::tan(alpha), 1e-6); - // test for alpha + /// Test for alpha CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eAlpha), alpha, 1e-6); - // test for minZ + /// Test for minZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMinZ), zMin, 1e-6); - // test for maxZ + /// Test for maxZ CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eMaxZ), zMax, 1e-6); - // test for averagePhi + /// Test for averagePhi CHECK_CLOSE_REL(coneBoundsObject.get(ConeBounds::eHalfPhiSector), halfPhi, 1e-6); - // test for dump - boost::test_tools::output_test_stream dumpOuput; - coneBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + coneBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, averagePhi) = " "(0.4142136, 3.0000000, 6.0000000, 0.7853982, 0.0000000)")); } diff --git a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp index 18fa0e93410..5d0102653b2 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp @@ -7,6 +7,7 @@ // file, You can obtain one at https://mozilla.org/MPL/2.0/. #include +#include #include #include "Acts/Definitions/Algebra.hpp" @@ -37,9 +38,10 @@ BOOST_AUTO_TEST_SUITE(ConeSurfaces) /// Unit test for creating compliant/non-compliant ConeSurface object BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { - // ConeSurface default constructor is deleted - // - // Constructor with transform, alpha and symmetry indicator + /// Test default construction + // default construction is deleted + + /// Constructor with transform, alpha and symmetry indicator const double alpha = std::numbers::pi / 8.; const double halfPhiSector = std::numbers::pi / 16.; const double zMin = 1.; @@ -56,34 +58,32 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceConstruction) { Surface::makeShared(pTransform, alpha, symmetric)->type(), Surface::Cone); - // Constructor with transform pointer, alpha,z min and max, halfPhiSector + /// Constructor with transform pointer, alpha,z min and max, halfPhiSector BOOST_CHECK_EQUAL(Surface::makeShared(pTransform, alpha, zMin, zMax, halfPhiSector) ->type(), Surface::Cone); - // Constructor with transform and ConeBounds pointer - // ConeBounds (double alpha, double zmin, double zmax, double - // halfphi=std::numbers::pi, double avphi=0.) + /// Constructor with transform and ConeBounds pointer auto pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pConeBounds)->type(), Surface::Cone); - // Copy constructor + /// Copy constructor auto coneSurfaceObject = Surface::makeShared(pTransform, alpha, symmetric); auto copiedConeSurface = Surface::makeShared(*coneSurfaceObject); BOOST_CHECK_EQUAL(copiedConeSurface->type(), Surface::Cone); BOOST_CHECK(*copiedConeSurface == *coneSurfaceObject); - // Copied and transformed + /// Copied and transformed auto copiedTransformedConeSurface = Surface::makeShared( tgContext, *coneSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedConeSurface->type(), Surface::Cone); - // Construct with nullptr bounds + /// Construct with nullptr bounds BOOST_CHECK_THROW(auto nullBounds = Surface::makeShared( Transform3::Identity(), nullptr), AssertionFailureException); @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { binningPosition, 1e-6); /// Test referenceFrame - Vector3 globalPosition{2.0, 2.0, 2.0}; + Vector3 globalPosition{2., 2., 2.}; Vector3 momentum{1.e6, 1.e6, 1.e6}; double rootHalf = std::sqrt(0.5); RotationMatrix3 expectedFrame; @@ -143,7 +143,6 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceProperties) { Vector2 localPosition{1., std::numbers::pi / 2.}; globalPosition = coneSurfaceObject->localToGlobal(tgContext, localPosition, momentum); - // std::cout<globalToLocal(tgContext, globalPosition, momentum) .value(); - // std::cout<toStream(tgContext); + BOOST_CHECK(dumpOutput.is_equal( + "Acts::ConeSurface\n" + " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" + " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" + " colY = (0.000000, 1.000000, 0.000000)\n" + " colZ = (0.000000, 0.000000, 1.000000)\n" + " Bounds : Acts::ConeBounds: (tanAlpha, minZ, maxZ, halfPhiSector, " + "averagePhi) = (0.4142136, 0.0000000, inf, 3.1415927, 0.0000000)" + + )); } BOOST_AUTO_TEST_CASE(ConeSurfaceEqualityOperators) { @@ -220,7 +218,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { const double zMax = 10.; const Translation3 translation{0., 0., 0.}; // != {0., 1., 2.} - // Testing a Full cone + /// Testing a Full cone auto pTransform = Transform3(translation); auto pConeBounds = std::make_shared(alpha, zMin, zMax); auto pCone = Surface::makeShared(pTransform, pConeBounds); @@ -244,7 +242,7 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binY), s_onSurfaceTolerance); - // Now a sector + /// Now a sector pConeBounds = std::make_shared(alpha, zMin, zMax, halfPhiSector, 0.); pCone = Surface::makeShared(pTransform, pConeBounds); diff --git a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp index 71192421737..14cafdd045b 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderBoundsTests.cpp @@ -28,43 +28,42 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant CylinderBounds object BOOST_AUTO_TEST_CASE(CylinderBoundsConstruction) { - /// test default construction - // CylinderBounds defaultConstructedCylinderBounds; // deleted + /// Test default construction + // default construction is deleted + const double radius = 0.5; - const double halfz = 10.; - const double halfphi = std::numbers::pi / 2.; + const double halfZ = 10.; + const double halfPhi = std::numbers::pi / 2.; const double averagePhi = std::numbers::pi / 2.; const double bevelMinZ = -std::numbers::pi / 4.; const double bevelMaxZ = std::numbers::pi / 6.; - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi).type(), SurfaceBounds::eCylinder); - BOOST_CHECK_EQUAL(CylinderBounds(radius, halfz, halfphi, averagePhi).type(), + BOOST_CHECK_EQUAL(CylinderBounds(radius, halfZ, halfPhi, averagePhi).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL( - CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ).type(), + CylinderBounds(radius, halfZ, std::numbers::pi, 0., bevelMinZ).type(), SurfaceBounds::eCylinder); BOOST_CHECK_EQUAL( - CylinderBounds(radius, halfz, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) + CylinderBounds(radius, halfZ, std::numbers::pi, 0., bevelMinZ, bevelMaxZ) .type(), SurfaceBounds::eCylinder); - // - /// test copy construction; - CylinderBounds cylinderBounds(radius, halfz); + + /// Test copy construction; + CylinderBounds cylinderBounds(radius, halfZ); CylinderBounds copyConstructedCylinderBounds(cylinderBounds); BOOST_CHECK_EQUAL(copyConstructedCylinderBounds, cylinderBounds); } BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { - /// test default construction - // CylinderBounds defaultConstructedCylinderBounds; // deleted const double radius = 0.5; - const double halfz = 10.; + const double halfZ = 10.; // Test construction with radii and default sector - auto original = CylinderBounds(radius, halfz); + auto original = CylinderBounds(radius, halfZ); auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), CylinderBounds::eSize, values.begin()); @@ -74,56 +73,56 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsRecreation) { BOOST_AUTO_TEST_CASE(CylinderBoundsException) { const double radius = 0.5; - const double halfz = 10.; - const double halfphi = std::numbers::pi / 2.; + const double halfZ = 10.; + const double halfPhi = std::numbers::pi / 2.; const double averagePhi = std::numbers::pi / 2.; - // Negative radius - BOOST_CHECK_THROW(CylinderBounds(-radius, halfz, halfphi, averagePhi), + /// Negative radius + BOOST_CHECK_THROW(CylinderBounds(-radius, halfZ, halfPhi, averagePhi), std::logic_error); - // Negative half length in z - BOOST_CHECK_THROW(CylinderBounds(radius, -halfz, halfphi, averagePhi), + /// Negative half length in z + BOOST_CHECK_THROW(CylinderBounds(radius, -halfZ, halfPhi, averagePhi), std::logic_error); - // Negative half sector in phi - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, -halfphi, averagePhi), + /// Negative half sector in phi + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, -halfPhi, averagePhi), std::logic_error); - // Half sector in phi out of bounds - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, 4., averagePhi), + /// Half sector in phi out of bounds + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, 4., averagePhi), std::logic_error); - // Phi position out of bounds - BOOST_CHECK_THROW(CylinderBounds(radius, halfz, halfphi, 4.), + /// Phi position out of bounds + BOOST_CHECK_THROW(CylinderBounds(radius, halfZ, halfPhi, 4.), std::logic_error); } /// Unit tests for CylinderBounds properties BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { - // CylinderBounds object of radius 0.5 and halfz 20 + // CylinderBounds object of radius 0.5 and halfZ 20 const double radius = 0.5; - const double halfz = 20.; // != 10. - const double halfphi = std::numbers::pi / 4.; // != pi/2 + const double halfZ = 20.; // != 10. + const double halfPhi = std::numbers::pi / 4.; // != pi/2 const double averagePhi = 0.; // != pi/2 const double bevelMinZ = std::numbers::pi / 4.; // != -pi/4 const double bevelMaxZ = std::numbers::pi / 6.; - CylinderBounds cylinderBoundsObject(radius, halfz); - CylinderBounds cylinderBoundsSegment(radius, halfz, halfphi, averagePhi); - CylinderBounds cylinderBoundsBeveledObject(radius, halfz, std::numbers::pi, + CylinderBounds cylinderBoundsObject(radius, halfZ); + CylinderBounds cylinderBoundsSegment(radius, halfZ, halfPhi, averagePhi); + CylinderBounds cylinderBoundsBeveledObject(radius, halfZ, std::numbers::pi, 0., bevelMinZ, bevelMaxZ); - /// test for type() + /// Test for type() BOOST_CHECK_EQUAL(cylinderBoundsObject.type(), SurfaceBounds::eCylinder); - /// test for inside(), 2D coords are r or phi ,z? : needs clarification + /// Test for inside(), 2D coords are r or phi ,z? : needs clarification const Vector2 origin{0., 0.}; const Vector2 atPiBy2{std::numbers::pi / 2., 0.}; const Vector2 atPi{std::numbers::pi, 0.}; const Vector2 beyondEnd{0, 30.}; - const Vector2 unitZ{0.0, 1.0}; - const Vector2 unitPhi{1.0, 0.0}; + const Vector2 unitZ{0., 1.}; + const Vector2 unitPhi{1., 0.}; const Vector2 withinBevelMin{0.5, -20.012}; const Vector2 outsideBevelMin{0.5, -40.}; const BoundaryTolerance tolerance = @@ -141,42 +140,43 @@ BOOST_AUTO_TEST_CASE(CylinderBoundsProperties) { BOOST_CHECK( !cylinderBoundsBeveledObject.inside(outsideBevelMin, lessTolerance)); - /// test for r() + /// Test for r() CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eR), radius, 1e-6); - /// test for averagePhi + /// Test for averagePhi CHECK_CLOSE_OR_SMALL(cylinderBoundsObject.get(CylinderBounds::eAveragePhi), averagePhi, 1e-6, 1e-6); - /// test for halfPhiSector + /// Test for halfPhiSector CHECK_CLOSE_REL(cylinderBoundsSegment.get(CylinderBounds::eHalfPhiSector), - halfphi, + halfPhi, 1e-6); // fail - /// test for halflengthZ (NOTE: Naming violation) - CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), halfz, + /// Test for halflengthZ (NOTE: Naming violation) + CHECK_CLOSE_REL(cylinderBoundsObject.get(CylinderBounds::eHalfLengthZ), halfZ, 1e-6); - /// test for bevelMinZ/MaxZ + /// Test for bevelMinZ/MaxZ CHECK_CLOSE_REL(cylinderBoundsBeveledObject.get(CylinderBounds::eBevelMinZ), bevelMinZ, 1e-6); CHECK_CLOSE_REL(cylinderBoundsBeveledObject.get(CylinderBounds::eBevelMaxZ), bevelMaxZ, 1e-6); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - cylinderBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + cylinderBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, " "averagePhi, bevelMinZ, bevelMaxZ) = (0.5000000, 20.0000000, 3.1415927, " "0.0000000, 0.0000000, 0.0000000)")); } + /// Unit test for testing CylinderBounds assignment BOOST_AUTO_TEST_CASE(CylinderBoundsAssignment) { const double radius = 0.5; - const double halfz = 20.; // != 10. + const double halfZ = 20.; // != 10. - CylinderBounds cylinderBoundsObject(radius, halfz); + CylinderBounds cylinderBoundsObject(radius, halfZ); CylinderBounds assignedCylinderBounds(10.5, 6.6); assignedCylinderBounds = cylinderBoundsObject; diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 09ba3895177..4dd6f7f6905 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -55,8 +55,9 @@ GeometryContext testContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(CylinderSurfaces) /// Unit test for creating compliant/non-compliant CylinderSurface object BOOST_AUTO_TEST_CASE(CylinderSurfaceConstruction) { - // CylinderSurface default constructor is deleted - // + /// Test default construction + // default construction is deleted + /// Constructor with transform, radius and halfZ const double radius = 1.; const double halfZ = 10.; @@ -105,7 +106,6 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { /// Test clone method const double radius = 1.; const double halfZ = 10.; - // const double halfPhiSector = std::numbers::pi / 8.; const Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { /// Test referenceFrame const double invSqrt2 = 1. / std::numbers::sqrt2; Vector3 globalPosition{invSqrt2, 1. - invSqrt2, 0.}; - Vector3 globalPositionZ{invSqrt2, 1. - invSqrt2, 2.0}; + Vector3 globalPositionZ{invSqrt2, 1. - invSqrt2, 2.}; Vector3 momentum{15., 15., 15.}; Vector3 momentum2{6.6, -3., 2.}; RotationMatrix3 expectedFrame; @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { BOOST_CHECK(!cylinderSurfaceObject->isOnSurface(testContext, offSurface, BoundaryTolerance::None())); - /// intersection test + /// Intersection test Vector3 direction{-1., 0, 0}; auto sfIntersection = cylinderSurfaceObject->intersect( testContext, offSurface, direction, BoundaryTolerance::Infinite()); diff --git a/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp index ecd5909f932..1869cde057d 100644 --- a/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiamondBoundsTests.cpp @@ -24,22 +24,26 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant DiamondBounds object BOOST_AUTO_TEST_CASE(DiamondBoundsConstruction) { - double minHalfX(10.), midHalfX(20.), maxHalfX(15.), halfY1(5.), halfY2(7.); - // test default construction - // DiamondBounds defaultConstructedDiamondBounds; //deleted - // + /// Test default construction + // default construction is deleted + + const double minHalfX = 10.; + const double midHalfX = 20.; + const double maxHalfX = 15.; + const double halfY1 = 5.; + const double halfY2 = 7.; + /// Test construction with dimensions - // DiamondBounds d(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); BOOST_CHECK_EQUAL( DiamondBounds(minHalfX, midHalfX, maxHalfX, halfY1, halfY2).type(), SurfaceBounds::eDiamond); - // + /// Copy constructor DiamondBounds original(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); DiamondBounds copied(original); BOOST_CHECK_EQUAL(copied.type(), SurfaceBounds::eDiamond); - // invalid inputs + /// Test invalid inputs BOOST_CHECK_THROW( DiamondBounds db(midHalfX, minHalfX, maxHalfX, halfY1, halfY2), std::logic_error); @@ -47,66 +51,66 @@ BOOST_AUTO_TEST_CASE(DiamondBoundsConstruction) { DiamondBounds db(minHalfX, maxHalfX, midHalfX, halfY1, halfY2), std::logic_error); } + /// Unit tests for DiamondBounds properties BOOST_AUTO_TEST_CASE(DiamondBoundsProperties) { - double minHalfX(10.), midHalfX(50.), maxHalfX(30.), halfY1(10.), halfY2(20.); + const double minHalfX = 10.; + const double midHalfX = 50.; // != 20. + const double maxHalfX = 30.; // != 15. + const double halfY1 = 10.; // != 5. + const double halfY2 = 20.; // != 7. + /// Test clone DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(diamondBoundsObject.type(), SurfaceBounds::eDiamond); - // //redundant test - // + /// Test the half length at negative y BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXnegY), minHalfX); - // + /// Test the half length at the x axis BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXzeroY), midHalfX); - // + /// Test the half length at positive y BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthXposY), maxHalfX); - // + /// Test half length into the negative side BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYneg), halfY1); - // + /// Test half length into the positive side BOOST_CHECK_EQUAL(diamondBoundsObject.get(DiamondBounds::eHalfLengthYpos), halfY2); - // + /// Test boundingBox BOOST_CHECK_EQUAL(diamondBoundsObject.boundingBox(), RectangleBounds(Vector2{-50., -10.}, Vector2{50., 20.})); - // - // clone already tested - // + /// Test distanceToBoundary Vector2 origin(0., 0.); Vector2 outsideBy10(0., 30.); Vector2 inRectangle(15., 0.); /// Test dump - // Acts::DiamondBounds: (minHlengthX, medHlengthX, maxHlengthX, hlengthY1, - // hlengthY2 ) = (30.0000000, 10.0000000, 50.0000000, 10.0000000, - // 20.0000000) diamondBoundsObject.toStream(std::cout); - boost::test_tools::output_test_stream dumpOuput; - diamondBoundsObject.toStream(dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + diamondBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::DiamondBounds: (halfXatYneg, halfXatYzero, " - "halfXatYpos, halfYneg, halfYpos) = (10.0000000, " - "50.0000000, 30.0000000, 10.0000000, 20.0000000)")); - // + dumpOutput.is_equal("Acts::DiamondBounds: (halfXatYneg, halfXatYzero, " + "halfXatYpos, halfYneg, halfYpos) = (10.0000000, " + "50.0000000, 30.0000000, 10.0000000, 20.0000000)")); + /// Test inside BOOST_CHECK(diamondBoundsObject.inside(origin, BoundaryTolerance::None())); // dont understand why this is so: BOOST_CHECK( !diamondBoundsObject.inside(outsideBy10, BoundaryTolerance::None())); - // + /// Test vertices (does this need to be implemented in this class?? // auto v=diamondBoundsObject.vertices(); std::vector referenceVertices{ @@ -117,20 +121,28 @@ BOOST_AUTO_TEST_CASE(DiamondBoundsProperties) { referenceVertices.cbegin(), referenceVertices.cend()); } + /// Unit test for testing DiamondBounds assignment BOOST_AUTO_TEST_CASE(DiamondBoundsAssignment) { - double minHalfX(10.), midHalfX(20.), maxHalfX(15.), halfY1(5.), halfY2(7.); + const double minHalfX = 10.; + const double midHalfX = 20.; + const double maxHalfX = 15.; + const double halfY1 = 5.; + const double halfY2 = 7.; + DiamondBounds diamondBoundsObject(minHalfX, midHalfX, maxHalfX, halfY1, halfY2); DiamondBounds similarlyConstructeDiamondBoundsObject( minHalfX, midHalfX, maxHalfX, halfY1, halfY2); + /// Test operator == BOOST_CHECK_EQUAL(diamondBoundsObject, similarlyConstructeDiamondBoundsObject); - // + /// Test assignment DiamondBounds assignedDiamondBoundsObject( 2 * minHalfX, 2 * midHalfX, 2 * maxHalfX, 2 * halfY1, 2 * halfY2); + // object, in some sense assignedDiamondBoundsObject = diamondBoundsObject; BOOST_CHECK_EQUAL(assignedDiamondBoundsObject, diamondBoundsObject); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index ed8a229c340..b5d1eec5f43 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -54,8 +54,9 @@ auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE); BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit tests for creating DiscSurface object BOOST_AUTO_TEST_CASE(DiscSurfaceConstruction) { - // default constructor is deleted - // scaffolding... + /// Test default construction + // default construction is deleted + const double rMin = 1.; const double rMax = 5.; const double halfPhiSector = std::numbers::pi / 8.; @@ -109,13 +110,10 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext), zAxis); /// Test normal, local position specified - Vector2 lpos(2.0, 0.05); + Vector2 lpos(2., 0.05); BOOST_CHECK_EQUAL(discSurfaceObject->normal(tgContext, lpos), zAxis); /// Test binningPosition - // auto binningPosition= - // discSurfaceObject.binningPosition(BinningValue::BinningValue::binRPhi ); - // std::cout<binningPosition(tgContext, BinningValue::binRPhi), origin3D); @@ -125,8 +123,8 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { Vector3 ignoredMomentum{0., 0., 0.}; /// Test isOnSurface() - Vector3 point3DNotInSector{0.0, 1.2, 0}; - Vector3 point3DOnSurface{1.2, 0.0, 0}; + Vector3 point3DNotInSector{0., 1.2, 0}; + Vector3 point3DOnSurface{1.2, 0., 0}; BOOST_CHECK(!discSurfaceObject->isOnSurface(tgContext, point3DNotInSector, ignoredMomentum, BoundaryTolerance::None())); @@ -140,21 +138,21 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { /// Test localToGlobal Vector3 returnedPosition{10.9, 8.7, 6.5}; Vector3 expectedPosition{1.2, 0, 0}; - Vector2 rPhiOnDisc{1.2, 0.0}; + Vector2 rPhiOnDisc{1.2, 0.}; Vector2 rPhiNotInSector{ 1.2, std::numbers::pi}; // outside sector at Phi=0, +/- pi/8 returnedPosition = discSurfaceObject->localToGlobal(tgContext, rPhiOnDisc, ignoredMomentum); CHECK_CLOSE_ABS(returnedPosition, expectedPosition, 1e-6); - // + returnedPosition = discSurfaceObject->localToGlobal( tgContext, rPhiNotInSector, ignoredMomentum); Vector3 expectedNonPosition{-1.2, 0, 0}; CHECK_CLOSE_ABS(returnedPosition, expectedNonPosition, 1e-6); - // + /// Test globalToLocal Vector2 returnedLocalPosition{33., 44.}; - Vector2 expectedLocalPosition{1.2, 0.0}; + Vector2 expectedLocalPosition{1.2, 0.}; returnedLocalPosition = discSurfaceObject ->globalToLocal(tgContext, point3DOnSurface, ignoredMomentum) @@ -167,7 +165,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { ->globalToLocal(tgContext, point3DNotInSector, ignoredMomentum) .value(); - Vector3 pointOutsideR{0.0, 100., 0}; + Vector3 pointOutsideR{0., 100., 0}; returnedLocalPosition = discSurfaceObject ->globalToLocal(tgContext, pointOutsideR, ignoredMomentum) @@ -243,7 +241,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceAssignment) { Transform3::Identity(), rMin, rMax, halfPhiSector); auto assignedDisc = Surface::makeShared(Transform3::Identity(), 2.2, 4.4, 0.07); - // + BOOST_CHECK_NO_THROW(*assignedDisc = *discSurfaceObject); BOOST_CHECK((*assignedDisc) == (*discSurfaceObject)); } @@ -339,7 +337,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceAlignment) { globalPosition); // Check if the result is as expected ActsMatrix<2, 3> expLoc3DToLocBound = ActsMatrix<2, 3>::Zero(); - expLoc3DToLocBound << 0, 1, 0, -1.0 / 3, 0, 0; + expLoc3DToLocBound << 0, 1, 0, -1. / 3, 0, 0; CHECK_CLOSE_ABS(loc3DToLocBound, expLoc3DToLocBound, 1e-10); } @@ -419,12 +417,12 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { BOOST_AUTO_TEST_SUITE(DiscSurfaceMerging) namespace { -std::shared_ptr makeDisc(const Transform3& transform, double rmin, - double rmax, +std::shared_ptr makeDisc(const Transform3& transform, double rMin, + double rMax, double halfPhi = std::numbers::pi, double avgPhi = 0) { return Surface::makeShared( - transform, std::make_shared(rmin, rmax, halfPhi, avgPhi)); + transform, std::make_shared(rMin, rMax, halfPhi, avgPhi)); } } // namespace @@ -809,8 +807,8 @@ BOOST_DATA_TEST_CASE(PhiDirection, // bounds should be equal however BOOST_CHECK_EQUAL(disc76->bounds(), disc67->bounds()); - BOOST_CHECK(!reversed76); // not reversed either because you get the - // ordering you put in + // not reversed either because you get the ordering you put in + BOOST_CHECK(!reversed76); const auto* bounds67 = dynamic_cast(&disc67->bounds()); BOOST_REQUIRE_NE(bounds67, nullptr); diff --git a/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp index 1515ef79292..8f6117ef1b0 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscTrapezoidBoundsTests.cpp @@ -24,22 +24,26 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) -/// Unit tests for DiscTrapezoidBounds constrcuctors +const double minHalfX = 1.; +const double maxHalfX = 5.; +const double rMin = 2.; +const double rMax = 6.; +const double averagePhi = 0.; +const double stereo = 0.1; + +/// Unit tests for DiscTrapezoidBounds constructors BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsConstruction) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - // /// Test construction with dimensions and default stereo BOOST_CHECK_EQUAL( DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi).type(), SurfaceBounds::eDiscTrapezoid); - // + /// Test construction with all dimensions BOOST_CHECK_EQUAL( DiscTrapezoidBounds(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo) .type(), SurfaceBounds::eDiscTrapezoid); - // + /// Copy constructor DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi); DiscTrapezoidBounds copied(original); @@ -48,9 +52,6 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsConstruction) { // Streaning and recreation test BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsRecreation) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - DiscTrapezoidBounds original(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo); auto valvector = original.values(); @@ -62,9 +63,6 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsRecreation) { // Unit tests for AnnulusBounds exception throwing BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsExceptions) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); - // Exception for opening neg min half x < 0 BOOST_CHECK_THROW( DiscTrapezoidBounds(-minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo), @@ -103,74 +101,72 @@ BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsExceptions) { /// Unit tests for DiscTrapezoidBounds properties BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsProperties) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), - averagePhi(0.0) /*, stereo(0.1)*/; /// Test clone DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax, averagePhi); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(DiscTrapezoidBoundsObject.type(), SurfaceBounds::eDiscTrapezoid); - // + /// Test distanceToBoundary Vector2 origin(0., 0.); Vector2 outside(30., 0.); - Vector2 inSurface(2.5, 0.0); - // + Vector2 inSurface(2.5, 0.); + /// Test dump - boost::test_tools::output_test_stream dumpOuput; - DiscTrapezoidBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + boost::test_tools::output_test_stream dumpOutput; + DiscTrapezoidBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::DiscTrapezoidBounds: (innerRadius, outerRadius, halfLengthXminR, " "halfLengthXmaxR, halfLengthY, halfPhiSector, averagePhi, rCenter, " "stereo) = " "(2.0000000, 6.0000000, 1.0000000, 5.0000000, 0.7922870, 0.9851108, " "0.0000000, 2.5243378, 0.0000000)")); - // + /// Test inside BOOST_CHECK( DiscTrapezoidBoundsObject.inside(inSurface, BoundaryTolerance::None())); BOOST_CHECK( !DiscTrapezoidBoundsObject.inside(outside, BoundaryTolerance::None())); - // + /// Test rMin CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMin(), rMin, 1e-6); - // + /// Test rMax CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rMax(), rMax, 1e-6); - // + /// Test averagePhi CHECK_SMALL(DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eAveragePhi), 1e-9); - // + /// Test rCenter (redundant; not configurable) CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.rCenter(), 2.524337798, 1e-6); - // + /// Test halfPhiSector (redundant; not configurable) CHECK_SMALL(DiscTrapezoidBoundsObject.stereo(), 1e-6); - // - /// Test minHalflengthX + + /// Test minHalfLengthX CHECK_CLOSE_REL( DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXminR), minHalfX, 1e-6); - // - /// Test maxHalflengthX + + /// Test maxHalfLengthX CHECK_CLOSE_REL( DiscTrapezoidBoundsObject.get(DiscTrapezoidBounds::eHalfLengthXmaxR), maxHalfX, 1e-6); - // - /// Test halflengthY + + /// Test halfLengthY CHECK_CLOSE_REL(DiscTrapezoidBoundsObject.halfLengthY(), 0.792286991, 1e-6); } /// Unit test for testing DiscTrapezoidBounds assignment BOOST_AUTO_TEST_CASE(DiscTrapezoidBoundsAssignment) { - double minHalfX(1.0), maxHalfX(5.0), rMin(2.0), rMax(6.0), averagePhi(0.0), - stereo(0.1); DiscTrapezoidBounds DiscTrapezoidBoundsObject(minHalfX, maxHalfX, rMin, rMax, averagePhi, stereo); - // operator == not implemented in this class - // + + /// Test operator == + // not implemented in this class + /// Test assignment DiscTrapezoidBounds assignedDiscTrapezoidBoundsObject(2.1, 6.6, 3.4, 4.2, 0.3, 0.); diff --git a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp index 9ce67b66cff..0ed78e656f6 100644 --- a/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/EllipseBoundsTests.cpp @@ -36,15 +36,15 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsConstruction) { const double outerRx = 25.; const double outerRy = 30.; - // test default construction - // EllipseBounds defaultConstructedEllipseBounds; //deleted - // + /// Test default construction + // default construction is deleted + /// Test construction with dimensions BOOST_CHECK_EQUAL( EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi) .type(), SurfaceBounds::eEllipse); - // + /// Copy constructor EllipseBounds original(innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi); @@ -75,38 +75,47 @@ BOOST_AUTO_TEST_CASE(ConeBoundsExceptions) { BOOST_CHECK_THROW( EllipseBounds(-innerRx, innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRy < 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, -innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRx < 0 and innerRy < 0 BOOST_CHECK_THROW(EllipseBounds(-innerRx, -innerRy, outerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for opening outerRx <= 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, 0., outerRy, phiSector, averagePhi), std::logic_error); + // Exception for opening outerRy <= 0 BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, 0., phiSector, averagePhi), std::logic_error); + // Exception for iouterRx < 0 and outerRy < 0 BOOST_CHECK_THROW(EllipseBounds(innerRx, innerRy, -outerRx, -outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRx > outerRx BOOST_CHECK_THROW( EllipseBounds(outerRx, innerRy, innerRx, outerRy, phiSector, averagePhi), std::logic_error); + // Exception for innerRxy > outerRy BOOST_CHECK_THROW( EllipseBounds(innerRx, outerRy, outerRx, innerRy, phiSector, averagePhi), std::logic_error); + // Exception for negative phiSector BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, outerRy, -phiSector, averagePhi), std::logic_error); + // Exception for average phi out of bound BOOST_CHECK_THROW( EllipseBounds(innerRx, innerRy, outerRx, outerRy, phiSector, 4.), @@ -125,8 +134,6 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) { /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(ellipseBoundsObject.type(), SurfaceBounds::eEllipse); - // clone already tested - /// Test distanceToBoundary Vector2 origin{0., 0.}; Vector2 outsideBy15{0., 30.}; @@ -163,9 +170,9 @@ BOOST_AUTO_TEST_CASE(EllipseBoundsProperties) { std::numbers::pi / 2.); /// Test dump - boost::test_tools::output_test_stream dumpOuput; - ellipseBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + boost::test_tools::output_test_stream dumpOutput; + ellipseBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::EllipseBounds: (innerRadius0, outerRadius0, innerRadius1, " "outerRadius1, hPhiSector, averagePhi) = (10.0000000, 15.0000000, " "15.0000000, 20.0000000, 0.0000000, 1.5707963, 0.0000000)")); diff --git a/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp index d0097695286..b0c7fa0c94f 100644 --- a/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/InfiniteBoundsTests.cpp @@ -29,19 +29,19 @@ BOOST_AUTO_TEST_CASE(InfiniteBoundsConstruction) { /// Unit tests for InfiniteBounds properties BOOST_AUTO_TEST_CASE(InfiniteBoundsProperties) { InfiniteBounds infiniteBoundsObject; - /// test for type() + /// Test for type() BOOST_CHECK_EQUAL(infiniteBoundsObject.type(), SurfaceBounds::eBoundless); - /// test for inside() + /// Test for inside() const Vector2 anyVector{0., 1.}; const BoundaryTolerance anyTolerance = BoundaryTolerance::None(); BOOST_CHECK(infiniteBoundsObject.inside(anyVector, anyTolerance)); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - infiniteBoundsObject.toStream(dumpOuput); + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + infiniteBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::InfiniteBounds ... boundless surface\n")); + dumpOutput.is_equal("Acts::InfiniteBounds ... boundless surface\n")); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp index f972529bed0..c8022a9174c 100644 --- a/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineBoundsTests.cpp @@ -24,20 +24,24 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant LineBounds object BOOST_AUTO_TEST_CASE(LineBoundsConstruction) { - /// test LineBounds(double, double) - double radius(0.5), halfz(10.); - LineBounds lineBounds(radius, halfz); + const double radius = 0.5; + const double halfZ = 10.; + + /// Test LineBounds(double, double) + LineBounds lineBounds(radius, halfZ); BOOST_CHECK_EQUAL(lineBounds.type(), SurfaceBounds::eLine); - /// test copy construction; + + /// Test copy construction; LineBounds copyConstructedLineBounds(lineBounds); // implicit BOOST_CHECK_EQUAL(copyConstructedLineBounds.type(), SurfaceBounds::eLine); } /// Unit test for testing LineBounds recreation from streaming BOOST_AUTO_TEST_CASE(LineBoundsRecreation) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds original(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. + + LineBounds original(radius, halfZ); LineBounds recreated(original); auto valvector = original.values(); std::array values{}; @@ -47,45 +51,45 @@ BOOST_AUTO_TEST_CASE(LineBoundsRecreation) { /// Unit test for testing LineBounds exceptions BOOST_AUTO_TEST_CASE(LineBoundsExceptions) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; + const double radius = 0.5; + const double halfZ = 20.; // != 10. + // Negative radius - BOOST_CHECK_THROW(LineBounds(-nominalRadius, nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(-radius, halfZ), std::logic_error); + // Negative half length - BOOST_CHECK_THROW(LineBounds(nominalRadius, -nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(radius, -halfZ), std::logic_error); // Negative radius and half length - BOOST_CHECK_THROW(LineBounds(-nominalRadius, -nominalHalfLength), - std::logic_error); + BOOST_CHECK_THROW(LineBounds(-radius, -halfZ), std::logic_error); } /// Unit test for testing LineBounds assignment BOOST_AUTO_TEST_CASE(LineBoundsAssignment) { - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds lineBoundsObject(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. + + LineBounds lineBoundsObject(radius, halfZ); LineBounds assignedLineBounds = lineBoundsObject; BOOST_CHECK_EQUAL(assignedLineBounds, lineBoundsObject); } /// Unit tests for LineBounds properties BOOST_AUTO_TEST_CASE(LineBoundsProperties) { - // LineBounds object of radius 0.5 and halfz 20 - double nominalRadius{0.5}; - double nominalHalfLength{20.}; - LineBounds lineBoundsObject(nominalRadius, nominalHalfLength); + const double radius = 0.5; + const double halfZ = 20.; // != 10. - /// test for type() + LineBounds lineBoundsObject(radius, halfZ); + + /// Test for type() BOOST_CHECK_EQUAL(lineBoundsObject.type(), SurfaceBounds::eLine); - /// test for inside() + /// Test for inside() const Vector2 origin{0., 0.}; const Vector2 atRadius{0.5, 10.}; - const Vector2 beyondEnd{0.0, 30.0}; - const Vector2 unitZ{0.0, 1.0}; - const Vector2 unitR{1.0, 0.0}; + const Vector2 beyondEnd{0., 30.}; + const Vector2 unitZ{0., 1.}; + const Vector2 unitR{1., 0.}; const BoundaryTolerance tolerance = BoundaryTolerance::AbsoluteBound(0.1, 0.1); // This fails because the bounds are not inclusive. @@ -94,22 +98,20 @@ BOOST_AUTO_TEST_CASE(LineBoundsProperties) { BOOST_CHECK(lineBoundsObject.inside(unitZ, tolerance)); BOOST_CHECK(!lineBoundsObject.inside(unitR, tolerance)); - /// Test negative redius inside - + /// Test negative radius inside BOOST_CHECK(lineBoundsObject.inside(Vector2{-0.2, 10}, tolerance)); BOOST_CHECK(!lineBoundsObject.inside(Vector2{-0.8, 10}, tolerance)); - /// test for r() - BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), nominalRadius); + /// Test for r() + BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), radius); - /// test for halflengthZ (NOTE: Naming violation) - BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), - nominalHalfLength); + /// Test for halfLengthZ + BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), halfZ); - /// test for dump - boost::test_tools::output_test_stream dumpOuput; - lineBoundsObject.toStream(dumpOuput); - BOOST_CHECK(dumpOuput.is_equal( + /// Test for dump + boost::test_tools::output_test_stream dumpOutput; + lineBoundsObject.toStream(dumpOutput); + BOOST_CHECK(dumpOutput.is_equal( "Acts::LineBounds: (radius, halflengthInZ) = (0.5000000, 20.0000000)")); } diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index b4e7373fc7d..0175578a423 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -56,28 +56,34 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant LineSurface object BOOST_AUTO_TEST_CASE(LineSurface_Constructors_test) { - // Default ctor is deleted - // LineSurfaceStub l; - // ctor with translation, radius, halfz + /// Test default construction + // default construction is deleted + Translation3 translation{0., 1., 2.}; Transform3 transform(translation); auto pTransform = Transform3(translation); - const double radius{2.0}, halfz{20.}; - BOOST_CHECK(LineSurfaceStub(pTransform, radius, halfz).constructedOk()); - // ctor with nullptr for LineBounds + const double radius = 2.; + const double halfZ = 20.; + BOOST_CHECK(LineSurfaceStub(pTransform, radius, halfZ).constructedOk()); + + /// ctor with nullptr for LineBounds BOOST_CHECK(LineSurfaceStub(pTransform).constructedOk()); - // ctor with LineBounds - auto pLineBounds = std::make_shared(2., 10.0); + + /// ctor with LineBounds + auto pLineBounds = std::make_shared(2., 10.); BOOST_CHECK(LineSurfaceStub(pTransform, pLineBounds).constructedOk()); - // ctor with LineBounds, detector element, Identifier + + /// ctor with LineBounds, detector element, Identifier auto pMaterial = std::make_shared(makePercentSlab()); DetectorElementStub detElement{pTransform, pLineBounds, 0.2, pMaterial}; BOOST_CHECK(LineSurfaceStub(pLineBounds, detElement).constructedOk()); - LineSurfaceStub lineToCopy(pTransform, 2.0, 20.); - // Copy ctor + LineSurfaceStub lineToCopy(pTransform, 2., 20.); + + /// Copy ctor BOOST_CHECK(LineSurfaceStub(lineToCopy).constructedOk()); - // Copied and transformed ctor + + /// Copied and transformed ctor BOOST_CHECK( LineSurfaceStub(tgContext, lineToCopy, transform).constructedOk()); @@ -95,18 +101,18 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { // binningPosition() Translation3 translation{0., 1., 2.}; Transform3 transform(translation); - LineSurfaceStub line(transform, 2.0, 20.); + LineSurfaceStub line(transform, 2., 20.); Vector3 referencePosition{0., 1., 2.}; CHECK_CLOSE_ABS(referencePosition, line.binningPosition(tgContext, BinningValue::binX), 1e-6); - // + // bounds() - auto pLineBounds = std::make_shared(2., 10.0); + auto pLineBounds = std::make_shared(2., 10.); LineSurfaceStub boundedLine(transform, pLineBounds); const LineBounds& bounds = dynamic_cast(boundedLine.bounds()); - BOOST_CHECK_EQUAL(bounds, LineBounds(2., 10.0)); - // + BOOST_CHECK_EQUAL(bounds, LineBounds(2., 10.)); + // globalToLocal() Vector3 gpos{0., 1., 0.}; const Vector3 mom{20., 0., 0.}; // needs more realistic parameters @@ -114,7 +120,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { line.globalToLocal(tgContext, gpos, mom.normalized()).value(); const Vector2 expectedResult{0, -2}; CHECK_CLOSE_ABS(expectedResult, localPosition, 1e-6); - // + // intersection { const Vector3 direction{0., 1., 2.}; @@ -128,7 +134,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { 1e-6); // need more tests.. BOOST_CHECK_EQUAL(sfIntersection.object(), &line); } - // + // isOnSurface const Vector3 insidePosition{0., 2.5, 0.}; BOOST_CHECK(line.isOnSurface( @@ -137,7 +143,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { const Vector3 outsidePosition{100., 100., 200.}; BOOST_CHECK(!line.isOnSurface(tgContext, outsidePosition, mom, BoundaryTolerance::None())); - // + // localToGlobal Vector3 returnedGlobalPosition{0., 0., 0.}; // Vector2 localPosition{0., 0.}; @@ -146,7 +152,7 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { line.localToGlobal(tgContext, localPosition, momentum.normalized()); const Vector3 expectedGlobalPosition{0, 1, 0}; CHECK_CLOSE_ABS(returnedGlobalPosition, expectedGlobalPosition, 1e-6); - // + // referenceFrame Vector3 globalPosition{0., 0., 0.}; auto returnedRotationMatrix = @@ -155,42 +161,38 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { double v1 = std::sin(std::atan(2. / 3.)); RotationMatrix3 expectedRotationMatrix; expectedRotationMatrix << -v1, 0., v0, v0, 0., v1, 0., 1., -0.; - // std::cout<(unitXYZ); BOOST_CHECK_EQUAL(Surface::makeShared(unitXYZ)->type(), Surface::Perigee); - // + /// Constructor with transform Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL(Surface::makeShared(pTransform)->type(), Surface::Perigee); - // + /// Copy constructor auto copiedPerigeeSurface = Surface::makeShared(*perigeeSurfaceObject); BOOST_CHECK_EQUAL(copiedPerigeeSurface->type(), Surface::Perigee); BOOST_CHECK(*copiedPerigeeSurface == *perigeeSurfaceObject); - // + /// Copied and transformed auto copiedTransformedPerigeeSurface = Surface::makeShared( tgContext, *perigeeSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedPerigeeSurface->type(), Surface::Perigee); } -// + /// Unit test for testing PerigeeSurface properties BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) { /// Test clone method Vector3 unitXYZ{1., 1., 1.}; auto perigeeSurfaceObject = Surface::makeShared(unitXYZ); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(perigeeSurfaceObject->type(), Surface::Perigee); - // + /// Test name BOOST_CHECK_EQUAL(perigeeSurfaceObject->name(), std::string("Acts::PerigeeSurface")); - // + /// Test dump boost::test_tools::output_test_stream dumpOutput; dumpOutput << perigeeSurfaceObject->toStream(tgContext); @@ -74,15 +75,18 @@ BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) { BOOST_AUTO_TEST_CASE(EqualityOperators) { Vector3 unitXYZ{1., 1., 1.}; - Vector3 invalidPosition{0.0, 0.0, 0.0}; + Vector3 invalidPosition{0., 0., 0.}; auto perigeeSurfaceObject = Surface::makeShared(unitXYZ); auto perigeeSurfaceObject2 = Surface::makeShared(unitXYZ); auto assignedPerigeeSurface = Surface::makeShared(invalidPosition); + /// Test equality operator BOOST_CHECK(*perigeeSurfaceObject == *perigeeSurfaceObject2); + /// Test assignment *assignedPerigeeSurface = *perigeeSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedPerigeeSurface == *perigeeSurfaceObject); } diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index 63f7b539372..99d0569b9d2 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -6,7 +6,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. -// #include +#include #include #include "Acts/Definitions/Algebra.hpp" @@ -45,16 +45,20 @@ GeometryContext tgContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(PlaneSurfaces) /// Unit test for creating compliant/non-compliant PlaneSurface object BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { - // PlaneSurface default constructor is deleted + /// Test default construction + // default construction is deleted + // bounds object, rectangle type auto rBounds = std::make_shared(3., 4.); /// Constructor with transform and bounds Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); - // constructor with transform + + /// Constructor with transform BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, rBounds)->type(), Surface::Plane); + /// Copy constructor auto planeSurfaceObject = Surface::makeShared(pTransform, rBounds); @@ -62,7 +66,7 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { Surface::makeShared(*planeSurfaceObject); BOOST_CHECK_EQUAL(copiedPlaneSurface->type(), Surface::Plane); BOOST_CHECK(*copiedPlaneSurface == *planeSurfaceObject); - // + /// Copied and transformed auto copiedTransformedPlaneSurface = Surface::makeShared( tgContext, *planeSurfaceObject, pTransform); @@ -74,11 +78,12 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceConstruction) { auto nullBounds = Surface::makeShared(nullptr, detElem), AssertionFailureException); } -// + /// Unit test for testing PlaneSurface properties BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { // bounds object, rectangle type auto rBounds = std::make_shared(3., 4.); + /// Test clone method Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); @@ -89,17 +94,18 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { auto pTransform2 = Transform3(translation2); auto planeSurfaceObject2 = Surface::makeShared(pTransform2, rBounds); + /// Test type (redundant) BOOST_CHECK_EQUAL(planeSurfaceObject->type(), Surface::Plane); - // + /// Test binningPosition Vector3 binningPosition{0., 1., 2.}; BOOST_CHECK_EQUAL( planeSurfaceObject->binningPosition(tgContext, BinningValue::binX), binningPosition); - // + /// Test referenceFrame - Vector3 arbitraryGlobalPosition{2.0, 2.0, 2.0}; + Vector3 arbitraryGlobalPosition{2., 2., 2.}; Vector3 momentum{1.e6, 1.e6, 1.e6}; RotationMatrix3 expectedFrame; expectedFrame << 1., 0., 0., 0., 1., 0., 0., 0., 1.; @@ -107,11 +113,11 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { CHECK_CLOSE_OR_SMALL(planeSurfaceObject->referenceFrame( tgContext, arbitraryGlobalPosition, momentum), expectedFrame, 1e-6, 1e-9); - // + /// Test normal, given 3D position Vector3 normal3D(0., 0., 1.); BOOST_CHECK_EQUAL(planeSurfaceObject->normal(tgContext), normal3D); - // + /// Test bounds BOOST_CHECK_EQUAL(planeSurfaceObject->bounds().type(), SurfaceBounds::eRectangle); @@ -120,13 +126,12 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { Vector2 localPosition{1.5, 1.7}; Vector3 globalPosition = planeSurfaceObject->localToGlobal(tgContext, localPosition, momentum); - // // expected position is the translated one Vector3 expectedPosition{1.5 + translation.x(), 1.7 + translation.y(), translation.z()}; CHECK_CLOSE_REL(globalPosition, expectedPosition, 1e-2); - // + /// Testing globalToLocal localPosition = planeSurfaceObject->globalToLocal(tgContext, globalPosition, momentum) @@ -159,8 +164,8 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { BoundaryTolerance::None())); BOOST_CHECK(!planeSurfaceObject->isOnSurface(tgContext, offSurface, BoundaryTolerance::None())); - // - // Test intersection + + /// Test intersection Vector3 direction{0., 0., 1.}; auto sfIntersection = planeSurfaceObject ->intersect(tgContext, offSurface, direction, @@ -173,30 +178,30 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceProperties) { BOOST_CHECK_EQUAL(sfIntersection.pathLength(), expectedIntersect.pathLength()); BOOST_CHECK_EQUAL(sfIntersection.object(), planeSurfaceObject.get()); - // /// Test pathCorrection CHECK_CLOSE_REL(planeSurfaceObject->pathCorrection(tgContext, offSurface, momentum.normalized()), std::numbers::sqrt3, 0.01); - // + /// Test name BOOST_CHECK_EQUAL(planeSurfaceObject->name(), std::string("Acts::PlaneSurface")); - // + /// Test dump - // TODO 2017-04-12 msmk: check how to correctly check output - // boost::test_tools::output_test_stream dumpOuput; - // planeSurfaceObject.toStream(dumpOuput); - // BOOST_CHECK(dumpOuput.is_equal( - // "Acts::PlaneSurface\n" - // " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" - // " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" - // " colY = (0.000000, 1.000000, 0.000000)\n" - // " colZ = (0.000000, 0.000000, 1.000000)\n" - // " Bounds : Acts::ConeBounds: (tanAlpha, minZ, maxZ, averagePhi, - // halfPhiSector) = (0.4142136, 0.0000000, inf, 0.0000000, - // 3.1415927)")); + boost::test_tools::output_test_stream dumpOutput; + dumpOutput << planeSurfaceObject->toStream(tgContext); + BOOST_CHECK(dumpOutput.is_equal( + "Acts::PlaneSurface\n" + " Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n" + " Rotation: colX = (1.000000, 0.000000, 0.000000)\n" + " colY = (0.000000, 1.000000, 0.000000)\n" + " colZ = (0.000000, 0.000000, 1.000000)\n" + " Bounds : Acts::RectangleBounds: (hlX, hlY) = (3.0000000, " + "4.0000000)\n" + "(lower left, upper right):\n" + "-3.0000000 -4.0000000\n" + "3.0000000 4.0000000")); } BOOST_AUTO_TEST_CASE(PlaneSurfaceEqualityOperators) { @@ -208,16 +213,18 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceEqualityOperators) { Surface::makeShared(pTransform, rBounds); auto planeSurfaceObject2 = Surface::makeShared(pTransform, rBounds); - // + /// Test equality operator BOOST_CHECK(*planeSurfaceObject == *planeSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a PlaneSurface object to the existing one"); + /// Test assignment auto assignedPlaneSurface = Surface::makeShared(Transform3::Identity(), nullptr); *assignedPlaneSurface = *planeSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedPlaneSurface == *planeSurfaceObject); } @@ -283,10 +290,10 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceExtent) { } BOOST_AUTO_TEST_CASE(RotatedTrapezoid) { - double shortHalfX{100.}; - double longHalfX{200.}; - double halfY{300.}; - double rotAngle{45._degree}; + const double shortHalfX = 100.; + const double longHalfX = 200.; + const double halfY = 300.; + const double rotAngle = 45._degree; Vector2 edgePoint{longHalfX - 10., halfY}; diff --git a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp index 273462142a0..a25eeb4d352 100644 --- a/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RadialBoundsTests.cpp @@ -30,10 +30,10 @@ const double rMax = 5.; const double halfPhiSector = std::numbers::pi / 8.; const double avgPhi = 0.1; -/// Unit tests for RadialBounds constrcuctors +/// Unit tests for RadialBounds constructors BOOST_AUTO_TEST_CASE(RadialBoundsConstruction) { - // test default construction - // RadialBounds defaultConstructedRadialBounds; should be deleted + /// Test default construction + // default construction is deleted /// Test construction with radii and default sector BOOST_CHECK_EQUAL(RadialBounds(rMin, rMax).type(), SurfaceBounds::eDisc); @@ -93,15 +93,15 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { /// Test distanceToBoundary Vector2 outside(30., 0.); - Vector2 inSurface(2., 0.0); + Vector2 inSurface(2., 0.); /// Test dump - boost::test_tools::output_test_stream dumpOuput; - radialBoundsObject.toStream(dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + radialBoundsObject.toStream(dumpOutput); BOOST_CHECK( - dumpOuput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, " - "hPhiSector, averagePhi) = (1.0000000, " - "5.0000000, 0.3926991, 0.0000000)")); + dumpOutput.is_equal("Acts::RadialBounds: (innerRadius, outerRadius, " + "hPhiSector, averagePhi) = (1.0000000, " + "5.0000000, 0.3926991, 0.0000000)")); /// Test inside BOOST_CHECK(radialBoundsObject.inside(inSurface, BoundaryTolerance::None())); @@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eMaxR), rMax); /// Test averagePhi (should be a redundant method, this is not configurable) - BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.0); + BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eAveragePhi), 0.); /// Test halfPhiSector BOOST_CHECK_EQUAL(radialBoundsObject.get(RadialBounds::eHalfPhiSector), @@ -123,7 +123,9 @@ BOOST_AUTO_TEST_CASE(RadialBoundsProperties) { /// Unit test for testing RadialBounds assignment BOOST_AUTO_TEST_CASE(RadialBoundsAssignment) { RadialBounds radialBoundsObject(rMin, rMax, halfPhiSector); - // operator == not implemented in this class + + /// Test operator == + // not implemented in this class /// Test assignment RadialBounds assignedRadialBoundsObject(10.1, 123.); diff --git a/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp index 53c4df54861..ad310e393cf 100644 --- a/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/RectangleBoundsTests.cpp @@ -28,30 +28,35 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// Unit test for creating compliant/non-compliant RectangleBounds object BOOST_AUTO_TEST_CASE(RectangleBoundsConstruction) { - const double halfX(10.), halfY(5.); + const double halfX = 10.; + const double halfY = 5.; RectangleBounds twentyByTenRectangle(halfX, halfY); BOOST_CHECK_EQUAL(twentyByTenRectangle.type(), Acts::SurfaceBounds::eRectangle); - // + // nonsensical bounds are also permitted, but maybe should not be - const double zeroHalfX(0.), zeroHalfY(0.); - const double infHalfX(inf), infHalfY(inf); - // - // BOOST_TEST_MESSAGE("Initialise with zero dimensions"); + const double zeroHalfX = 0.; + const double zeroHalfY = 0.; + const double infHalfX = inf; + const double infHalfY = inf; + + // Initialise with zero dimensions RectangleBounds zeroDimensionsRectangle(zeroHalfX, zeroHalfY); BOOST_CHECK_EQUAL(zeroDimensionsRectangle.type(), Acts::SurfaceBounds::eRectangle); - // - // BOOST_TEST_MESSAGE("Initialise with infinite dimensions"); + + // Initialise with infinite dimensions RectangleBounds infinite(infHalfX, infHalfY); BOOST_CHECK_EQUAL(infinite.type(), Acts::SurfaceBounds::eRectangle); } /// Recreation BOOST_AUTO_TEST_CASE(RectangleBoundsRecreation) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. + RectangleBounds original(halfX, halfY); - // const bool symmetric(false); + auto valvector = original.values(); std::array values{}; std::copy_n(valvector.begin(), RectangleBounds::eSize, values.begin()); @@ -61,7 +66,8 @@ BOOST_AUTO_TEST_CASE(RectangleBoundsRecreation) { // Exception tests BOOST_AUTO_TEST_CASE(RadialBoundsException) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. // Negative x half length BOOST_CHECK_THROW(RectangleBounds(-halfX, halfY), std::logic_error); @@ -73,29 +79,33 @@ BOOST_AUTO_TEST_CASE(RadialBoundsException) { /// Unit test for testing RectangleBounds properties BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(1e-10)) BOOST_AUTO_TEST_CASE(RectangleBoundsProperties) { - const double halfX(10.), halfY(5.); + const double halfX = 10.; + const double halfY = 5.; + RectangleBounds rect(halfX, halfY); - BOOST_CHECK_EQUAL(rect.halfLengthX(), 10.); - BOOST_CHECK_EQUAL(rect.halfLengthY(), 5.); + BOOST_CHECK_EQUAL(rect.halfLengthX(), halfX); + BOOST_CHECK_EQUAL(rect.halfLengthY(), halfY); CHECK_CLOSE_ABS(rect.min(), Vector2(-halfX, -halfY), 1e-6); CHECK_CLOSE_ABS(rect.max(), Vector2(halfX, halfY), 1e-6); const std::vector coords = { - {-10., -5.}, {10., -5.}, {10., 5.}, {-10., 5.}}; + {-halfX, -halfY}, {halfX, -halfY}, {halfX, halfY}, {-halfX, halfY}}; // equality, ensure ordering is ok const auto& rectVertices = rect.vertices(); BOOST_CHECK_EQUAL_COLLECTIONS(coords.cbegin(), coords.cend(), rectVertices.cbegin(), rectVertices.cend()); - const Vector2 pointA{1.0, 1.0}; + const Vector2 pointA{1., 1.}; // distance is signed, from boundary to point. (doesn't seem right, given BoundaryTolerance tolerance = BoundaryTolerance::None(); BOOST_CHECK(rect.inside(pointA, tolerance)); } BOOST_AUTO_TEST_CASE(RectangleBoundsAssignment) { - const double halfX(10.), halfY(2.); + const double halfX = 10.; + const double halfY = 2.; // != 5. + RectangleBounds rectA(halfX, halfY); - RectangleBounds rectB(0.0, 0.0); + RectangleBounds rectB(0., 0.); rectB = rectA; const auto originalVertices = rectA.vertices(); const auto assignedVertices = rectB.vertices(); diff --git a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp index 9756800eed2..2998ad0e799 100644 --- a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp @@ -30,13 +30,17 @@ namespace Acts::Test { GeometryContext tgContext = GeometryContext(); BOOST_AUTO_TEST_SUITE(StrawSurfaces) + +const double radius = 1.; +const double halfZ = 10.; +Translation3 translation{0., 1., 2.}; + /// Unit test for creating compliant/non-compliant StrawSurface object BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { - // StrawSurface default constructor is deleted - // + /// Test default construction + // default construction is deleted + /// Constructor with transform, radius and halfZ - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); BOOST_CHECK_EQUAL( Surface::makeShared(Transform3::Identity(), radius, halfZ) @@ -45,21 +49,21 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, radius, halfZ)->type(), Surface::Straw); - // + /// Constructor with transform and LineBounds pointer auto pLineBounds = std::make_shared(radius, halfZ); BOOST_CHECK_EQUAL( Surface::makeShared(pTransform, pLineBounds)->type(), Surface::Straw); - // + /// Constructor with LineBounds ptr, DetectorElement std::shared_ptr p = std::make_shared(1., 10.); - DetectorElementStub detElement{pTransform, p, 1.0, nullptr}; + DetectorElementStub detElement{pTransform, p, 1., nullptr}; BOOST_CHECK_EQUAL( Surface::makeShared(pLineBounds, detElement)->type(), Surface::Straw); - // + /// Copy constructor auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); @@ -67,29 +71,27 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceConstruction) { Surface::makeShared(*strawSurfaceObject); BOOST_CHECK_EQUAL(copiedStrawSurface->type(), Surface::Straw); BOOST_CHECK(*copiedStrawSurface == *strawSurfaceObject); - // + /// Copied and transformed auto copiedTransformedStrawSurface = Surface::makeShared( tgContext, *strawSurfaceObject, pTransform); BOOST_CHECK_EQUAL(copiedTransformedStrawSurface->type(), Surface::Straw); } -// + /// Unit test for testing StrawSurface properties BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) { /// Test clone method - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test type (redundant) BOOST_CHECK_EQUAL(strawSurfaceObject->type(), Surface::Straw); - // + /// Test name BOOST_CHECK_EQUAL(strawSurfaceObject->name(), std::string("Acts::StrawSurface")); - // + /// Test dump boost::test_tools::output_test_stream dumpOutput; dumpOutput << strawSurfaceObject->toStream(tgContext); @@ -103,24 +105,24 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) { } BOOST_AUTO_TEST_CASE(EqualityOperators) { - double radius(1.0), halfZ(10.); - Translation3 translation{0., 1., 2.}; auto pTransform = Transform3(translation); auto strawSurfaceObject = Surface::makeShared(pTransform, radius, halfZ); - // + auto strawSurfaceObject2 = Surface::makeShared(pTransform, radius, halfZ); - // + /// Test equality operator BOOST_CHECK(*strawSurfaceObject == *strawSurfaceObject2); - // + BOOST_TEST_CHECKPOINT( "Create and then assign a StrawSurface object to the existing one"); + /// Test assignment auto assignedStrawSurface = Surface::makeShared(Transform3::Identity(), 6.6, 33.33); *assignedStrawSurface = *strawSurfaceObject; + /// Test equality of assigned to original BOOST_CHECK(*assignedStrawSurface == *strawSurfaceObject); } diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp index e48d3bcb0f3..2d62f29f4e4 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp @@ -136,7 +136,6 @@ struct SurfaceArrayFixture { for (int i = 0; i < nZ; i++) { double z = i * w * 2 + z0; - // std::cout << "z=" << z << std::endl; SrfVec ring = fullPhiTestSurfacesBRL(nPhi, 0, z, std::numbers::pi / 9., w, h); res.insert(res.end(), ring.begin(), ring.end()); @@ -227,7 +226,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { SurfaceArray::SurfaceGridLookup>( transform, itransform, std::make_tuple(std::move(phiAxis), std::move(zAxis))); - // do NOT fill, only completebinning + // do NOT fill, only complete binning sl2->completeBinning(tgContext, brlRaw); SurfaceArray sa2(std::move(sl2), brl); sa.toStream(tgContext, std::cout); @@ -241,7 +240,8 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { } BOOST_AUTO_TEST_CASE(SurfaceArray_singleElement) { - double w = 3, h = 4; + const double w = 3; + const double h = 4; auto bounds = std::make_shared(w, h); auto srf = Surface::makeShared(Transform3::Identity(), bounds); @@ -255,7 +255,8 @@ BOOST_AUTO_TEST_CASE(SurfaceArray_singleElement) { } BOOST_AUTO_TEST_CASE(SurfaceArray_manyElementsSingleLookup) { - double w = 3, h = 4; + const double w = 3; + const double h = 4; auto bounds = std::make_shared(w, h); auto srf0 = Surface::makeShared(Transform3::Identity(), bounds); auto srf1 = Surface::makeShared(Transform3::Identity(), bounds); diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp index 3de53a2b628..e150e9a64c9 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp @@ -57,7 +57,9 @@ class SurfaceBoundsStub : public SurfaceBounds { } // namespace Acts namespace Acts::Test { + BOOST_AUTO_TEST_SUITE(Surfaces) + /// Unit test for creating compliant/non-compliant SurfaceBounds object BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) { SurfaceBoundsStub u; @@ -65,6 +67,7 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) { SurfaceBoundsStub t(s); SurfaceBoundsStub v(u); } + BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) { SurfaceBoundsStub surface(5); std::vector reference{0, 1, 2, 3, 4}; @@ -72,6 +75,7 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) { BOOST_CHECK_EQUAL_COLLECTIONS(reference.cbegin(), reference.cend(), boundValues.cbegin(), boundValues.cend()); } + /// Unit test for testing SurfaceBounds properties BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) { SurfaceBoundsStub surface(1); @@ -79,15 +83,18 @@ BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) { SurfaceBoundsStub differentSurface(2); BOOST_CHECK_EQUAL(surface, copiedSurface); BOOST_CHECK_NE(surface, differentSurface); + SurfaceBoundsStub assignedSurface; assignedSurface = surface; BOOST_CHECK_EQUAL(surface, assignedSurface); + const auto& surfaceboundValues = surface.values(); const auto& assignedboundValues = assignedSurface.values(); BOOST_CHECK_EQUAL_COLLECTIONS( surfaceboundValues.cbegin(), surfaceboundValues.cend(), assignedboundValues.cbegin(), assignedboundValues.cend()); } + BOOST_AUTO_TEST_SUITE_END() } // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp index eda3f6d2db6..e6294fc27ca 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceIntersectionTests.cpp @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_SUITE(Surfaces) /// This tests the intersection with cylinders /// and looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { - double radius = 1_m; - double halfZ = 10_m; + const double radius = 1_m; + const double halfZ = 10_m; auto testCylinderIntersection = [&](const Transform3& transform) -> void { // A cylinder created aligned with a provided transform @@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(CylinderIntersectionTests) { /// This tests the intersection with cylinders /// and looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { - double alpha = std::numbers::pi / 4.; + const double alpha = std::numbers::pi / 4.; auto testConeIntersection = [&](const Transform3& transform) -> void { // A cone surface ready to use @@ -226,8 +226,8 @@ BOOST_AUTO_TEST_CASE(ConeIntersectionTest) { /// sufficient /// - it looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { - double halfX = 1_m; - double halfY = 10_m; + const double halfX = 1_m; + const double halfY = 10_m; auto testPlanarIntersection = [&](const Transform3& transform) -> void { // A Plane created with a specific transform @@ -325,8 +325,8 @@ BOOST_AUTO_TEST_CASE(PlanarIntersectionTest) { /// sufficient /// - it looks for valid, non-valid, solutions BOOST_AUTO_TEST_CASE(LineIntersectionTest) { - double radius = 1_m; - double halfZ = 10_m; + const double radius = 1_m; + const double halfZ = 10_m; auto testLineAppraoch = [&](const Transform3& transform) -> void { // A Plane created with a specific transform diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp index d399c3ff8cc..11c66abf303 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceLocalToGlobalRoundtripTests.cpp @@ -77,9 +77,9 @@ void runTest(const Surface& surface, double l0, double l1, double phi, // local positions const auto posAngle = bdata::xrange(-std::numbers::pi, std::numbers::pi, 0.25); -const auto posPositiveNonzero = bdata::xrange(0.25, 1.0, 0.25); -const auto posPositive = bdata::make(0.0) + posPositiveNonzero; -const auto posSymmetric = bdata::xrange(-1.0, 1.0, 0.25); +const auto posPositiveNonzero = bdata::xrange(0.25, 1., 0.25); +const auto posPositive = bdata::make(0.) + posPositiveNonzero; +const auto posSymmetric = bdata::xrange(-1., 1., 0.25); // direction angles const auto phis = bdata::xrange(-std::numbers::pi, std::numbers::pi, std::numbers::pi / 4.); @@ -97,7 +97,7 @@ const auto cones = bdata::make({ }); const auto cylinders = bdata::make({ Surface::makeShared(Transform3::Identity(), - 10.0 /* radius */, 100 /* half z */), + 10. /* radius */, 100 /* half z */), }); const auto discs = bdata::make({ Surface::makeShared(Transform3::Identity(), 0 /* radius min */, @@ -112,8 +112,8 @@ const auto planes = bdata::make({ CurvilinearSurface(Vector3(3, -4, 5), Vector3::UnitZ()).planeSurface(), }); const auto straws = bdata::make({ - Surface::makeShared(Transform3::Identity(), 2.0 /* radius */, - 200.0 /* half z */), + Surface::makeShared(Transform3::Identity(), 2. /* radius */, + 200. /* half z */), }); } // namespace @@ -127,7 +127,7 @@ BOOST_DATA_TEST_CASE(ConeSurface, // local parameter r*phi has limits that depend on the z position const auto r = lz * surface->bounds().tanAlpha(); // local coordinates are singular at z = 0 -> normalize local phi - runTest(*surface, (0 < lz) ? (r * lphi) : 0.0, lz, phi, theta); + runTest(*surface, (0 < lz) ? (r * lphi) : 0., lz, phi, theta); } BOOST_DATA_TEST_CASE(CylinderSurface, @@ -139,7 +139,7 @@ BOOST_DATA_TEST_CASE(CylinderSurface, BOOST_DATA_TEST_CASE(DiscSurface, discs* posPositive* posAngle* phis* thetas, surface, lr, lphi, phi, theta) { // local coordinates are singular at r = 0 -> normalize local phi - runTest(*surface, lr, (0 < lr) ? lphi : 0.0, phi, theta); + runTest(*surface, lr, (0 < lr) ? lphi : 0., phi, theta); } BOOST_DATA_TEST_CASE( diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp index ce745bec85c..c61508a6d89 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceStub.hpp @@ -78,7 +78,7 @@ class SurfaceStub : public RegularSurface { /// Inherited from GeometryObject base Vector3 binningPosition(const GeometryContext& /*txt*/, BinningValue /*bValue*/) const final { - const Vector3 v{0.0, 0.0, 0.0}; + const Vector3 v{0., 0., 0.}; return v; } diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp index 654bed3b8ff..e4c214b53d8 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceTests.cpp @@ -82,52 +82,60 @@ BOOST_AUTO_TEST_CASE(SurfaceProperties) { std::make_shared(makePercentSlab()); DetectorElementStub detElement{pTransform, pPlanarBound, 0.2, pMaterial}; SurfaceStub surface(detElement); + // associatedDetectorElement BOOST_CHECK_EQUAL(surface.associatedDetectorElement(), &detElement); - // test associatelayer, associatedLayer + + // test associatelayer, associatedLayer surface.associateLayer(*pLayer); BOOST_CHECK_EQUAL(surface.associatedLayer(), pLayer.get()); + // associated Material is not set to the surface // it is set to the detector element surface though BOOST_CHECK_NE(surface.surfaceMaterial(), pMaterial.get()); + // center() CHECK_CLOSE_OR_SMALL(reference, surface.center(tgContext), 1e-6, 1e-9); + // insideBounds - Vector2 localPosition{0.1, 3.0}; + Vector2 localPosition{0.1, 3.}; BOOST_CHECK(surface.insideBounds(localPosition)); Vector2 outside{20., 20.}; BOOST_CHECK(surface.insideBounds( outside)); // should return false, but doesn't because SurfaceStub has // "no bounds" hard-coded Vector3 mom{100., 200., 300.}; + // isOnSurface BOOST_CHECK(surface.isOnSurface(tgContext, reference, mom, BoundaryTolerance::Infinite())); BOOST_CHECK(surface.isOnSurface( tgContext, reference, mom, BoundaryTolerance::None())); // need to improve bounds() + // referenceFrame() RotationMatrix3 unitary; unitary << 1, 0, 0, 0, 1, 0, 0, 0, 1; auto referenceFrame = - surface.referenceFrame(tgContext, Vector3{1, 2, 3}.normalized(), - mom); // need more complex case to test + surface.referenceFrame(tgContext, Vector3{1, 2, 3}.normalized(), mom); BOOST_CHECK_EQUAL(referenceFrame, unitary); + // normal() auto normal = surface.normal(tgContext, Vector3{1, 2, 3}.normalized(), - Vector3::UnitZ()); // needs more - // complex test + Vector3::UnitZ()); Vector3 zero{0., 0., 0.}; BOOST_CHECK_EQUAL(zero, normal); + // pathCorrection is pure virtual + // surfaceMaterial() auto pNewMaterial = std::make_shared(makePercentSlab()); surface.assignSurfaceMaterial(pNewMaterial); - BOOST_CHECK_EQUAL(surface.surfaceMaterial(), - pNewMaterial.get()); // passes ?? - // + BOOST_CHECK_EQUAL(surface.surfaceMaterial(), pNewMaterial.get()); + CHECK_CLOSE_OR_SMALL(surface.transform(tgContext), pTransform, 1e-6, 1e-9); + // type() is pure virtual } @@ -140,6 +148,7 @@ BOOST_AUTO_TEST_CASE(EqualityOperators) { Translation3 translation2{1., 1., 2.}; auto pTransform1 = Transform3(translation1); auto pTransform2 = Transform3(translation2); + // build a planeSurface to be compared auto planeSurface = Surface::makeShared(pTransform1, pPlanarBound); @@ -149,27 +158,20 @@ BOOST_AUTO_TEST_CASE(EqualityOperators) { DetectorElementStub detElement1{pTransform1, pPlanarBound, 0.2, pMaterial}; DetectorElementStub detElement2{pTransform1, pPlanarBound, 0.3, pMaterial}; DetectorElementStub detElement3{pTransform2, pPlanarBound, 0.3, pMaterial}; - // + SurfaceStub surface1(detElement1); SurfaceStub surface2(detElement1); // 1 and 2 are the same SurfaceStub surface3(detElement2); // 3 differs in thickness SurfaceStub surface4(detElement3); // 4 has a different transform and id SurfaceStub surface5(detElement1); surface5.assignSurfaceMaterial(pMaterial); // 5 has non-null surface material - // + BOOST_CHECK(surface1 == surface2); - // - // remove test for the moment, - // surfaces do not have a concept of thickness (only detector elements have) - // only thickness is different here - // - // BOOST_CHECK_NE(surface1, surface3); // will fail - // + BOOST_CHECK(surface1 != surface3); BOOST_CHECK(surface1 != surface4); - // BOOST_CHECK(surface1 != surface5); - // BOOST_CHECK(surface1 != *planeSurface); + // Test the getSharedPtr const auto surfacePtr = Surface::makeShared(detElement1); const auto sharedSurfacePtr = surfacePtr->getSharedPtr(); diff --git a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp index 35fb2cfb343..0e9f1bba029 100644 --- a/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/TrapezoidBoundsTests.cpp @@ -32,13 +32,15 @@ namespace Acts::Test { BOOST_AUTO_TEST_SUITE(Surfaces) +const double minHalfX = 1.; +const double maxHalfX = 6.; +const double halfY = 2.; + /// Unit test for creating compliant/non-compliant TrapezoidBounds object BOOST_AUTO_TEST_CASE(TrapezoidBoundsConstruction) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // - // default construction deleted - // TrapezoidBounds defaultConstructedTrapezoidBounds; - // + /// Test default construction + // default construction is deleted + /// Test construction with defining half lengths BOOST_CHECK_EQUAL(TrapezoidBounds(minHalfX, maxHalfX, halfY).type(), SurfaceBounds::eTrapezoid); @@ -50,7 +52,6 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsConstruction) { /// Unit test for creating compliant/non-compliant TrapezoidBounds object BOOST_AUTO_TEST_CASE(TrapezoidBoundsRecreated) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); /// Copy constructor TrapezoidBounds original(minHalfX, maxHalfX, halfY); // const bool symmetric(false); @@ -63,8 +64,6 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsRecreated) { // Exception tests BOOST_AUTO_TEST_CASE(TrapezoidBoundsException) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // Negative x at min y BOOST_CHECK_THROW(TrapezoidBounds(-minHalfX, maxHalfX, halfY), std::logic_error); @@ -84,25 +83,23 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsException) { /// Unit tests for TrapezoidBounds properties BOOST_AUTO_TEST_CASE(TrapezoidBoundsProperties) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); - // TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); - // + /// Test type() (redundant; already used in constructor confirmation) BOOST_CHECK_EQUAL(trapezoidBoundsObject.type(), SurfaceBounds::eTrapezoid); - // + /// Test minHalflengthX BOOST_CHECK_EQUAL( trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthXnegY), minHalfX); - // + /// Test maxHalfLengthX BOOST_CHECK_EQUAL( trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthXposY), maxHalfX); - // + /// Test halflengthY BOOST_CHECK_EQUAL(trapezoidBoundsObject.get(TrapezoidBounds::eHalfLengthY), halfY); - // + /// Test distanceToBoundary Vector2 outside(30., 0.); Vector2 inRectangle(2., 0.5); @@ -114,24 +111,18 @@ BOOST_AUTO_TEST_CASE(TrapezoidBoundsProperties) { BOOST_CHECK_EQUAL_COLLECTIONS(actualVertices.cbegin(), actualVertices.cend(), expectedVertices.cbegin(), expectedVertices.cend()); - /** - for (auto i: trapezoidBoundsObject.vertices()){ - std::cout<(-3, 3))) ^ - bdata::xrange(1000) * bdata::make({0.0, 0.1, 0.2, 0.3}), + bdata::xrange(1000) * bdata::make({0., 0.1, 0.2, 0.3}), x, y, index, tol) { (void)index; - double minHalfX(1.), maxHalfX(6.), halfY(2.); + static const TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); static const auto vertices = trapezoidBoundsObject.vertices(); BoundaryTolerance tolerance = BoundaryTolerance::None(); - if (tol != 0.0) { + if (tol != 0.) { tolerance = BoundaryTolerance::AbsoluteBound{tol, tol}; } @@ -211,10 +201,11 @@ BOOST_DATA_TEST_CASE( /// Unit test for testing TrapezoidBounds assignment BOOST_AUTO_TEST_CASE(TrapezoidBoundsAssignment) { - double minHalfX(1.), maxHalfX(6.), halfY(2.); TrapezoidBounds trapezoidBoundsObject(minHalfX, maxHalfX, halfY); - // operator == not implemented in this class - // + + /// Test operator == + // not implemented in this class + /// Test assignment TrapezoidBounds assignedTrapezoidBoundsObject(10., 20., 14.2); assignedTrapezoidBoundsObject = trapezoidBoundsObject; diff --git a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp index 4a01ef7da87..ecd464b42d7 100644 --- a/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/VerticesHelperTests.cpp @@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE(GenerateCircleEllipseVertices) { expectedVertices = 41u; // 4 sectors + 1 overlap at (-pi/pi) BOOST_CHECK_EQUAL(vertices.size(), expectedVertices); - // Now ellipsiod + // Now ellipsoid ActsScalar riy = 4.; ActsScalar roy = 14.; vertices = VerticesHelper::ellipsoidVertices(ri, riy, ro, roy, 0.,