Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TupleIndexOfTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TupleIndexOfTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 
12 
13 #include <tuple>
14 
15 namespace ActsFatras {
16 namespace detail {
17 template <class T, class Tuple>
18 struct TupleIndexOf;
19 } // namespace detail
20 } // namespace ActsFatras
21 
22 using ActsFatras::detail::TupleIndexOf;
23 
24 BOOST_AUTO_TEST_SUITE(FatrasTupleIndexOf)
25 
27  using T = std::tuple<int, double, float>;
28 
29  BOOST_CHECK_EQUAL((TupleIndexOf<int, T>::value), 0u);
30  BOOST_CHECK_EQUAL((TupleIndexOf<double, T>::value), 1u);
31  BOOST_CHECK_EQUAL((TupleIndexOf<float, T>::value), 2u);
32 }
33 
34 BOOST_AUTO_TEST_CASE(Duplicates) {
35  using T = std::tuple<double, int, double>;
36 
37  // should return the first matching type
38  BOOST_CHECK_EQUAL((TupleIndexOf<double, T>::value), 0u);
39  BOOST_CHECK_EQUAL((TupleIndexOf<int, T>::value), 1u);
40 }
41 
42 BOOST_AUTO_TEST_SUITE_END()