File indexing completed on 2025-01-18 09:12:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Utilities/RangeXD.hpp"
0012
0013 #include <limits>
0014
0015 namespace Acts::Test {
0016
0017 BOOST_AUTO_TEST_SUITE(Utilities)
0018
0019 BOOST_AUTO_TEST_SUITE(RangeXD)
0020
0021 BOOST_AUTO_TEST_CASE(default_constructor_double) {
0022 Acts::RangeXD<3, double> r;
0023
0024 BOOST_CHECK_EQUAL(r[0].min(), std::numeric_limits<double>::lowest());
0025 BOOST_CHECK_EQUAL(r[0].max(), std::numeric_limits<double>::max());
0026 BOOST_CHECK_EQUAL(r[1].min(), std::numeric_limits<double>::lowest());
0027 BOOST_CHECK_EQUAL(r[1].max(), std::numeric_limits<double>::max());
0028 BOOST_CHECK_EQUAL(r[2].min(), std::numeric_limits<double>::lowest());
0029 BOOST_CHECK_EQUAL(r[2].max(), std::numeric_limits<double>::max());
0030 }
0031
0032 BOOST_AUTO_TEST_CASE(mutate_ranges_double) {
0033 Acts::RangeXD<3, double> r;
0034
0035 r[0].shrink(-10.0, 10.0);
0036 r[1].shrink(0.0, 50.0);
0037 r[2].shrinkMax(-20.0);
0038
0039 BOOST_CHECK_EQUAL(r[0].min(), -10.0);
0040 BOOST_CHECK_EQUAL(r[0].max(), 10.0);
0041 BOOST_CHECK_EQUAL(r[1].min(), 0.0);
0042 BOOST_CHECK_EQUAL(r[1].max(), 50.0);
0043 BOOST_CHECK_EQUAL(r[2].min(), std::numeric_limits<double>::lowest());
0044 BOOST_CHECK_EQUAL(r[2].max(), -20.0);
0045 }
0046
0047 BOOST_AUTO_TEST_CASE(degenerate_double) {
0048 Acts::RangeXD<3, double> r;
0049
0050 r[0].shrink(-10.0, 10.0);
0051 r[1].shrink(0.0, 50.0);
0052 r[2].shrink(-20.0, -30.0);
0053
0054 BOOST_CHECK(r.degenerate());
0055 }
0056
0057 BOOST_AUTO_TEST_CASE(degenerate_false_double) {
0058 Acts::RangeXD<3, double> r;
0059
0060 r[0].shrink(-10.0, 10.0);
0061 r[1].shrink(0.0, 50.0);
0062 r[2].shrink(-20.0, 30.0);
0063
0064 BOOST_CHECK(!r.degenerate());
0065 }
0066
0067 BOOST_AUTO_TEST_CASE(contains_double) {
0068 Acts::RangeXD<3, double> r;
0069
0070 r[0].shrink(-10.0, 10.0);
0071 r[1].shrink(0.0, 50.0);
0072 r[2].shrink(-20.0, 30.0);
0073
0074 BOOST_CHECK(r.contains({0.0, 1.0, 0.0}));
0075 BOOST_CHECK(r.contains({9.0, 0.5, 29.0}));
0076 BOOST_CHECK(r.contains({-8.0, 40.0, -20.0}));
0077 BOOST_CHECK(r.contains({4.0, 4.0, 4.0}));
0078 BOOST_CHECK(r.contains({0.0, 0.0, 0.0}));
0079 BOOST_CHECK(!r.contains({-12.0, 1.0, 0.0}));
0080 BOOST_CHECK(!r.contains({0.0, -1.0, 0.0}));
0081 BOOST_CHECK(!r.contains({0.0, 1.0, 40.0}));
0082 BOOST_CHECK(!r.contains({20.0, 10.0, 300.0}));
0083 BOOST_CHECK(!r.contains({-100.0, -100.0, -100.0}));
0084 }
0085
0086 BOOST_AUTO_TEST_CASE(equality_int) {
0087 Acts::RangeXD<3, int> r, q;
0088
0089 r[0].shrink(-10, 10);
0090 r[1].shrink(0, 50);
0091 r[2].shrink(-20, 30);
0092
0093 q[0].shrink(-10, 10);
0094 q[1].shrink(0, 50);
0095 q[2].shrink(-20, 30);
0096
0097 BOOST_CHECK((r == q));
0098 }
0099
0100 BOOST_AUTO_TEST_CASE(subset1_double) {
0101 Acts::RangeXD<3, double> r, q;
0102
0103 r[0].shrink(-10.0, 10.0);
0104 r[1].shrink(0.0, 50.0);
0105 r[2].shrink(-20.0, 30.0);
0106
0107 q[0].shrink(-5.0, 5.0);
0108 q[1].shrink(10.0, 100.0);
0109 q[2].shrink(-10.0, 20.0);
0110
0111 BOOST_CHECK(!(r <= q));
0112 BOOST_CHECK(!(q <= r));
0113 }
0114
0115 BOOST_AUTO_TEST_CASE(subset2_double) {
0116 Acts::RangeXD<3, double> r, q;
0117
0118 r[0].shrink(-10.0, 10.0);
0119 r[1].shrink(0.0, 50.0);
0120 r[2].shrink(-20.0, 30.0);
0121
0122 q[0].shrink(-5.0, 5.0);
0123 q[1].shrink(10.0, 20.0);
0124 q[2].shrink(-10.0, 20.0);
0125
0126 BOOST_CHECK(!(r <= q));
0127 BOOST_CHECK((q <= r));
0128 }
0129
0130 BOOST_AUTO_TEST_CASE(superset2_double) {
0131 Acts::RangeXD<3, double> r, q;
0132
0133 r[0].shrink(-10.0, 10.0);
0134 r[1].shrink(0.0, 50.0);
0135 r[2].shrink(-20.0, 30.0);
0136
0137 q[0].shrink(-5.0, 5.0);
0138 q[1].shrink(10.0, 20.0);
0139 q[2].shrink(-10.0, 20.0);
0140
0141 BOOST_CHECK((r >= q));
0142 BOOST_CHECK(!(q >= r));
0143 }
0144
0145 BOOST_AUTO_TEST_CASE(intersection_double) {
0146 Acts::RangeXD<3, double> r, q;
0147
0148 r[0].shrink(-10.0, 10.0);
0149 r[1].shrink(0.0, 50.0);
0150 r[2].shrink(-20.0, 30.0);
0151
0152 q[0].shrink(-5.0, 5.0);
0153 q[1].shrink(10.0, 20.0);
0154 q[2].shrink(-10.0, 20.0);
0155
0156 BOOST_CHECK((r && q));
0157 BOOST_CHECK((q && r));
0158 }
0159
0160 BOOST_AUTO_TEST_CASE(intersection_false_double) {
0161 Acts::RangeXD<3, double> r, q;
0162
0163 r[0].shrink(-10.0, 10.0);
0164 r[1].shrink(0.0, 50.0);
0165 r[2].shrink(-20.0, 30.0);
0166
0167 q[0].shrink(-5.0, 5.0);
0168 q[1].shrink(10.0, 20.0);
0169 q[2].shrink(-100.0, -50.0);
0170
0171 BOOST_CHECK(!(r && q));
0172 BOOST_CHECK(!(q && r));
0173 }
0174
0175 BOOST_AUTO_TEST_CASE(intersection_false2_double) {
0176 Acts::RangeXD<3, double> r, q;
0177
0178 r[0].shrink(-10.0, 10.0);
0179 r[1].shrink(0.0, 50.0);
0180 r[2].shrink(-20.0, 30.0);
0181
0182 q[0].shrink(-50.0, -20.0);
0183 q[1].shrink(-10.0, -5.0);
0184 q[2].shrink(-100.0, -50.0);
0185
0186 BOOST_CHECK(!(r && q));
0187 BOOST_CHECK(!(q && r));
0188 }
0189
0190 BOOST_AUTO_TEST_SUITE_END()
0191
0192 BOOST_AUTO_TEST_SUITE_END()
0193
0194 }