Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-18 08:22:52

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/Utilities/detail/Extendable.hpp"
0012 
0013 #include <tuple>
0014 #include <type_traits>
0015 
0016 using namespace Acts;
0017 
0018 namespace ActsTests {
0019 
0020 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0021 
0022 // This tests the implementation of the ActionList
0023 // and the standard aborters
0024 BOOST_AUTO_TEST_CASE(Extendable_) {
0025   struct TypeA {
0026     double vaA = 0.;
0027   };
0028 
0029   struct TypeB {
0030     int vaB = 0;
0031   };
0032 
0033   struct TypeC {
0034     char vaC = '0';
0035   };
0036 
0037   // Test the empty list
0038   detail::Extendable<> nullist{};
0039   (void)nullist;
0040   BOOST_CHECK_EQUAL(std::tuple_size_v<std::tuple<>>, 0u);
0041 
0042   detail::Extendable<TypeA> alist;
0043   auto& a0_object = alist.get<TypeA>();
0044   a0_object.vaA = 1.;
0045   BOOST_CHECK_EQUAL(alist.get<TypeA>().vaA, 1.);
0046 
0047   detail::Extendable<TypeA, TypeB> ablist;
0048   auto& a1_object = ablist.get<TypeA>();
0049   a1_object.vaA = 2.;
0050   auto& b1_object = ablist.get<TypeB>();
0051   b1_object.vaB = 3;
0052   BOOST_CHECK_EQUAL(ablist.get<TypeA>().vaA, 2.);
0053   BOOST_CHECK_EQUAL(ablist.get<TypeB>().vaB, 3);
0054 
0055   TypeC c;
0056   c.vaC = '4';
0057   detail::Extendable<TypeA, TypeB, TypeC> abcList = ablist.append<TypeC>(c);
0058   BOOST_CHECK_EQUAL(abcList.get<TypeA>().vaA, 2.);
0059   BOOST_CHECK_EQUAL(abcList.get<TypeB>().vaB, 3);
0060   BOOST_CHECK_EQUAL(abcList.get<TypeC>().vaC, '4');
0061 }
0062 
0063 BOOST_AUTO_TEST_SUITE_END()
0064 
0065 }  // namespace ActsTests