1 // Copyright 2019 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/detail/argument_traits.hpp>
10 #include <boost/histogram/sample.hpp>
11 #include <boost/histogram/weight.hpp>
12
13 namespace dtl = boost::histogram::detail;
14
main()15 int main() {
16 using boost::histogram::sample;
17 using boost::histogram::weight;
18
19 // is_weight
20 {
21 struct A {};
22 using B = int;
23 BOOST_TEST_NOT(dtl::is_weight<A>::value);
24 BOOST_TEST_NOT(dtl::is_weight<B>::value);
25 BOOST_TEST_NOT(dtl::is_weight<decltype(sample(0))>::value);
26 BOOST_TEST(dtl::is_weight<decltype(weight(0))>::value);
27 }
28
29 // is_sample
30 {
31 struct A {};
32 using B = int;
33 BOOST_TEST_NOT(dtl::is_sample<A>::value);
34 BOOST_TEST_NOT(dtl::is_sample<B>::value);
35 BOOST_TEST_NOT(dtl::is_sample<decltype(weight(0))>::value);
36 BOOST_TEST(dtl::is_sample<decltype(sample(0))>::value);
37 BOOST_TEST(dtl::is_sample<decltype(sample(0, A{}))>::value);
38 }
39
40 using T1 = dtl::argument_traits<int>;
41 using E1 = dtl::argument_traits_holder<1, 0, -1, -1, std::tuple<>>;
42 BOOST_TEST_TRAIT_SAME(T1, E1);
43
44 using T2 = dtl::argument_traits<int, int>;
45 using E2 = dtl::argument_traits_holder<2, 0, -1, -1, std::tuple<>>;
46 BOOST_TEST_TRAIT_SAME(T2, E2);
47
48 using T3 = dtl::argument_traits<decltype(weight(0)), int, int>;
49 using E3 = dtl::argument_traits_holder<2, 1, 0, -1, std::tuple<>>;
50 BOOST_TEST_TRAIT_SAME(T3, E3);
51
52 using T4 = dtl::argument_traits<decltype(weight(0)), int, int, decltype(sample(0))>;
53 using E4 = dtl::argument_traits_holder<2, 1, 0, 3, std::tuple<int>>;
54 BOOST_TEST_TRAIT_SAME(T4, E4);
55
56 using T5 = dtl::argument_traits<int, decltype(sample(0, 0.0))>;
57 using E5 = dtl::argument_traits_holder<1, 0, -1, 1, std::tuple<int, double>>;
58 BOOST_TEST_TRAIT_SAME(T5, E5);
59
60 return boost::report_errors();
61 }
62