Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DirectionTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DirectionTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/unit_test.hpp>
10 
13 
14 #include <string>
15 
16 using namespace Acts;
17 
18 BOOST_AUTO_TEST_SUITE(DefinitionsDirection)
19 
20 BOOST_AUTO_TEST_CASE(DirectionTests) {
21  constexpr Direction bwd = Direction::Backward;
22  constexpr Direction fwd = Direction::Forward;
23 
24  BOOST_CHECK(bwd == Direction::Negative);
25  BOOST_CHECK(fwd == Direction::Positive);
26 
27  BOOST_CHECK(Direction::fromScalar(-1.) == bwd);
28  BOOST_CHECK(Direction::fromScalar(1.) == fwd);
29  BOOST_CHECK(Direction::fromScalarZeroAsPositive(0) == fwd);
30 
31  BOOST_CHECK(Direction::fromIndex(0) == bwd);
32  BOOST_CHECK(Direction::fromIndex(1) == fwd);
33 
34  BOOST_CHECK(bwd.index() == 0u);
35  BOOST_CHECK(fwd.index() == 1u);
36 
37  BOOST_CHECK(bwd.sign() == -1);
38  BOOST_CHECK(fwd.sign() == +1);
39 
40  BOOST_CHECK(bwd.invert() == fwd);
41  BOOST_CHECK(fwd.invert() == bwd);
42 
43  BOOST_CHECK(bwd.toString() == "backward");
44  BOOST_CHECK(fwd.toString() == "forward");
45 
46  BOOST_CHECK(2. * fwd == 2.);
47  BOOST_CHECK(7 * fwd == 7);
48  BOOST_CHECK(Vector3(1., 1., 1.) * fwd == Vector3(1., 1., 1.));
49 
50  BOOST_CHECK(2. * bwd == -2.);
51  BOOST_CHECK(7 * bwd == -7);
52  BOOST_CHECK(Vector3(1., 1., 1.) * bwd == Vector3(-1., -1., -1.));
53 
54  double a = 7.;
55  a *= fwd;
56  BOOST_CHECK(a == 7.);
57  a *= bwd;
58  BOOST_CHECK(a == -7.);
59 
60  float b = 8.;
61  b *= fwd;
62  BOOST_CHECK(b == 8.);
63  b *= bwd;
64  BOOST_CHECK(b == -8.);
65 
66  Vector3 c(9., 9., 9.);
67  c *= fwd;
68  BOOST_CHECK(c == Vector3(9., 9., 9.));
69  c *= bwd;
70  BOOST_CHECK(c == Vector3(-9., -9., -9.));
71 }
72 
73 BOOST_AUTO_TEST_SUITE_END()