1 // Copyright 2018 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 <array>
8 #include <boost/core/lightweight_test.hpp>
9 #include <boost/histogram/accumulators/weighted_mean.hpp>
10 #include <boost/histogram/algorithm/empty.hpp>
11 #include <boost/histogram/axis/integer.hpp>
12 #include <unordered_map>
13 #include <vector>
14 #include "throw_exception.hpp"
15 #include "utility_histogram.hpp"
16
17 using namespace boost::histogram;
18 using boost::histogram::algorithm::empty;
19
20 template <typename Tag>
run_tests()21 void run_tests() {
22 auto ax = axis::integer<>(0, 10);
23
24 {
25 auto h = make(Tag(), ax);
26 BOOST_TEST(empty(h, coverage::all));
27 BOOST_TEST(empty(h, coverage::inner));
28 for (int i = -1; i < 11; ++i) {
29 h.reset();
30 h(i);
31 BOOST_TEST(!empty(h, coverage::all));
32 if (i == -1 || i == 10) {
33 BOOST_TEST(empty(h, coverage::inner));
34 } else {
35 BOOST_TEST(!empty(h, coverage::inner));
36 }
37 }
38 }
39
40 {
41 auto h = make_s(Tag(), std::vector<accumulators::weighted_mean<>>(),
42 axis::integer<>(0, 10), axis::integer<>(0, 10));
43 BOOST_TEST(empty(h, coverage::all));
44 BOOST_TEST(empty(h, coverage::inner));
45 h.reset();
46 h(weight(2), -2, -4, sample(3));
47 BOOST_TEST(!empty(h, coverage::all));
48 BOOST_TEST(empty(h, coverage::inner));
49 h.reset();
50 h(weight(1), -4, 2, sample(2));
51 BOOST_TEST(!empty(h, coverage::all));
52 BOOST_TEST(empty(h, coverage::inner));
53 h.reset();
54 h(weight(3), 3, 5, sample(1));
55 BOOST_TEST(!empty(h, coverage::all));
56 BOOST_TEST(!empty(h, coverage::inner));
57 }
58 }
59
main()60 int main() {
61 run_tests<static_tag>();
62 run_tests<dynamic_tag>();
63
64 return boost::report_errors();
65 }
66