ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LayerTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file LayerTests.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 
17 #include "Acts/Geometry/Layer.hpp"
21 
22 #include "LayerStub.hpp"
23 
24 using boost::test_tools::output_test_stream;
25 namespace utf = boost::unit_test;
26 
27 namespace Acts {
28 
29 namespace Test {
30 
31 // Create a test context
33 
34 namespace Layers {
35 
36 BOOST_AUTO_TEST_SUITE(Layers)
37 
38 
39 BOOST_AUTO_TEST_CASE(LayerConstruction) {
40  // Descendant Layer objects also inherit from Surface objects, which
41  // delete the default constructor
42  //
44  LayerStub minallyConstructed(nullptr);
45  BOOST_CHECK(minallyConstructed.constructedOk());
47  std::vector<std::shared_ptr<const Surface>> aSurfaces{
48  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
49  std::unique_ptr<ApproachDescriptor> ad(
50  new GenericApproachDescriptor(aSurfaces));
51  const double thickness(1.0);
52  LayerStub approachDescriptorConstructed(nullptr, thickness, std::move(ad));
54  BOOST_CHECK(approachDescriptorConstructed.constructedOk());
55  // Copy construction is deleted
56 }
57 
59 BOOST_AUTO_TEST_CASE(LayerProperties, *utf::expected_failures(1)) {
60  // Make a dummy layer to play with
61  // bounds object, rectangle type
62  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
64  std::shared_ptr<const Transform3D> pNullTransform{};
65  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
66  Surface::makeShared<PlaneSurface>(pNullTransform, rBounds),
67  Surface::makeShared<PlaneSurface>(pNullTransform, rBounds)};
68  std::unique_ptr<ApproachDescriptor> ad(
69  new GenericApproachDescriptor(aSurfaces));
70  auto adPtr = ad.get();
71  const double thickness(1.0);
72  LayerStub layerStub(nullptr, thickness, std::move(ad));
73  //
75  BOOST_CHECK_EQUAL(layerStub.surfaceArray(), nullptr);
77  BOOST_CHECK_EQUAL(layerStub.thickness(), thickness);
78  // onLayer() is templated; can't find implementation!
80  const Vector3D pos{0.0, 0.0, 0.0};
81  const Vector3D pos2{100., 100., std::nan("")};
82  BOOST_CHECK(layerStub.isOnLayer(tgContext, pos));
83  // this should fail, but does not, but possibly my fault in SurfaceStub
84  // implementation:
85  BOOST_CHECK(!layerStub.isOnLayer(tgContext, pos2));
87  BOOST_CHECK_EQUAL(layerStub.approachDescriptor(), adPtr);
88  const Vector3D gpos{0., 0., 1.0};
89  const Vector3D direction{0., 0., -1.};
91  BOOST_CHECK(!(layerStub.nextLayer(tgContext, gpos, direction)));
93  BOOST_CHECK(!layerStub.trackingVolume());
94  // BOOST_TEST_CHECKPOINT("Before ending test");
95  // deletion results in "memory access violation at address: 0x00000071: no
96  // mapping at fault address"
97  // delete abstractVolumePtr;
99  BOOST_CHECK_EQUAL(layerStub.layerType(), LayerType::passive);
100 }
101 
102 BOOST_AUTO_TEST_SUITE_END()
103 } // namespace Layers
104 } // namespace Test
105 
106 } // namespace Acts