File indexing completed on 2025-10-23 08:24:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/output_test_stream.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0014 #include "Acts/Surfaces/LineBounds.hpp"
0015 #include "Acts/Surfaces/SurfaceBounds.hpp"
0016
0017 #include <algorithm>
0018 #include <array>
0019 #include <stdexcept>
0020 #include <vector>
0021
0022 using namespace Acts;
0023
0024 namespace ActsTests {
0025
0026 BOOST_AUTO_TEST_SUITE(SurfacesSuite)
0027
0028 BOOST_AUTO_TEST_CASE(LineBoundsConstruction) {
0029 const double radius = 0.5;
0030 const double halfZ = 10.;
0031
0032
0033 LineBounds lineBounds(radius, halfZ);
0034 BOOST_CHECK_EQUAL(lineBounds.type(), SurfaceBounds::eLine);
0035
0036
0037 LineBounds copyConstructedLineBounds(lineBounds);
0038 BOOST_CHECK_EQUAL(copyConstructedLineBounds.type(), SurfaceBounds::eLine);
0039 }
0040
0041
0042 BOOST_AUTO_TEST_CASE(LineBoundsRecreation) {
0043 const double radius = 0.5;
0044 const double halfZ = 20.;
0045
0046 LineBounds original(radius, halfZ);
0047 LineBounds recreated(original);
0048 auto valvector = original.values();
0049 std::array<double, LineBounds::eSize> values{};
0050 std::copy_n(valvector.begin(), LineBounds::eSize, values.begin());
0051 BOOST_CHECK_EQUAL(original, recreated);
0052 }
0053
0054
0055 BOOST_AUTO_TEST_CASE(LineBoundsExceptions) {
0056 const double radius = 0.5;
0057 const double halfZ = 20.;
0058
0059
0060 BOOST_CHECK_THROW(LineBounds(-radius, halfZ), std::logic_error);
0061
0062
0063 BOOST_CHECK_THROW(LineBounds(radius, -halfZ), std::logic_error);
0064
0065
0066 BOOST_CHECK_THROW(LineBounds(-radius, -halfZ), std::logic_error);
0067 }
0068
0069
0070 BOOST_AUTO_TEST_CASE(LineBoundsAssignment) {
0071 const double radius = 0.5;
0072 const double halfZ = 20.;
0073
0074 LineBounds lineBoundsObject(radius, halfZ);
0075 LineBounds assignedLineBounds = lineBoundsObject;
0076 BOOST_CHECK_EQUAL(assignedLineBounds, lineBoundsObject);
0077 }
0078
0079
0080 BOOST_AUTO_TEST_CASE(LineBoundsProperties) {
0081 const double radius = 0.5;
0082 const double halfZ = 20.;
0083
0084 LineBounds lineBoundsObject(radius, halfZ);
0085
0086
0087 BOOST_CHECK_EQUAL(lineBoundsObject.type(), SurfaceBounds::eLine);
0088
0089
0090 const Vector2 origin{0., 0.};
0091 const Vector2 atRadius{0.5, 10.};
0092 const Vector2 beyondEnd{0., 30.};
0093 const Vector2 unitZ{0., 1.};
0094 const Vector2 unitR{1., 0.};
0095 const BoundaryTolerance tolerance = BoundaryTolerance::AbsoluteEuclidean(0.1);
0096
0097 BOOST_CHECK(!lineBoundsObject.inside(atRadius, tolerance));
0098 BOOST_CHECK(!lineBoundsObject.inside(beyondEnd, tolerance));
0099 BOOST_CHECK(lineBoundsObject.inside(unitZ, tolerance));
0100 BOOST_CHECK(!lineBoundsObject.inside(unitR, tolerance));
0101
0102
0103 BOOST_CHECK(lineBoundsObject.inside(Vector2{-0.2, 10}, tolerance));
0104 BOOST_CHECK(!lineBoundsObject.inside(Vector2{-0.8, 10}, tolerance));
0105
0106
0107 BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), radius);
0108
0109
0110 BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), halfZ);
0111
0112
0113 boost::test_tools::output_test_stream dumpOutput;
0114 lineBoundsObject.toStream(dumpOutput);
0115 BOOST_CHECK(dumpOutput.is_equal(
0116 "Acts::LineBounds: (radius, halflengthInZ) = (0.5000000, 20.0000000)"));
0117 }
0118
0119 BOOST_AUTO_TEST_CASE(LineBoundsCenter) {
0120 const double radius = 2.5;
0121 const double halfZ = 15.0;
0122
0123 LineBounds lineBounds(radius, halfZ);
0124 Vector2 center = lineBounds.center();
0125
0126
0127 BOOST_CHECK_EQUAL(center.x(), 0.0);
0128 BOOST_CHECK_EQUAL(center.y(), 0.0);
0129 }
0130
0131 BOOST_AUTO_TEST_SUITE_END()
0132
0133 }