• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <boost/core/lightweight_test.hpp>
8 #include <boost/histogram/axis/option.hpp>
9 #include <iostream>
10 
11 using namespace boost::histogram::axis;
12 
13 template <unsigned N, unsigned M>
operator ==(option::bitset<N>,option::bitset<M>)14 bool operator==(option::bitset<N>, option::bitset<M>) {
15   return N == M;
16 }
17 
18 template <unsigned N>
operator <<(std::ostream & os,option::bitset<N>)19 std::ostream& operator<<(std::ostream& os, option::bitset<N>) {
20   os << "underflow " << static_cast<bool>(N & option::underflow) << " "
21      << "overflow " << static_cast<bool>(N & option::overflow) << " "
22      << "circular " << static_cast<bool>(N & option::circular) << " "
23      << "growth " << static_cast<bool>(N & option::growth);
24   return os;
25 }
26 
main()27 int main() {
28   using namespace option;
29   using uoflow = decltype(underflow | overflow);
30   constexpr auto uoflow_growth = uoflow{} | growth;
31 
32   BOOST_TEST_EQ(uoflow::value, underflow | overflow);
33   BOOST_TEST_EQ(underflow | overflow, overflow | underflow);
34 
35   BOOST_TEST(underflow.test(underflow));
36   BOOST_TEST_NOT(underflow.test(overflow));
37   BOOST_TEST_NOT(underflow.test(underflow | overflow));
38   BOOST_TEST(uoflow::test(underflow));
39   BOOST_TEST(uoflow::test(overflow));
40   BOOST_TEST_NOT(uoflow::test(circular));
41   BOOST_TEST_NOT(uoflow::test(growth));
42   BOOST_TEST(uoflow_growth.test(underflow));
43   BOOST_TEST(uoflow_growth.test(overflow));
44   BOOST_TEST(uoflow_growth.test(growth));
45   BOOST_TEST_NOT(uoflow_growth.test(circular));
46 
47   BOOST_TEST_EQ(uoflow_growth & uoflow_growth, uoflow_growth);
48   BOOST_TEST_EQ(uoflow_growth & growth, growth);
49   BOOST_TEST_EQ(uoflow_growth & uoflow{}, uoflow::value);
50 
51   BOOST_TEST_EQ(uoflow_growth - growth, uoflow{});
52   BOOST_TEST_EQ(uoflow_growth - uoflow{}, growth);
53   BOOST_TEST_EQ(uoflow_growth - underflow, growth | overflow);
54 
55   return boost::report_errors();
56 }
57