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