• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-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/accumulators/count.hpp>
9 #include <boost/histogram/accumulators/ostream.hpp>
10 #include "throw_exception.hpp"
11 #include "utility_str.hpp"
12 
13 using namespace boost::histogram;
14 using namespace std::literals;
15 
main()16 int main() {
17   using c_t = accumulators::count<double>;
18 
19   c_t c;
20   ++c;
21   BOOST_TEST_EQ(c.value(), 1);
22   BOOST_TEST_EQ(str(c), "1"s);
23   BOOST_TEST_EQ(str(c, 2, false), " 1"s);
24   BOOST_TEST_EQ(str(c, 2, true), "1 "s);
25 
26   c += 2;
27   BOOST_TEST_EQ(str(c), "3"s);
28 
29   BOOST_TEST_EQ(c, 3);
30   BOOST_TEST_NE(c, 2);
31 
32   c_t one(1), two(2), one_copy(1);
33   BOOST_TEST_LT(one, two);
34   BOOST_TEST_LE(one, two);
35   BOOST_TEST_LE(one, one_copy);
36   BOOST_TEST_GT(two, one);
37   BOOST_TEST_GE(two, one);
38   BOOST_TEST_GE(one, one_copy);
39 
40   BOOST_TEST_EQ(c_t{} += c_t{}, c_t{});
41 
42   return boost::report_errors();
43 }
44