File indexing completed on 2025-01-18 09:12:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/Geometry/CylinderVolumeBounds.hpp"
0013 #include "Acts/Geometry/TrackingVolume.hpp"
0014
0015 using namespace Acts::UnitLiterals;
0016
0017 namespace Acts::Test {
0018
0019 BOOST_AUTO_TEST_SUITE(Geometry)
0020 BOOST_AUTO_TEST_SUITE(TrackingVolumeTests)
0021
0022 std::size_t countVolumes(const TrackingVolume& tv) {
0023 std::size_t count = 0;
0024 tv.visitVolumes([&count](const auto&) { ++count; });
0025 return count;
0026 }
0027
0028 BOOST_AUTO_TEST_CASE(TrackigVolumeChildren) {
0029 auto cylBounds =
0030 std::make_shared<Acts::CylinderVolumeBounds>(10_mm, 20_mm, 100_mm);
0031
0032 TrackingVolume tv{Transform3::Identity(), cylBounds};
0033
0034 BOOST_CHECK(tv.volumes().empty());
0035 BOOST_CHECK_EQUAL(countVolumes(tv), 1);
0036
0037 auto& child1 = tv.addVolume(
0038 std::make_unique<TrackingVolume>(Transform3::Identity(), cylBounds));
0039
0040 BOOST_CHECK_EQUAL(tv.volumes().size(), 1);
0041
0042 auto it = tv.volumes().begin();
0043 static_assert(std::is_same_v<decltype(*it), TrackingVolume&>);
0044
0045 const auto& tvConst = tv;
0046 auto cit = tvConst.volumes().begin();
0047 static_assert(std::is_same_v<decltype(*cit), const TrackingVolume&>);
0048
0049 BOOST_CHECK_EQUAL(&*it, &child1);
0050
0051 BOOST_CHECK_EQUAL(countVolumes(tv), 2);
0052
0053 tv.addVolume(
0054 std::make_unique<TrackingVolume>(Transform3::Identity(), cylBounds));
0055
0056 BOOST_CHECK_EQUAL(countVolumes(tv), 3);
0057 }
0058
0059 BOOST_AUTO_TEST_SUITE_END()
0060
0061 BOOST_AUTO_TEST_SUITE_END()
0062
0063 }