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 
16 
17 #include <cmath>
18 #include <memory>
19 #include <random>
20 #include <variant>
21 
22 #include <boost/hana/equal.hpp>
23 #include <boost/hana/integral_constant.hpp>
24 #include <boost/hana/tuple.hpp>
25 #include <boost/hana/type.hpp>
26 
27 namespace hana = boost::hana;
28 using namespace hana::literals;
29 
30 #define _T(...) hana::tuple_c<size_t, __VA_ARGS__>
31 
32 namespace Acts {
33 namespace Test {
34 
35 BOOST_AUTO_TEST_CASE(index_combination_generation_test) {
36  {
37  constexpr auto result = detail::unique_ordered_sublists<1>();
38  constexpr auto expected = hana::make_tuple(_T(0));
39  static_assert(result == expected, "At size 1 is not equal");
40  } // namespace Test
41  {
42  constexpr auto result = detail::unique_ordered_sublists<2>();
43  constexpr auto expected = hana::make_tuple(_T(0), _T(1), _T(0, 1));
44  static_assert(result == expected, "At size 2 is not equal");
45  }
46  {
47  constexpr auto result = detail::unique_ordered_sublists<3>();
48  constexpr auto expected = hana::make_tuple(_T(0), _T(1), _T(0, 1), _T(2),
49  _T(0, 2), _T(1, 2), _T(0, 1, 2));
50  static_assert(result == expected, "At size 3 is not equal");
51  }
52  {
53  constexpr auto result = detail::unique_ordered_sublists<4>();
54  constexpr auto expected =
55  hana::make_tuple(_T(0), _T(1), _T(0, 1), _T(2), _T(0, 2), _T(1, 2),
56  _T(0, 1, 2), _T(3), _T(0, 3), _T(1, 3), _T(0, 1, 3),
57  _T(2, 3), _T(0, 2, 3), _T(1, 2, 3), _T(0, 1, 2, 3));
58  static_assert(result == expected, "At size 4 is not equal");
59  }
60  {
61  constexpr auto result = detail::unique_ordered_sublists<5>();
62  constexpr auto expected = hana::make_tuple(
63  _T(0), _T(1), _T(0, 1), _T(2), _T(0, 2), _T(1, 2), _T(0, 1, 2), _T(3),
64  _T(0, 3), _T(1, 3), _T(0, 1, 3), _T(2, 3), _T(0, 2, 3), _T(1, 2, 3),
65  _T(0, 1, 2, 3), _T(4), _T(0, 4), _T(1, 4), _T(0, 1, 4), _T(2, 4),
66  _T(0, 2, 4), _T(1, 2, 4), _T(0, 1, 2, 4), _T(3, 4), _T(0, 3, 4),
67  _T(1, 3, 4), _T(0, 1, 3, 4), _T(2, 3, 4), _T(0, 2, 3, 4),
68  _T(1, 2, 3, 4), _T(0, 1, 2, 3, 4));
69  static_assert(result == expected, "At size 5 is not equal");
70  }
71 } // namespace Acts
72 
75 
76 template <par_t... pars>
77 struct meas_factory {
78  using type = Measurement<Source, par_t, pars...>;
79 };
80 
81 constexpr par_t operator"" _p(unsigned long long i) {
82  return par_t(i);
83 }
84 
85 BOOST_AUTO_TEST_CASE(variant_bound_measurement_generation_test) {
86  {
87  using actual = detail::type_generator_t<par_t, meas_factory>;
88  using expected = std::variant<
148  "Variant is not identical");
149  }
150 }
151 
153 
154 template <freePar_t... pars>
156  using type = Measurement<Source, freePar_t, pars...>;
157 };
158 
159 constexpr freePar_t operator"" _fp(unsigned long long i) {
160  return freePar_t(i);
161 }
162 
163 BOOST_AUTO_TEST_CASE(variant_free_measurement_generation_test) {
164  {
165  using actual = detail::type_generator_t<freePar_t, meas_factory2>;
166  using expected = std::variant<
293  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 3_fp, 4_fp, 5_fp,
294  6_fp>,
358  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 3_fp, 4_fp, 5_fp,
359  7_fp>,
391  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 3_fp, 4_fp, 6_fp,
392  7_fp>,
408  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 3_fp, 5_fp, 6_fp,
409  7_fp>,
417  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 4_fp, 5_fp, 6_fp,
418  7_fp>,
422  Measurement<Source, freePar_t, 0_fp, 1_fp, 3_fp, 4_fp, 5_fp, 6_fp,
423  7_fp>,
425  Measurement<Source, freePar_t, 0_fp, 2_fp, 3_fp, 4_fp, 5_fp, 6_fp,
426  7_fp>,
427  Measurement<Source, freePar_t, 1_fp, 2_fp, 3_fp, 4_fp, 5_fp, 6_fp,
428  7_fp>,
429  Measurement<Source, freePar_t, 0_fp, 1_fp, 2_fp, 3_fp, 4_fp, 5_fp, 6_fp,
430  7_fp>>;
432  "Variant is not identical");
433  }
434 }
435 } // namespace Test
436 } // namespace Acts