diff --git a/Core/include/ACTS/Layers/NavigationLayer.hpp b/Core/include/ACTS/Layers/NavigationLayer.hpp index 32f4effea8a1f29fcb99e279556970dbf317f0b4..10997925a9a11bb1a25644afc38e3b64671aa424 100644 --- a/Core/include/ACTS/Layers/NavigationLayer.hpp +++ b/Core/include/ACTS/Layers/NavigationLayer.hpp @@ -34,7 +34,7 @@ public: /// Factory Constructor - the surface representation is given by pointer /// (ownership passed) /// - /// @param sRepresentation is the represenation for extrapolation + /// @param sRepresentation is the representation for extrapolation /// @param thickness is the thickness for the binning static LayerPtr create(std::unique_ptr<const Surface> sRepresentation, double thickness = 0.) diff --git a/Tests/Layers/CMakeLists.txt b/Tests/Layers/CMakeLists.txt index b12be181086ae8ce6fc07613c06c9afa549e46b4..4fcca6e84a6d332c4e4cb58a16af9263ae972700 100644 --- a/Tests/Layers/CMakeLists.txt +++ b/Tests/Layers/CMakeLists.txt @@ -18,4 +18,6 @@ add_executable (ConeLayerTests ConeLayerTests.cpp) target_link_libraries (ConeLayerTests PRIVATE ACTSCore) add_test (NAME ConeLayerTests COMMAND ConeLayerTests) - +add_executable (NavigationLayerTests NavigationLayerTests.cpp) +target_link_libraries (NavigationLayerTests PRIVATE ACTSCore) +add_test (NAME NavigationLayerTests COMMAND NavigationLayerTests) diff --git a/Tests/Layers/ConeLayerTests.cpp b/Tests/Layers/ConeLayerTests.cpp index cae1fbe98084d4503eff9b1dd9c20e3735efe95d..d37dd694199f49f6770be6497a830ee8eb78f2df 100644 --- a/Tests/Layers/ConeLayerTests.cpp +++ b/Tests/Layers/ConeLayerTests.cpp @@ -88,7 +88,7 @@ namespace Test { } /// Unit test for testing Layer properties - BOOST_AUTO_TEST_CASE(LayerProperties /*, *utf::expected_failures(1)*/) + BOOST_AUTO_TEST_CASE(ConeLayerProperties /*, *utf::expected_failures(1)*/) { Translation3D translation{0., 1., 2.}; auto pTransform = std::make_shared<const Transform3D>(translation); diff --git a/Tests/Layers/CylinderLayerTests.cpp b/Tests/Layers/CylinderLayerTests.cpp index 3ec9b53a47a4e2a76c1688abe5d2f54148edbb5e..8f4cc40c6350eed34dbbe27be4f12afa021c80be 100644 --- a/Tests/Layers/CylinderLayerTests.cpp +++ b/Tests/Layers/CylinderLayerTests.cpp @@ -86,7 +86,7 @@ namespace Test { } /// Unit test for testing Layer properties - BOOST_AUTO_TEST_CASE(LayerProperties /*, *utf::expected_failures(1)*/) + BOOST_AUTO_TEST_CASE(CylinderLayerProperties /*, *utf::expected_failures(1)*/) { Translation3D translation{0., 1., 2.}; auto pTransform = std::make_shared<const Transform3D>(translation); diff --git a/Tests/Layers/DiscLayerTests.cpp b/Tests/Layers/DiscLayerTests.cpp index 55ce862966700c852a34a9f7f9e7ab2ce5ef332a..8d9dd5c96104948d75469697a3863fa27b973f2f 100644 --- a/Tests/Layers/DiscLayerTests.cpp +++ b/Tests/Layers/DiscLayerTests.cpp @@ -86,7 +86,7 @@ namespace Test { } /// Unit test for testing Layer properties - BOOST_AUTO_TEST_CASE(LayerProperties /*, *utf::expected_failures(1)*/) + BOOST_AUTO_TEST_CASE(DiscLayerProperties /*, *utf::expected_failures(1)*/) { Translation3D translation{0., 1., 2.}; auto pTransform = std::make_shared<const Transform3D>(translation); diff --git a/Tests/Layers/LayerStub.hpp b/Tests/Layers/LayerStub.hpp index afdec4a7464b5ae7cc0f6c350c2690d7b098a437..8b7fa990a4c1c40e44472f5121b4665e7b7610d0 100644 --- a/Tests/Layers/LayerStub.hpp +++ b/Tests/Layers/LayerStub.hpp @@ -13,6 +13,8 @@ namespace Acts { /// Layer derived class stub +///Note: Layer classes in general have a static 'create' factory method, but nothing +///in the baseclasses mandates this. class LayerStub : virtual public SurfaceStub, public Layer { public: @@ -50,6 +52,12 @@ public: { return (*this); } + + /// simply return true to show a method can be called on the constructed object + bool + constructedOk() const { + return true; + } /// Other methods have implementation in baseclass /// templated 'onLayer()' from baseclass ? diff --git a/Tests/Layers/LayerTests.cpp b/Tests/Layers/LayerTests.cpp index 63997830963bd4d0b74e2eda7445f5300f591993..6972e5e089f5a81ea42ff7c2c57bf849017abf67 100644 --- a/Tests/Layers/LayerTests.cpp +++ b/Tests/Layers/LayerTests.cpp @@ -43,7 +43,7 @@ namespace Test { // /// Minimum possible construction (default constructor is deleted) LayerStub minallyConstructed(nullptr); - BOOST_TEST(minallyConstructed.layerType() == passive); + BOOST_TEST(minallyConstructed.constructedOk()); /// Need an approach descriptor for the next level of complexity: const std::vector<const Surface*> aSurfaces{new SurfaceStub(), new SurfaceStub()}; @@ -53,7 +53,7 @@ namespace Test { LayerStub approachDescriptorConstructed( nullptr, thickness, std::move(ad)); /// Construction with (minimal) approach descriptor - BOOST_TEST(approachDescriptorConstructed.layerType() == passive); + BOOST_TEST(approachDescriptorConstructed.constructedOk()); // Copy construction is deleted } diff --git a/Tests/Layers/NavigationLayerTests.cpp b/Tests/Layers/NavigationLayerTests.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86bb8b6989eb7eaae5e24c38c28b10c40a8a2438 --- /dev/null +++ b/Tests/Layers/NavigationLayerTests.cpp @@ -0,0 +1,79 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 ACTS project team +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#define BOOST_TEST_MODULE Layer Tests + +#include <boost/test/included/unit_test.hpp> +// leave blank line + +#include <boost/test/data/test_case.hpp> +// leave blank line + +#include <boost/test/output_test_stream.hpp> +// leave blank line + +//#include <limits> +#include "ACTS/Layers/NavigationLayer.hpp" +#include "ACTS/Surfaces/ConeBounds.hpp" +//#include "ACTS/Utilities/Definitions.hpp" +#include "ACTS/EventData/SingleTrackParameters.hpp" +#include "ACTS/Layers/GenericApproachDescriptor.hpp" +#include "ACTS/Tools/SurfaceArrayCreator.hpp" +#include "ACTS/Volumes/CuboidVolumeBounds.hpp" +#include "LayerStub.hpp" + +using boost::test_tools::output_test_stream; +namespace utf = boost::unit_test; + +namespace Acts { + +namespace Test { + namespace Layers { + BOOST_AUTO_TEST_SUITE(Layers); + + /// Unit test for creating compliant/non-compliant NavigationLayer object + BOOST_AUTO_TEST_CASE(NavigationLayerConstruction) + { + // default constructor, copy and assignment are all deleted + auto pSurface = std::unique_ptr<const Surface> (new SurfaceStub()); + auto pNavigationLayer = NavigationLayer::create(std::move(pSurface)); + BOOST_TEST(pNavigationLayer->layerType() == LayerType::navigation); + // next level: with thickness + const double thickness=0.1; + auto pSurface2 = std::unique_ptr<const Surface> (new SurfaceStub()); + auto pThickNavigationLayer = NavigationLayer::create(std::move(pSurface2),thickness); + BOOST_TEST(pThickNavigationLayer->layerType() == LayerType::navigation); + } + + /// Unit test for testing NavigationLayer properties + BOOST_AUTO_TEST_CASE(NavigationLayerProperties, *utf::expected_failures(1)) + { + const double thickness=0.1; + auto pSurface = std::unique_ptr<const Surface> (new SurfaceStub()); + auto rawSurfacePtr = pSurface.get(); + auto pNavigationLayer = NavigationLayer::create(std::move(pSurface),thickness); + BinningValue b{BinningValue::binZ}; + Vector3D origin{0.,0.,0.}; + //binningPosition(), needs a better test + BOOST_TEST(pNavigationLayer->binningPosition(b) == origin); + //surfaceRepresentation() [looks dangerous] + BOOST_TEST(rawSurfacePtr == &(pNavigationLayer->surfaceRepresentation())); + //isOnLayer() + BOOST_CHECK(pNavigationLayer->isOnLayer(origin,true)); + //isOnLayer() + Vector3D crazyPosition{1000.,10000.,std::nan("")}; + BOOST_CHECK(pNavigationLayer->isOnLayer(crazyPosition,true) == false); + //resolve() + BOOST_CHECK(pNavigationLayer->resolve(true, true, true) == false); + } + + BOOST_AUTO_TEST_SUITE_END(); + } // end of namespace Layers +} // end of namespace Test + +} // end of namespace Acts diff --git a/Tests/Layers/PlaneLayerTests.cpp b/Tests/Layers/PlaneLayerTests.cpp index 807773a461eaf1b5e3cf696d750865a93420b2e3..fd625da48729e06edd662796f678d9173a6bde58 100644 --- a/Tests/Layers/PlaneLayerTests.cpp +++ b/Tests/Layers/PlaneLayerTests.cpp @@ -87,7 +87,7 @@ namespace Test { } /// Unit test for testing Layer properties - BOOST_AUTO_TEST_CASE(LayerProperties /*, *utf::expected_failures(1)*/) + BOOST_AUTO_TEST_CASE(PlaneLayerProperties /*, *utf::expected_failures(1)*/) { Translation3D translation{0., 1., 2.}; auto pTransform = std::make_shared<const Transform3D>(translation);