ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CuboidVolumeBoundsTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CuboidVolumeBoundsTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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/unit_test.hpp>
10 
15 
16 namespace Acts {
17 namespace Test {
18 
20 
21 double hx{10.}, hy{20.}, hz{30.};
22 
23 BOOST_AUTO_TEST_SUITE(Geometry)
24 
25 BOOST_AUTO_TEST_CASE(CuboidVolumeConstruction) {
26  // Test Construction
28 
29  // Test copy construction
30  CuboidVolumeBounds copied(box);
31  BOOST_CHECK_EQUAL(box, copied);
32 
33  // Test assigned
34  CuboidVolumeBounds assigned = box;
35  BOOST_CHECK_EQUAL(box, assigned);
36 }
37 
38 BOOST_AUTO_TEST_CASE(CuboidVolumeRecreation) {
39  CuboidVolumeBounds original(hx, hy, hz);
40  auto valvector = original.values();
41  std::array<double, CuboidVolumeBounds::eSize> values;
42  std::copy_n(valvector.begin(), CuboidVolumeBounds::eSize, values.begin());
43  CuboidVolumeBounds recreated(values);
44  BOOST_CHECK_EQUAL(original, recreated);
45 }
46 
47 BOOST_AUTO_TEST_CASE(CuboidVolumeException) {
48  // Test exception negative x
49  BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, hy, hz), std::logic_error);
50  // Test exception negative y
51  BOOST_CHECK_THROW(CuboidVolumeBounds(hx, -hy, hz), std::logic_error);
52  // Test exception negative z
53  BOOST_CHECK_THROW(CuboidVolumeBounds(hx, hy, -hz), std::logic_error);
54  // Other iterations 0
55  BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, hy, -hz), std::logic_error);
56  // Other iterations 1
57  BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, -hy, hz), std::logic_error);
58  // Other iterations 2
59  BOOST_CHECK_THROW(CuboidVolumeBounds(hx, -hy, -hz), std::logic_error);
60  // Other iterations : all
61  BOOST_CHECK_THROW(CuboidVolumeBounds(-hx, -hy, -hz), std::logic_error);
62 }
63 
64 BOOST_AUTO_TEST_CASE(CuboidVolumeProperties) {
66  // Test the type
67  BOOST_TEST(box.type() == VolumeBounds::eCuboid);
68  // Test the halflength x
70  // Test the halflength y
72  // Test the halflength z
74  // Test the streaming
75  std::vector<double> refvalues = {hx, hy, hz};
76  BOOST_TEST(box.values() == refvalues);
77 
78  // Inside position
79  Vector3D inside({5., 10., 8.});
80  // Outside positions in x, y, z
81  std::vector<Vector3D> outsides = {
82  {20., 1., -2.}, {1., -30., 2.}, {-1., 2., 100.}};
83 
84  // Inside position
85  BOOST_TEST(box.inside(inside, s_onSurfaceTolerance));
86 
87  // Outside position
88  for (const auto& outside : outsides) {
89  BOOST_TEST(!box.inside(outside, s_onSurfaceTolerance));
90  }
91 }
92 
93 BOOST_AUTO_TEST_SUITE_END()
94 
95 } // namespace Test
96 } // namespace Acts