File indexing completed on 2025-01-18 09:12:52
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0013 #include "Acts/Surfaces/SurfaceBounds.hpp"
0014
0015 #include <cstddef>
0016 #include <numeric>
0017 #include <ostream>
0018 #include <vector>
0019
0020 namespace Acts {
0021
0022
0023 class SurfaceBoundsStub : public SurfaceBounds {
0024 public:
0025
0026 explicit SurfaceBoundsStub(std::size_t nValues = 0) : m_values(nValues, 0) {
0027 std::iota(m_values.begin(), m_values.end(), 0);
0028 }
0029
0030 #if defined(__GNUC__) && (__GNUC__ == 13 || __GNUC__ == 14) && \
0031 !defined(__clang__)
0032 #pragma GCC diagnostic push
0033 #pragma GCC diagnostic ignored "-Warray-bounds"
0034 #pragma GCC diagnostic ignored "-Wstringop-overflow"
0035 #endif
0036 SurfaceBoundsStub(const SurfaceBoundsStub& other) = default;
0037 #if defined(__GNUC__) && (__GNUC__ == 13 || __GNUC__ == 14) && \
0038 !defined(__clang__)
0039 #pragma GCC diagnostic pop
0040 #endif
0041
0042 ~SurfaceBoundsStub() override = default;
0043 BoundsType type() const final { return SurfaceBounds::eOther; }
0044 std::vector<double> values() const override { return m_values; }
0045 bool inside(const Vector2& ,
0046 const BoundaryTolerance& ) const final {
0047 return true;
0048 }
0049
0050 std::ostream& toStream(std::ostream& sl) const final {
0051 sl << "SurfaceBoundsStub";
0052 return sl;
0053 }
0054
0055 private:
0056 std::vector<double> m_values;
0057 };
0058
0059 }
0060
0061 namespace Acts::Test {
0062
0063 BOOST_AUTO_TEST_SUITE(Surfaces)
0064
0065
0066 BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) {
0067 SurfaceBoundsStub u;
0068 SurfaceBoundsStub s(1);
0069 SurfaceBoundsStub t(s);
0070 SurfaceBoundsStub v(u);
0071 }
0072
0073 BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) {
0074 SurfaceBoundsStub surface(5);
0075 std::vector<double> reference{0, 1, 2, 3, 4};
0076 const auto& boundValues = surface.values();
0077 BOOST_CHECK_EQUAL_COLLECTIONS(reference.cbegin(), reference.cend(),
0078 boundValues.cbegin(), boundValues.cend());
0079 }
0080
0081
0082 BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) {
0083 SurfaceBoundsStub surface(1);
0084 SurfaceBoundsStub copiedSurface(surface);
0085 SurfaceBoundsStub differentSurface(2);
0086 BOOST_CHECK_EQUAL(surface, copiedSurface);
0087 BOOST_CHECK_NE(surface, differentSurface);
0088
0089 SurfaceBoundsStub assignedSurface;
0090 assignedSurface = surface;
0091 BOOST_CHECK_EQUAL(surface, assignedSurface);
0092
0093 const auto& surfaceboundValues = surface.values();
0094 const auto& assignedboundValues = assignedSurface.values();
0095 BOOST_CHECK_EQUAL_COLLECTIONS(
0096 surfaceboundValues.cbegin(), surfaceboundValues.cend(),
0097 assignedboundValues.cbegin(), assignedboundValues.cend());
0098 }
0099
0100 BOOST_AUTO_TEST_SUITE_END()
0101
0102 }