ECCE @ EIC 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 #include <numeric>
13 
16 
17 namespace Acts {
18 
21  public:
23  explicit SurfaceBoundsStub(size_t nValues = 0) : m_values(nValues, 0) {
24  std::iota(m_values.begin(), m_values.end(), 0);
25  }
26 
27  ~SurfaceBoundsStub() override { /*nop*/
28  }
29  BoundsType type() const final { return SurfaceBounds::eOther; }
30  std::vector<double> values() const override { return m_values; }
31  bool inside(const Vector2D& /*lpos*/,
32  const BoundaryCheck& /*bcheck*/) const final {
33  return true;
34  }
35  double distanceToBoundary(const Vector2D& /*lpos*/) const final {
36  return 10.;
37  }
38  std::ostream& toStream(std::ostream& sl) const final {
39  sl << "SurfaceBoundsStub";
40  return sl;
41  }
42 
43  private:
44  std::vector<double> m_values;
45 };
46 
47 namespace Test {
48 BOOST_AUTO_TEST_SUITE(Surfaces)
50 BOOST_AUTO_TEST_CASE(SurfaceBoundsConstruction) {
52  SurfaceBoundsStub s(1); // would act as size_t cast to SurfaceBounds
55 }
56 BOOST_AUTO_TEST_CASE(SurfaceBoundsProperties) {
58  std::vector<double> reference{0, 1, 2, 3, 4};
59  const auto& boundValues = surface.values();
60  BOOST_CHECK_EQUAL_COLLECTIONS(reference.cbegin(), reference.cend(),
61  boundValues.cbegin(), boundValues.cend());
62 }
64 BOOST_AUTO_TEST_CASE(SurfaceBoundsEquality) {
66  SurfaceBoundsStub copiedSurface(surface);
67  SurfaceBoundsStub differentSurface(2);
68  BOOST_CHECK_EQUAL(surface, copiedSurface);
69  BOOST_CHECK_NE(surface, differentSurface);
70  SurfaceBoundsStub assignedSurface;
71  assignedSurface = surface;
72  BOOST_CHECK_EQUAL(surface, assignedSurface);
73  const auto& surfaceboundValues = surface.values();
74  const auto& assignedboundValues = assignedSurface.values();
75  BOOST_CHECK_EQUAL_COLLECTIONS(
76  surfaceboundValues.cbegin(), surfaceboundValues.cend(),
77  assignedboundValues.cbegin(), assignedboundValues.cend());
78 }
79 BOOST_AUTO_TEST_SUITE_END()
80 
81 } // namespace Test
82 
83 } // namespace Acts