Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:56

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