ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FittableTypeTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FittableTypeTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 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/unit_test.hpp>
10 
11 #include <cmath>
12 #include <memory>
13 #include <random>
14 #include <variant>
15 
20 
22 
23 #include <boost/hana/equal.hpp>
24 #include <boost/hana/integral_constant.hpp>
25 #include <boost/hana/tuple.hpp>
26 #include <boost/hana/type.hpp>
27 
28 namespace hana = boost::hana;
29 using namespace hana::literals;
30 
31 #define _T(...) hana::tuple_c<size_t, __VA_ARGS__>
32 
33 namespace Acts {
34 namespace Test {
35 
36 BOOST_AUTO_TEST_CASE(index_combination_generation_test) {
37  {
38  constexpr auto result = detail::unique_ordered_sublists<1>();
39  constexpr auto expected = hana::make_tuple(_T(0));
40  static_assert(result == expected, "At size 1 is not equal");
41  }
42  {
43  constexpr auto result = detail::unique_ordered_sublists<2>();
44  constexpr auto expected = hana::make_tuple(_T(0), _T(1), _T(0, 1));
45  static_assert(result == expected, "At size 2 is not equal");
46  }
47  {
48  constexpr auto result = detail::unique_ordered_sublists<3>();
49  constexpr auto expected = hana::make_tuple(_T(0), _T(1), _T(0, 1), _T(2),
50  _T(0, 2), _T(1, 2), _T(0, 1, 2));
51  static_assert(result == expected, "At size 3 is not equal");
52  }
53  {
54  constexpr auto result = detail::unique_ordered_sublists<4>();
55  constexpr auto expected =
56  hana::make_tuple(_T(0), _T(1), _T(0, 1), _T(2), _T(0, 2), _T(1, 2),
57  _T(0, 1, 2), _T(3), _T(0, 3), _T(1, 3), _T(0, 1, 3),
58  _T(2, 3), _T(0, 2, 3), _T(1, 2, 3), _T(0, 1, 2, 3));
59  static_assert(result == expected, "At size 4 is not equal");
60  }
61  {
62  constexpr auto result = detail::unique_ordered_sublists<5>();
63  constexpr auto expected = hana::make_tuple(
64  _T(0), _T(1), _T(0, 1), _T(2), _T(0, 2), _T(1, 2), _T(0, 1, 2), _T(3),
65  _T(0, 3), _T(1, 3), _T(0, 1, 3), _T(2, 3), _T(0, 2, 3), _T(1, 2, 3),
66  _T(0, 1, 2, 3), _T(4), _T(0, 4), _T(1, 4), _T(0, 1, 4), _T(2, 4),
67  _T(0, 2, 4), _T(1, 2, 4), _T(0, 1, 2, 4), _T(3, 4), _T(0, 3, 4),
68  _T(1, 3, 4), _T(0, 1, 3, 4), _T(2, 3, 4), _T(0, 2, 3, 4),
69  _T(1, 2, 3, 4), _T(0, 1, 2, 3, 4));
70  static_assert(result == expected, "At size 5 is not equal");
71  }
72 }
73 
74 using par_t = ParID_t;
76 
77 template <par_t... pars>
78 struct meas_factory {
79  using type = Measurement<SourceLink, pars...>;
80 };
81 
82 constexpr par_t operator"" _p(unsigned long long i) {
83  return par_t(i);
84 }
85 
86 BOOST_AUTO_TEST_CASE(variant_measurement_generation_test) {
87  {
88  using actual = detail::type_generator_t<meas_factory, 1>;
89  using expected = std::variant<Measurement<SourceLink, 0_p>>;
91  "Variant is not identical");
92  }
93  {
94  using actual = detail::type_generator_t<meas_factory, 2>;
95  using expected =
96  std::variant<Measurement<SourceLink, 0_p>, Measurement<SourceLink, 1_p>,
99  "Variant is not identical");
100  }
101  {
102  using actual = detail::type_generator_t<meas_factory, 3>;
103  using expected = std::variant<
109  "Variant is not identical");
110  }
111  {
112  using actual = detail::type_generator_t<meas_factory, 4>;
113  using expected = std::variant<
125  "Variant is not identical");
126  }
127  {
128  using actual = detail::type_generator_t<meas_factory, 5>;
129  using expected = std::variant<
156  "Variant is not identical");
157  }
158 }
159 } // namespace Test
160 } // namespace Acts