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 
16 #include "Acts/Geometry/Layer.hpp"
20 
21 #include "LayerStub.hpp"
22 
23 using boost::test_tools::output_test_stream;
24 namespace utf = boost::unit_test;
25 
26 namespace Acts {
27 
28 namespace Test {
29 
30 // Create a test context
32 
33 namespace Layers {
34 
35 BOOST_AUTO_TEST_SUITE(Layers)
36 
37 
38 BOOST_AUTO_TEST_CASE(LayerConstruction) {
39  // Descendant Layer objects also inherit from Surface objects, which
40  // delete the default constructor
41  //
43  LayerStub minallyConstructed(nullptr);
44  BOOST_CHECK(minallyConstructed.constructedOk());
46  std::vector<std::shared_ptr<const Surface>> aSurfaces{
47  Surface::makeShared<SurfaceStub>(), Surface::makeShared<SurfaceStub>()};
48  std::unique_ptr<ApproachDescriptor> ad(
49  new GenericApproachDescriptor(aSurfaces));
50  const double thickness(1.0);
51  LayerStub approachDescriptorConstructed(nullptr, thickness, std::move(ad));
53  BOOST_CHECK(approachDescriptorConstructed.constructedOk());
54  // Copy construction is deleted
55 }
56 
58 BOOST_AUTO_TEST_CASE(LayerProperties, *utf::expected_failures(1)) {
59  // Make a dummy layer to play with
60  // bounds object, rectangle type
61  auto rBounds = std::make_shared<const RectangleBounds>(1., 1.);
63  const std::vector<std::shared_ptr<const Surface>> aSurfaces{
64  Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds),
65  Surface::makeShared<PlaneSurface>(Transform3D::Identity(), rBounds)};
66  std::unique_ptr<ApproachDescriptor> ad(
67  new GenericApproachDescriptor(aSurfaces));
68  auto adPtr = ad.get();
69  const double thickness(1.0);
70  LayerStub layerStub(nullptr, thickness, std::move(ad));
71  //
73  BOOST_CHECK_EQUAL(layerStub.surfaceArray(), nullptr);
75  BOOST_CHECK_EQUAL(layerStub.thickness(), thickness);
76  // onLayer() is templated; can't find implementation!
78  const Vector3D pos{0.0, 0.0, 0.0};
79  const Vector3D pos2{100., 100., std::nan("")};
80  BOOST_CHECK(layerStub.isOnLayer(tgContext, pos));
81  // this should fail, but does not, but possibly my fault in SurfaceStub
82  // implementation:
83  BOOST_CHECK(!layerStub.isOnLayer(tgContext, pos2));
85  BOOST_CHECK_EQUAL(layerStub.approachDescriptor(), adPtr);
86  const Vector3D gpos{0., 0., 1.0};
87  const Vector3D direction{0., 0., -1.};
89  BOOST_CHECK(!(layerStub.nextLayer(tgContext, gpos, direction)));
91  BOOST_CHECK(!layerStub.trackingVolume());
92  // BOOST_TEST_CHECKPOINT("Before ending test");
93  // deletion results in "memory access violation at address: 0x00000071: no
94  // mapping at fault address"
95  // delete abstractVolumePtr;
97  BOOST_CHECK_EQUAL(layerStub.layerType(), LayerType::passive);
98 }
99 
100 BOOST_AUTO_TEST_SUITE_END()
101 } // namespace Layers
102 } // namespace Test
103 
104 } // namespace Acts