Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SurfaceBoundsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SurfaceBoundsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
16 
17 #include <cstddef>
18 #include <numeric>
19 #include <ostream>
20 #include <vector>
21 
22 namespace Acts {
23 
26  public:
28  explicit SurfaceBoundsStub(size_t nValues = 0) : m_values(nValues, 0) {
29  std::iota(m_values.begin(), m_values.end(), 0);
30  }
31 
32 #if defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Warray-bounds"
35 #pragma GCC diagnostic ignored "-Wstringop-overflow"
36 #endif
37  SurfaceBoundsStub(const SurfaceBoundsStub& other) = default;
38 #if defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)
39 #pragma GCC diagnostic pop
40 #endif
41 
42  ~SurfaceBoundsStub() override = default;
43  BoundsType type() const final {
44  return SurfaceBounds::eOther;
45  }
46  std::vector<double> values() const override {
47  return m_values;
48  }
49  bool inside(const Vector2& /*lpos*/,
50  const BoundaryCheck& /*bcheck*/) const final {
51  return true;
52  }
53 
54  std::ostream& toStream(std::ostream& sl) const final {
55  sl << "SurfaceBoundsStub";
56  return sl;
57  }
58 
59  private:
60  std::vector<double> m_values;
61 };
62 
63 namespace Test {
64 BOOST_AUTO_TEST_SUITE(Surfaces)
66 BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) {
68  SurfaceBoundsStub s(1); // would act as size_t cast to SurfaceBounds
71 }
72 BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) {
74  std::vector<double> reference{0, 1, 2, 3, 4};
75  const auto& boundValues = surface.values();
76  BOOST_CHECK_EQUAL_COLLECTIONS(reference.cbegin(), reference.cend(),
77  boundValues.cbegin(), boundValues.cend());
78 }
80 BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) {
82  SurfaceBoundsStub copiedSurface(surface);
83  SurfaceBoundsStub differentSurface(2);
84  BOOST_CHECK_EQUAL(surface, copiedSurface);
85  BOOST_CHECK_NE(surface, differentSurface);
86  SurfaceBoundsStub assignedSurface;
87  assignedSurface = surface;
88  BOOST_CHECK_EQUAL(surface, assignedSurface);
89  const auto& surfaceboundValues = surface.values();
90  const auto& assignedboundValues = assignedSurface.values();
91  BOOST_CHECK_EQUAL_COLLECTIONS(
92  surfaceboundValues.cbegin(), surfaceboundValues.cend(),
93  assignedboundValues.cbegin(), assignedboundValues.cend());
94 }
95 BOOST_AUTO_TEST_SUITE_END()
96 
97 } // namespace Test
98 
99 } // namespace Acts