File indexing completed on 2025-01-18 09:12:51
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 namespace Acts::Test {
0023
0024 BOOST_AUTO_TEST_SUITE(Surfaces)
0025
0026 BOOST_AUTO_TEST_CASE(LineBoundsConstruction) {
0027 const double radius = 0.5;
0028 const double halfZ = 10.;
0029
0030
0031 LineBounds lineBounds(radius, halfZ);
0032 BOOST_CHECK_EQUAL(lineBounds.type(), SurfaceBounds::eLine);
0033
0034
0035 LineBounds copyConstructedLineBounds(lineBounds);
0036 BOOST_CHECK_EQUAL(copyConstructedLineBounds.type(), SurfaceBounds::eLine);
0037 }
0038
0039
0040 BOOST_AUTO_TEST_CASE(LineBoundsRecreation) {
0041 const double radius = 0.5;
0042 const double halfZ = 20.;
0043
0044 LineBounds original(radius, halfZ);
0045 LineBounds recreated(original);
0046 auto valvector = original.values();
0047 std::array<double, LineBounds::eSize> values{};
0048 std::copy_n(valvector.begin(), LineBounds::eSize, values.begin());
0049 BOOST_CHECK_EQUAL(original, recreated);
0050 }
0051
0052
0053 BOOST_AUTO_TEST_CASE(LineBoundsExceptions) {
0054 const double radius = 0.5;
0055 const double halfZ = 20.;
0056
0057
0058 BOOST_CHECK_THROW(LineBounds(-radius, halfZ), std::logic_error);
0059
0060
0061 BOOST_CHECK_THROW(LineBounds(radius, -halfZ), std::logic_error);
0062
0063
0064 BOOST_CHECK_THROW(LineBounds(-radius, -halfZ), std::logic_error);
0065 }
0066
0067
0068 BOOST_AUTO_TEST_CASE(LineBoundsAssignment) {
0069 const double radius = 0.5;
0070 const double halfZ = 20.;
0071
0072 LineBounds lineBoundsObject(radius, halfZ);
0073 LineBounds assignedLineBounds = lineBoundsObject;
0074 BOOST_CHECK_EQUAL(assignedLineBounds, lineBoundsObject);
0075 }
0076
0077
0078 BOOST_AUTO_TEST_CASE(LineBoundsProperties) {
0079 const double radius = 0.5;
0080 const double halfZ = 20.;
0081
0082 LineBounds lineBoundsObject(radius, halfZ);
0083
0084
0085 BOOST_CHECK_EQUAL(lineBoundsObject.type(), SurfaceBounds::eLine);
0086
0087
0088 const Vector2 origin{0., 0.};
0089 const Vector2 atRadius{0.5, 10.};
0090 const Vector2 beyondEnd{0., 30.};
0091 const Vector2 unitZ{0., 1.};
0092 const Vector2 unitR{1., 0.};
0093 const BoundaryTolerance tolerance =
0094 BoundaryTolerance::AbsoluteBound(0.1, 0.1);
0095
0096 BOOST_CHECK(!lineBoundsObject.inside(atRadius, tolerance));
0097 BOOST_CHECK(!lineBoundsObject.inside(beyondEnd, tolerance));
0098 BOOST_CHECK(lineBoundsObject.inside(unitZ, tolerance));
0099 BOOST_CHECK(!lineBoundsObject.inside(unitR, tolerance));
0100
0101
0102 BOOST_CHECK(lineBoundsObject.inside(Vector2{-0.2, 10}, tolerance));
0103 BOOST_CHECK(!lineBoundsObject.inside(Vector2{-0.8, 10}, tolerance));
0104
0105
0106 BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eR), radius);
0107
0108
0109 BOOST_CHECK_EQUAL(lineBoundsObject.get(LineBounds::eHalfLengthZ), halfZ);
0110
0111
0112 boost::test_tools::output_test_stream dumpOutput;
0113 lineBoundsObject.toStream(dumpOutput);
0114 BOOST_CHECK(dumpOutput.is_equal(
0115 "Acts::LineBounds: (radius, halflengthInZ) = (0.5000000, 20.0000000)"));
0116 }
0117
0118 BOOST_AUTO_TEST_SUITE_END()
0119
0120 }