From 642e62113231f796a45ef0fc88986ae46f119333 Mon Sep 17 00:00:00 2001 From: Ianna Osborne Date: Wed, 20 Mar 2019 12:07:50 +0100 Subject: [PATCH] Add unit tests --- DetectorDescription/DDCMS/interface/Filter.h | 2 +- DetectorDescription/DDCMS/test/BuildFile.xml | 1 + .../DDCMS/test/DDFilteredView.cppunit.cc | 24 ++++++++-- .../DDCMS/test/ExpandedNodes.cppunit.cc | 46 +++++++++++++++++++ .../interface/DTGeometryBuilder.h | 2 +- 5 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc diff --git a/DetectorDescription/DDCMS/interface/Filter.h b/DetectorDescription/DDCMS/interface/Filter.h index 02a0a5f86df35..f07c720d4d269 100644 --- a/DetectorDescription/DDCMS/interface/Filter.h +++ b/DetectorDescription/DDCMS/interface/Filter.h @@ -25,7 +25,7 @@ namespace cms { struct Filter { std::vector keys; - struct std::unique_ptr next; + std::unique_ptr next; struct Filter* up; }; diff --git a/DetectorDescription/DDCMS/test/BuildFile.xml b/DetectorDescription/DDCMS/test/BuildFile.xml index 01ad605820adf..d56021563ca5f 100644 --- a/DetectorDescription/DDCMS/test/BuildFile.xml +++ b/DetectorDescription/DDCMS/test/BuildFile.xml @@ -1,6 +1,7 @@ + diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc index 4781ca1c69506..b4ea649e29b26 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc @@ -1,26 +1,44 @@ #include #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/DDDetector.h" +#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "DD4hep/Detector.h" + +#include +#include #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" +using namespace cms; +using namespace std; + class testDDFilteredView : public CppUnit::TestFixture { - + CPPUNIT_TEST_SUITE(testDDFilteredView); CPPUNIT_TEST(checkFilteredView); CPPUNIT_TEST_SUITE_END(); public: - void setUp() override {} + void setUp() override; void tearDown() override {} void checkFilteredView(); + +private: + + string fileName_; }; CPPUNIT_TEST_SUITE_REGISTRATION(testDDFilteredView); +void testDDFilteredView::setUp() { + fileName_ = edm::FileInPath("DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml").fullPath(); +} + void testDDFilteredView::checkFilteredView() { - cms::DDFilteredView fview(); +unique_ptr det = make_unique("DUMMY", fileName_); + DDFilteredView fview(det.get(), det->description()->worldVolume()); } diff --git a/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc b/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc new file mode 100644 index 0000000000000..0948e9deea2dc --- /dev/null +++ b/DetectorDescription/DDCMS/test/ExpandedNodes.cppunit.cc @@ -0,0 +1,46 @@ +#include + +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" + +#include + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" + +using namespace cms; +using namespace std; + +class testExpandedNodes : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(testExpandedNodes); + CPPUNIT_TEST(checkExpandedNodes); + CPPUNIT_TEST_SUITE_END(); + +public: + + void setUp() override; + void tearDown() override {} + void checkExpandedNodes(); + +private: + ExpandedNodes nodes_; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(testExpandedNodes); + +void +testExpandedNodes::setUp() { + nodes_.tags = { 1., 2., 3. }; + nodes_.offsets = { 1., 2., 3. }; + nodes_.copyNos = { 1, 2, 3 }; +} + +void +testExpandedNodes::checkExpandedNodes() { + cout << "Expanded Nodes...\n"; + CPPUNIT_ASSERT(nodes_.tags.size() == nodes_.offsets.size()); + CPPUNIT_ASSERT(nodes_.tags.size() == nodes_.copyNos.size()); + + for(auto const& i : nodes_.tags) + cout << i << " "; +} diff --git a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h index 0ca2a20a4ab54..b82d354a97541 100644 --- a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h +++ b/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h @@ -17,7 +17,7 @@ class DTLayer; namespace cms { class DDDetector; - struct DDFilteredView; + class DDFilteredView; struct MuonNumbering; struct DDSpecPar;