Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:46

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/Units.hpp"
0012 #include "Acts/EventData/SourceLink.hpp"
0013 #include "Acts/EventData/detail/TestSourceLink.hpp"
0014 #include "Acts/Geometry/GeometryIdentifier.hpp"
0015 
0016 #include <any>
0017 #include <sstream>
0018 
0019 using namespace Acts;
0020 using namespace Acts::UnitLiterals;
0021 
0022 namespace ActsTests {
0023 
0024 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0025 
0026 BOOST_AUTO_TEST_CASE(TestSourceLinkCoverage) {
0027   using detail::Test::TestSourceLink;
0028 
0029   Vector2 stddev(0.01, 0.1);
0030   SquareMatrix2 cov = stddev.cwiseProduct(stddev).asDiagonal();
0031   TestSourceLink l1(eBoundLoc0, 0.1, cov(0, 0), GeometryIdentifier(0x999), 0);
0032   TestSourceLink l2(l1);
0033 
0034   BOOST_CHECK(l1 == l2);     // testing the ==
0035   BOOST_CHECK(!(l1 != l2));  // testing the !=
0036   std::ostringstream str;
0037   str << l1;
0038 }
0039 
0040 struct MySourceLink {
0041   GeometryIdentifier m_geometryId;
0042 
0043   GeometryIdentifier geometryId() const { return m_geometryId; }
0044 };
0045 
0046 BOOST_AUTO_TEST_CASE(Construct) {
0047   MySourceLink msl;
0048   msl.m_geometryId = GeometryIdentifier().withSensitive(42);
0049   {
0050     SourceLink sl{msl};
0051     BOOST_CHECK_EQUAL(sl.get<MySourceLink>().geometryId(), msl.geometryId());
0052     BOOST_CHECK_THROW(sl.get<int>(), std::bad_any_cast);
0053   }
0054 }
0055 
0056 BOOST_AUTO_TEST_CASE(Reassign) {
0057   int value = 5;
0058   SourceLink sl{value};
0059 
0060   BOOST_CHECK_EQUAL(sl.get<int>(), value);
0061   BOOST_CHECK_THROW(sl.get<double>(), std::bad_any_cast);
0062 
0063   double otherValue = 42.42;
0064 
0065   // this changes the stored type
0066   sl = SourceLink{otherValue};
0067   BOOST_CHECK_EQUAL(sl.get<double>(), otherValue);
0068   BOOST_CHECK_THROW(sl.get<int>(), std::bad_any_cast);
0069 }
0070 
0071 BOOST_AUTO_TEST_SUITE_END()
0072 
0073 }  // namespace ActsTests