File indexing completed on 2025-08-05 08:09:57
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/tools/old/interface.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 #include <boost/test/unit_test_suite.hpp>
0012
0013 #include "Acts/Utilities/detail/TransformComparator.hpp"
0014
0015 BOOST_AUTO_TEST_SUITE(TransformComparatorTests)
0016
0017 BOOST_AUTO_TEST_CASE(Vector3Sorting) {
0018
0019 Acts::detail::TransformComparator sorter{};
0020 Acts::detail::TransformComparator sorterWithTol{0.5, 0.5};
0021
0022 for (unsigned dimA = 0; dimA < 3; ++dimA) {
0023 const Acts::Vector3 aPlus = Acts::Vector3::Unit(dimA);
0024 const Acts::Vector3 aMinus = -aPlus;
0025 BOOST_CHECK_EQUAL(sorter.compare<3>(aPlus, aPlus), 0);
0026 BOOST_CHECK_EQUAL(sorter.compare<3>(aPlus, aMinus), 1);
0027 BOOST_CHECK_EQUAL(sorter.compare<3>(aMinus, aPlus), -1);
0028 BOOST_CHECK_NE(sorter(aPlus, aMinus), sorter(aMinus, aPlus));
0029
0030 const Acts::Vector3 halfPlus =
0031 (0.5 + std::numeric_limits<double>::epsilon()) * aPlus;
0032 const Acts::Vector3 halfMinus =
0033 (0.5 - std::numeric_limits<double>::epsilon()) * aPlus;
0034
0035 BOOST_CHECK_EQUAL(sorterWithTol.compare<3>(aPlus, halfPlus), 0);
0036 BOOST_CHECK_NE(sorterWithTol.compare<3>(aPlus, halfMinus), 0);
0037 for (unsigned dimB = 0; dimB < 3; ++dimB) {
0038 const Acts::Vector3 bPlus = Acts::Vector3::Unit(dimB);
0039 const int expectSign = (dimA == dimB) ? 0 : dimA > dimB ? -1 : 1;
0040 BOOST_CHECK_EQUAL(sorter.compare<3>(aPlus, bPlus), expectSign);
0041 }
0042 }
0043 }
0044
0045 BOOST_AUTO_TEST_CASE(Vector2Sorting) {
0046 Acts::detail::TransformComparator sorter{};
0047 Acts::detail::TransformComparator sorterWithTol{0.5, 0.5};
0048
0049 for (unsigned dimA = 0; dimA < 2; ++dimA) {
0050 const Acts::Vector2 aPlus = Acts::Vector2::Unit(dimA);
0051 const Acts::Vector2 aMinus = -aPlus;
0052 BOOST_CHECK_EQUAL(sorter.compare<2>(aPlus, aPlus), 0);
0053 BOOST_CHECK_EQUAL(sorter.compare<2>(aPlus, aMinus), 1);
0054 BOOST_CHECK_EQUAL(sorter.compare<2>(aMinus, aPlus), -1);
0055 BOOST_CHECK_NE(sorter(aPlus, aMinus), sorter(aMinus, aPlus));
0056
0057 const Acts::Vector2 halfPlus =
0058 (0.5 + std::numeric_limits<double>::epsilon()) * aPlus;
0059 const Acts::Vector2 halfMinus =
0060 (0.5 - std::numeric_limits<double>::epsilon()) * aPlus;
0061
0062 BOOST_CHECK_EQUAL(sorterWithTol.compare<2>(aPlus, halfPlus), 0);
0063 BOOST_CHECK_NE(sorterWithTol.compare<2>(aPlus, halfMinus), 0);
0064 for (unsigned dimB = 0; dimB < 2; ++dimB) {
0065 const Acts::Vector2 bPlus = Acts::Vector2::Unit(dimB);
0066 const int expectSign = (dimA == dimB) ? 0 : dimA > dimB ? -1 : 1;
0067 BOOST_CHECK_EQUAL(sorter.compare<2>(aPlus, bPlus), expectSign);
0068 }
0069 }
0070 }
0071
0072 BOOST_AUTO_TEST_SUITE_END()