Analysis Software
Documentation for sPHENIX simulation 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 #include <tuple>
16 #include <type_traits>
17 
18 namespace bdata = boost::unit_test::data;
19 namespace tt = boost::test_tools;
20 
21 namespace Acts {
22 
23 namespace Test {
24 
25 // This tests the implementation of the ActionList
26 // and the standard aborters
27 BOOST_AUTO_TEST_CASE(Extendable_) {
28  struct TypeA {
29  double vaA = 0.;
30  };
31 
32  struct TypeB {
33  int vaB = 0;
34  };
35 
36  struct TypeC {
37  char vaC = '0';
38  };
39 
40  // Test the empty list
41  detail::Extendable<> nullist{};
42  (void)nullist;
43  BOOST_CHECK_EQUAL(std::tuple_size<std::tuple<>>::value, 0u);
44 
46  auto& a0_object = alist.get<TypeA>();
47  a0_object.vaA = 1.;
48  BOOST_CHECK_EQUAL(alist.get<TypeA>().vaA, 1.);
49 
51  auto& a1_object = ablist.get<TypeA>();
52  a1_object.vaA = 2.;
53  auto& b1_object = ablist.get<TypeB>();
54  b1_object.vaB = 3;
55  BOOST_CHECK_EQUAL(ablist.get<TypeA>().vaA, 2.);
56  BOOST_CHECK_EQUAL(ablist.get<TypeB>().vaB, 3);
57 
58  TypeC c;
59  c.vaC = '4';
60  detail::Extendable<TypeA, TypeB, TypeC> abcList = ablist.append<TypeC>(c);
61  BOOST_CHECK_EQUAL(abcList.get<TypeA>().vaA, 2.);
62  BOOST_CHECK_EQUAL(abcList.get<TypeB>().vaB, 3);
63  BOOST_CHECK_EQUAL(abcList.get<TypeC>().vaC, '4');
64 }
65 
66 } // namespace Test
67 } // namespace Acts