Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / histogram / test / detail_linearize_test.cpp
1 // Copyright 2015-2017 Hans Dembinski
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <boost/core/lightweight_test.hpp>
8 #include <boost/core/lightweight_test_trait.hpp>
9 #include <boost/histogram/axis/integer.hpp>
10 #include <boost/histogram/axis/variant.hpp>
11 #include <boost/histogram/detail/linearize.hpp>
12 #include <tuple>
13 #include <utility>
14 #include <vector>
15 #include "std_ostream.hpp"
16
17 using namespace boost::histogram;
18
19 int main() {
20   {
21     struct growing {
22       auto update(int) { return std::make_pair(0, 0); }
23     };
24     using T = growing;
25     using I = axis::integer<>;
26
27     using A = std::tuple<I, T>;
28     using B = std::vector<T>;
29     using C = std::vector<axis::variant<I, T>>;
30     using D = std::tuple<I>;
31     using E = std::vector<I>;
32     using F = std::vector<axis::variant<I>>;
33
34     BOOST_TEST_TRAIT_TRUE((detail::has_growing_axis<A>));
35     BOOST_TEST_TRAIT_TRUE((detail::has_growing_axis<B>));
36     BOOST_TEST_TRAIT_TRUE((detail::has_growing_axis<C>));
37     BOOST_TEST_TRAIT_FALSE((detail::has_growing_axis<D>));
38     BOOST_TEST_TRAIT_FALSE((detail::has_growing_axis<E>));
39     BOOST_TEST_TRAIT_FALSE((detail::has_growing_axis<F>));
40   }
41
42   {
43     struct multidim {
44       auto index(const std::tuple<int>&) { return 0; }
45     };
46     using T = multidim;
47     using I = axis::integer<>;
48
49     using A = std::tuple<I, T>;
50     using B = std::vector<T>;
51     using C = std::vector<axis::variant<I, T>>;
52     using D = std::tuple<I>;
53     using E = std::vector<I>;
54     using F = std::vector<axis::variant<I>>;
55
56     BOOST_TEST_TRAIT_TRUE((detail::has_multidim_axis<A>));
57     BOOST_TEST_TRAIT_TRUE((detail::has_multidim_axis<B>));
58     BOOST_TEST_TRAIT_TRUE((detail::has_multidim_axis<C>));
59     BOOST_TEST_TRAIT_FALSE((detail::has_multidim_axis<D>));
60     BOOST_TEST_TRAIT_FALSE((detail::has_multidim_axis<E>));
61     BOOST_TEST_TRAIT_FALSE((detail::has_multidim_axis<F>));
62   }
63   return boost::report_errors();
64 }