Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstrainedStepTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConstrainedStepTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 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/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
14 
15 #include <limits>
16 
17 namespace bdata = boost::unit_test::data;
18 namespace tt = boost::test_tools;
19 
20 namespace Acts {
21 
22 namespace Test {
23 
24 // This tests the implementation of the AbortList
25 // and the standard aborters
26 BOOST_AUTO_TEST_CASE(ConstrainedStepTest) {
27  // forward stepping test
28  ConstrainedStep stepSize_p(0.25);
29 
30  // All of the types should be 0.25 now
31  BOOST_CHECK_EQUAL(stepSize_p.accuracy(), std::numeric_limits<double>::max());
32  BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::actor),
33  std::numeric_limits<double>::max());
34  BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::aborter),
35  std::numeric_limits<double>::max());
36  BOOST_CHECK_EQUAL(stepSize_p.value(ConstrainedStep::user), 0.25);
37 
38  // Check the cast operation to double
39  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.25);
40 
41  // now we set the accuracy
42  stepSize_p.setAccuracy(0.1);
43  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.1);
44 
45  // now we update the actor to smaller
46  stepSize_p.update(0.05, ConstrainedStep::actor);
47  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
48  // we increase the actor, but do not release the step size
49  stepSize_p.update(0.15, ConstrainedStep::actor, false);
50  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
51  // we increase the actor, but now DO release the step size
52  // it falls back to the accuracy
53  stepSize_p.update(0.15, ConstrainedStep::actor, true);
54  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.1);
55 
56  // now set two and update them
57  stepSize_p.update(0.05, ConstrainedStep::user);
58  stepSize_p.setAccuracy(0.03);
59  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.03);
60 
61  // now we release the accuracy - to the highest available value
62  stepSize_p.releaseAccuracy();
63  BOOST_CHECK_EQUAL(stepSize_p.accuracy(), std::numeric_limits<double>::max());
64  BOOST_CHECK_EQUAL(stepSize_p.value(), 0.05);
65 }
66 
67 } // namespace Test
68 } // namespace Acts