Skip to content
Snippets Groups Projects
Commit b9ebc38c authored by Shaun Roe's avatar Shaun Roe Committed by Moritz Kiehn
Browse files

Add NavigationLayerTests

parent 34b89e6c
No related branches found
No related tags found
1 merge request!318Layers unit tests
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
/// Factory Constructor - the surface representation is given by pointer /// Factory Constructor - the surface representation is given by pointer
/// (ownership passed) /// (ownership passed)
/// ///
/// @param sRepresentation is the represenation for extrapolation /// @param sRepresentation is the representation for extrapolation
/// @param thickness is the thickness for the binning /// @param thickness is the thickness for the binning
static LayerPtr static LayerPtr
create(std::unique_ptr<const Surface> sRepresentation, double thickness = 0.) create(std::unique_ptr<const Surface> sRepresentation, double thickness = 0.)
......
...@@ -18,4 +18,6 @@ add_executable (ConeLayerTests ConeLayerTests.cpp) ...@@ -18,4 +18,6 @@ add_executable (ConeLayerTests ConeLayerTests.cpp)
target_link_libraries (ConeLayerTests PRIVATE ACTSCore) target_link_libraries (ConeLayerTests PRIVATE ACTSCore)
add_test (NAME ConeLayerTests COMMAND ConeLayerTests) add_test (NAME ConeLayerTests COMMAND ConeLayerTests)
add_executable (NavigationLayerTests NavigationLayerTests.cpp)
target_link_libraries (NavigationLayerTests PRIVATE ACTSCore)
add_test (NAME NavigationLayerTests COMMAND NavigationLayerTests)
...@@ -88,7 +88,7 @@ namespace Test { ...@@ -88,7 +88,7 @@ namespace Test {
} }
/// Unit test for testing Layer properties /// 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.}; Translation3D translation{0., 1., 2.};
auto pTransform = std::make_shared<const Transform3D>(translation); auto pTransform = std::make_shared<const Transform3D>(translation);
......
...@@ -86,7 +86,7 @@ namespace Test { ...@@ -86,7 +86,7 @@ namespace Test {
} }
/// Unit test for testing Layer properties /// 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.}; Translation3D translation{0., 1., 2.};
auto pTransform = std::make_shared<const Transform3D>(translation); auto pTransform = std::make_shared<const Transform3D>(translation);
......
...@@ -86,7 +86,7 @@ namespace Test { ...@@ -86,7 +86,7 @@ namespace Test {
} }
/// Unit test for testing Layer properties /// 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.}; Translation3D translation{0., 1., 2.};
auto pTransform = std::make_shared<const Transform3D>(translation); auto pTransform = std::make_shared<const Transform3D>(translation);
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace Acts { namespace Acts {
/// Layer derived class stub /// 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 class LayerStub : virtual public SurfaceStub, public Layer
{ {
public: public:
...@@ -50,6 +52,12 @@ public: ...@@ -50,6 +52,12 @@ public:
{ {
return (*this); 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 /// Other methods have implementation in baseclass
/// templated 'onLayer()' from baseclass ? /// templated 'onLayer()' from baseclass ?
......
...@@ -43,7 +43,7 @@ namespace Test { ...@@ -43,7 +43,7 @@ namespace Test {
// //
/// Minimum possible construction (default constructor is deleted) /// Minimum possible construction (default constructor is deleted)
LayerStub minallyConstructed(nullptr); LayerStub minallyConstructed(nullptr);
BOOST_TEST(minallyConstructed.layerType() == passive); BOOST_TEST(minallyConstructed.constructedOk());
/// Need an approach descriptor for the next level of complexity: /// Need an approach descriptor for the next level of complexity:
const std::vector<const Surface*> aSurfaces{new SurfaceStub(), const std::vector<const Surface*> aSurfaces{new SurfaceStub(),
new SurfaceStub()}; new SurfaceStub()};
...@@ -53,7 +53,7 @@ namespace Test { ...@@ -53,7 +53,7 @@ namespace Test {
LayerStub approachDescriptorConstructed( LayerStub approachDescriptorConstructed(
nullptr, thickness, std::move(ad)); nullptr, thickness, std::move(ad));
/// Construction with (minimal) approach descriptor /// Construction with (minimal) approach descriptor
BOOST_TEST(approachDescriptorConstructed.layerType() == passive); BOOST_TEST(approachDescriptorConstructed.constructedOk());
// Copy construction is deleted // Copy construction is deleted
} }
......
// 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
...@@ -87,7 +87,7 @@ namespace Test { ...@@ -87,7 +87,7 @@ namespace Test {
} }
/// Unit test for testing Layer properties /// 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.}; Translation3D translation{0., 1., 2.};
auto pTransform = std::make_shared<const Transform3D>(translation); auto pTransform = std::make_shared<const Transform3D>(translation);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment