Back to home page

sPhenix code displayed by LXR

 
 

    


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

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