Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Tests/UnitTests/Core/Definitions/DirectionTests.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 namespace ActsTests {
0019 
0020 BOOST_AUTO_TEST_SUITE(DefinitionsSuite)
0021 
0022 BOOST_AUTO_TEST_CASE(DirectionTests) {
0023   constexpr Direction bwd = Direction::Backward();
0024   constexpr Direction fwd = Direction::Forward();
0025 
0026   BOOST_CHECK_EQUAL(bwd, Direction::Negative());
0027   BOOST_CHECK_EQUAL(fwd, Direction::Positive());
0028 
0029   BOOST_CHECK_EQUAL(Direction::fromScalar(-1.), bwd);
0030   BOOST_CHECK_EQUAL(Direction::fromScalar(1.), fwd);
0031   BOOST_CHECK_EQUAL(Direction::fromScalarZeroAsPositive(0), fwd);
0032 
0033   BOOST_CHECK_EQUAL(Direction::fromIndex(0), bwd);
0034   BOOST_CHECK_EQUAL(Direction::fromIndex(1), fwd);
0035 
0036   BOOST_CHECK_EQUAL(bwd.index(), 0u);
0037   BOOST_CHECK_EQUAL(fwd.index(), 1u);
0038 
0039   BOOST_CHECK_EQUAL(bwd.sign(), -1);
0040   BOOST_CHECK_EQUAL(fwd.sign(), +1);
0041 
0042   BOOST_CHECK_EQUAL(bwd.invert(), fwd);
0043   BOOST_CHECK_EQUAL(fwd.invert(), bwd);
0044 
0045   BOOST_CHECK_EQUAL(bwd.toString(), "backward");
0046   BOOST_CHECK_EQUAL(fwd.toString(), "forward");
0047 
0048   BOOST_CHECK_EQUAL(2. * fwd, 2.);
0049   BOOST_CHECK_EQUAL(7 * fwd, 7);
0050   BOOST_CHECK_EQUAL(Vector3(1., 1., 1.) * fwd, Vector3(1., 1., 1.));
0051 
0052   BOOST_CHECK_EQUAL(2. * bwd, -2.);
0053   BOOST_CHECK_EQUAL(7 * bwd, -7);
0054   BOOST_CHECK_EQUAL(Vector3(1., 1., 1.) * bwd, Vector3(-1., -1., -1.));
0055 
0056   double a = 7.;
0057   a *= fwd;
0058   BOOST_CHECK_EQUAL(a, 7.);
0059   a *= bwd;
0060   BOOST_CHECK_EQUAL(a, -7.);
0061 
0062   float b = 8.;
0063   b *= fwd;
0064   BOOST_CHECK_EQUAL(b, 8.);
0065   b *= bwd;
0066   BOOST_CHECK_EQUAL(b, -8.);
0067 
0068   Vector3 c(9., 9., 9.);
0069   c *= fwd;
0070   BOOST_CHECK_EQUAL(c, Vector3(9., 9., 9.));
0071   c *= bwd;
0072   BOOST_CHECK_EQUAL(c, Vector3(-9., -9., -9.));
0073 }
0074 
0075 BOOST_AUTO_TEST_SUITE_END()
0076 
0077 }  // namespace ActsTests