Skip to content

Commit 82a5fec

Browse files
dstoccosawenzel
authored andcommitted
Reduce number of generated tests for MID geometry transformer (#1451)
* Reduce number of tests * Re-enable tests after reducing their number
1 parent b945386 commit 82a5fec

File tree

2 files changed

+25
-40
lines changed

2 files changed

+25
-40
lines changed

Detectors/MUON/MID/Base/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ O2_GENERATE_TESTS(
3838
TEST_SRCS test/testDEconversion.cxx
3939
)
4040

41-
# SW: This test takes very very long
42-
#O2_GENERATE_TESTS(
43-
# MODULE_LIBRARY_NAME ${LIBRARY_NAME}
44-
# BUCKET_NAME ${BUCKET_NAME}
45-
# TEST_SRCS test/testGeometryTransformer.cxx
46-
#)
41+
O2_GENERATE_TESTS(
42+
MODULE_LIBRARY_NAME ${LIBRARY_NAME}
43+
BUCKET_NAME ${BUCKET_NAME}
44+
TEST_SRCS test/testGeometryTransformer.cxx
45+
)

Detectors/MUON/MID/Base/test/testGeometryTransformer.cxx

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
/// \author Diego Stocco <Diego.Stocco at cern.ch>
1414
/// \date 14 March 2018
1515

16+
#define BOOST_TEST_MODULE Test MID geometry transformer
1617
#define BOOST_TEST_DYN_LINK
17-
#define BOOST_TEST_MAIN
1818

1919
#include <boost/test/unit_test.hpp>
2020

@@ -37,58 +37,44 @@ o2::mid::GeometryTransformer GEOM::geoTrans;
3737
BOOST_AUTO_TEST_SUITE(o2_mid_geometryTransformer)
3838
BOOST_FIXTURE_TEST_SUITE(geo, GEOM)
3939

40-
std::vector<Point3D<double>> generatePoints(int ntimes)
40+
BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(0.00001))
41+
BOOST_DATA_TEST_CASE(InverseTransformation, boost::unit_test::data::xrange(72), deId)
4142
{
43+
4244
std::random_device rd;
4345
std::mt19937 mt(rd());
4446
std::uniform_real_distribution<double> distX(-127.5, 127.5);
4547
std::uniform_real_distribution<double> distY(-40., 40.);
4648

47-
std::vector<Point3D<double>> points;
49+
for (int ipt = 0; ipt < 1000; ++ipt) {
50+
Point3D<double> point(distX(mt), distY(mt), 0.);
4851

49-
for (int itime = 0; itime < ntimes; ++itime) {
50-
points.emplace_back(distX(mt), distY(mt), 0.);
51-
}
52+
Point3D<double> globalPoint = GEOM::geoTrans.localToGlobal(deId, point.x(), point.y());
53+
Point3D<double> localPoint = GEOM::geoTrans.globalToLocal(deId, globalPoint.x(), globalPoint.y(), globalPoint.z());
5254

53-
return points;
55+
BOOST_TEST(localPoint.x() == point.x());
56+
BOOST_TEST(localPoint.y() == point.y());
57+
BOOST_TEST(localPoint.z() == point.z());
58+
}
5459
}
5560

5661
BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(0.00001))
57-
BOOST_DATA_TEST_CASE(InverseTransformation, boost::unit_test::data::xrange(72) * generatePoints(1000), deId, point)
58-
{
59-
Point3D<double> globalPoint = GEOM::geoTrans.localToGlobal(deId, point.x(), point.y());
60-
Point3D<double> localPoint = GEOM::geoTrans.globalToLocal(deId, globalPoint.x(), globalPoint.y(), globalPoint.z());
61-
62-
BOOST_TEST(localPoint.x() == point.x());
63-
BOOST_TEST(localPoint.y() == point.y());
64-
BOOST_TEST(localPoint.z() == point.z());
65-
}
66-
67-
std::vector<Vector3D<double>> generateSlopes(int ntimes)
62+
BOOST_DATA_TEST_CASE(InverseTransformationSlope, boost::unit_test::data::xrange(72), deId)
6863
{
6964
std::random_device rd;
7065
std::mt19937 mt(rd());
7166
std::uniform_real_distribution<double> distX(-1., 1.);
7267
std::uniform_real_distribution<double> distY(-1., 1.);
7368

74-
std::vector<Vector3D<double>> slopes;
69+
for (int ipt = 0; ipt < 1000; ++ipt) {
70+
Vector3D<double> slope(distX(mt), distY(mt), 1.);
71+
Vector3D<double> globalSlope = GEOM::geoTrans.localToGlobal(deId, slope);
72+
Vector3D<double> localSlope = GEOM::geoTrans.globalToLocal(deId, globalSlope);
7573

76-
for (int itime = 0; itime < ntimes; ++itime) {
77-
slopes.emplace_back(distX(mt), distY(mt), 1.);
74+
BOOST_TEST(localSlope.x() == slope.x());
75+
BOOST_TEST(localSlope.y() == slope.y());
76+
BOOST_TEST(localSlope.z() == slope.z());
7877
}
79-
80-
return slopes;
81-
}
82-
83-
BOOST_TEST_DECORATOR(*boost::unit_test::tolerance(0.00001))
84-
BOOST_DATA_TEST_CASE(InverseTransformationSlope, boost::unit_test::data::xrange(72) * generateSlopes(1000), deId, slope)
85-
{
86-
Vector3D<double> globalSlope = GEOM::geoTrans.localToGlobal(deId, slope);
87-
Vector3D<double> localSlope = GEOM::geoTrans.globalToLocal(deId, globalSlope);
88-
89-
BOOST_TEST(localSlope.x() == slope.x());
90-
BOOST_TEST(localSlope.y() == slope.y());
91-
BOOST_TEST(localSlope.z() == slope.z());
9278
}
9379

9480
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)