Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:11:35

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2017-2018 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/tools/output_test_stream.hpp>
0011 #include <boost/test/unit_test.hpp>
0012 
0013 #include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
0014 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp"
0015 
0016 using Acts::detail::RealQuadraticEquation;
0017 
0018 namespace Acts {
0019 namespace Test {
0020 BOOST_AUTO_TEST_SUITE(Surfaces)
0021 /// Unit test for creating RealQuadraticEquation object
0022 BOOST_AUTO_TEST_CASE(RealQuadraticEquationConstruction) {
0023   double a(1.0), b(-3.), c(2.);
0024   // test default construction: not deleted, not written
0025   // RealQuadraticEquation defaultConstructedRealQuadraticEquation;
0026   //
0027   /// Test construction with parameters
0028   BOOST_REQUIRE_NO_THROW(RealQuadraticEquation(a, b, c));
0029   //
0030   /// Copy constructor (implicit), void removes 'unused' compiler warning
0031   RealQuadraticEquation orig(a, b, c);
0032   BOOST_REQUIRE_NO_THROW(RealQuadraticEquation copied(orig); (void)copied);
0033 }
0034 /// Unit test for RealQuadraticEquation properties
0035 BOOST_AUTO_TEST_CASE(RealQuadraticEquationProperties) {
0036   double a(1.0), b(-3.), c(2.);
0037   //
0038   /// Test construction with parameters
0039   RealQuadraticEquation equation(a, b, c);
0040   //
0041   /// Test for solutions
0042   CHECK_CLOSE_REL(equation.first, 2., 1e-6);
0043   CHECK_CLOSE_REL(equation.second, 1., 1e-6);
0044   BOOST_CHECK_EQUAL(equation.solutions, 2);
0045 }
0046 
0047 /// Unit test for testing RealQuadraticEquation assignment
0048 BOOST_AUTO_TEST_CASE(RealQuadraticEquationAssignment) {
0049   double a(1.0), b(-3.), c(2.);
0050   RealQuadraticEquation realQuadraticEquationObject(a, b, c);
0051   // operator == not implemented in this class
0052   //
0053   /// Test assignment (implicit)
0054   RealQuadraticEquation assignedRealQuadraticEquationObject(9., -3.5, 6.7);
0055   assignedRealQuadraticEquationObject = realQuadraticEquationObject;
0056   CHECK_CLOSE_REL(assignedRealQuadraticEquationObject.first, 2., 1e-6);
0057   CHECK_CLOSE_REL(assignedRealQuadraticEquationObject.second, 1., 1e-6);
0058   BOOST_CHECK_EQUAL(assignedRealQuadraticEquationObject.solutions, 2);
0059   /// equality not written and not implicit
0060   // BOOST_CHECK_EQUAL(assignedRealQuadraticEquationObject,
0061   //                   realQuadraticEquationObject);
0062 }
0063 BOOST_AUTO_TEST_SUITE_END()
0064 }  // namespace Test
0065 }  // namespace Acts