ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtendableTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExtendableTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
14 
15 namespace bdata = boost::unit_test::data;
16 namespace tt = boost::test_tools;
17 
18 namespace Acts {
19 
20 namespace Test {
21 
22 // This tests the implementation of the ActionList
23 // and the standard aborters
24 BOOST_AUTO_TEST_CASE(Extendable_) {
25  struct TypeA {
26  double vaA = 0.;
27  };
28 
29  struct TypeB {
30  int vaB = 0;
31  };
32 
33  struct TypeC {
34  char vaC = '0';
35  };
36 
37  // Test the empty list
38  detail::Extendable<> nullist;
39  (void)nullist;
40  BOOST_CHECK_EQUAL(std::tuple_size<std::tuple<>>::value, 0u);
41 
43  auto& a0_object = alist.get<TypeA>();
44  a0_object.vaA = 1.;
45  BOOST_CHECK_EQUAL(alist.get<TypeA>().vaA, 1.);
46 
48  auto& a1_object = ablist.get<TypeA>();
49  a1_object.vaA = 2.;
50  auto& b1_object = ablist.get<TypeB>();
51  b1_object.vaB = 3;
52  BOOST_CHECK_EQUAL(ablist.get<TypeA>().vaA, 2.);
53  BOOST_CHECK_EQUAL(ablist.get<TypeB>().vaB, 3);
54 
55  TypeC c;
56  c.vaC = '4';
57  detail::Extendable<TypeA, TypeB, TypeC> abcList = ablist.append<TypeC>(c);
58  BOOST_CHECK_EQUAL(abcList.get<TypeA>().vaA, 2.);
59  BOOST_CHECK_EQUAL(abcList.get<TypeB>().vaB, 3);
60  BOOST_CHECK_EQUAL(abcList.get<TypeC>().vaC, '4');
61 }
62 
63 } // namespace Test
64 } // namespace Acts