File indexing completed on 2025-01-18 09:12:31
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Direction.hpp"
0013
0014 #include <string>
0015
0016 using namespace Acts;
0017
0018 BOOST_AUTO_TEST_SUITE(DefinitionsDirection)
0019
0020 BOOST_AUTO_TEST_CASE(DirectionTests) {
0021 constexpr Direction bwd = Direction::Backward();
0022 constexpr Direction fwd = Direction::Forward();
0023
0024 BOOST_CHECK_EQUAL(bwd, Direction::Negative());
0025 BOOST_CHECK_EQUAL(fwd, Direction::Positive());
0026
0027 BOOST_CHECK_EQUAL(Direction::fromScalar(-1.), bwd);
0028 BOOST_CHECK_EQUAL(Direction::fromScalar(1.), fwd);
0029 BOOST_CHECK_EQUAL(Direction::fromScalarZeroAsPositive(0), fwd);
0030
0031 BOOST_CHECK_EQUAL(Direction::fromIndex(0), bwd);
0032 BOOST_CHECK_EQUAL(Direction::fromIndex(1), fwd);
0033
0034 BOOST_CHECK_EQUAL(bwd.index(), 0u);
0035 BOOST_CHECK_EQUAL(fwd.index(), 1u);
0036
0037 BOOST_CHECK_EQUAL(bwd.sign(), -1);
0038 BOOST_CHECK_EQUAL(fwd.sign(), +1);
0039
0040 BOOST_CHECK_EQUAL(bwd.invert(), fwd);
0041 BOOST_CHECK_EQUAL(fwd.invert(), bwd);
0042
0043 BOOST_CHECK_EQUAL(bwd.toString(), "backward");
0044 BOOST_CHECK_EQUAL(fwd.toString(), "forward");
0045
0046 BOOST_CHECK_EQUAL(2. * fwd, 2.);
0047 BOOST_CHECK_EQUAL(7 * fwd, 7);
0048 BOOST_CHECK_EQUAL(Vector3(1., 1., 1.) * fwd, Vector3(1., 1., 1.));
0049
0050 BOOST_CHECK_EQUAL(2. * bwd, -2.);
0051 BOOST_CHECK_EQUAL(7 * bwd, -7);
0052 BOOST_CHECK_EQUAL(Vector3(1., 1., 1.) * bwd, Vector3(-1., -1., -1.));
0053
0054 double a = 7.;
0055 a *= fwd;
0056 BOOST_CHECK_EQUAL(a, 7.);
0057 a *= bwd;
0058 BOOST_CHECK_EQUAL(a, -7.);
0059
0060 float b = 8.;
0061 b *= fwd;
0062 BOOST_CHECK_EQUAL(b, 8.);
0063 b *= bwd;
0064 BOOST_CHECK_EQUAL(b, -8.);
0065
0066 Vector3 c(9., 9., 9.);
0067 c *= fwd;
0068 BOOST_CHECK_EQUAL(c, Vector3(9., 9., 9.));
0069 c *= bwd;
0070 BOOST_CHECK_EQUAL(c, Vector3(-9., -9., -9.));
0071 }
0072
0073 BOOST_AUTO_TEST_SUITE_END()