JayBeams  0.1
Another project to have fun coding.
ut_integer_range_binning.cpp
Go to the documentation of this file.
2 
3 #include <boost/test/unit_test.hpp>
4 
5 namespace {
6 
7 template <typename sample_type_t>
8 void check_constructor() {
9  BOOST_CHECK_THROW(
10  jb::integer_range_binning<sample_type_t>(10, 10), std::exception);
11  BOOST_CHECK_THROW(
12  jb::integer_range_binning<sample_type_t>(20, 10), std::exception);
13  BOOST_CHECK_NO_THROW(jb::integer_range_binning<sample_type_t>(1, 2));
14  BOOST_CHECK_NO_THROW(jb::integer_range_binning<sample_type_t>(1000, 2000));
15 }
16 
17 template <typename sample_type_t>
18 void check_basic() {
20  BOOST_CHECK_EQUAL(bin.histogram_min(), 0);
21  BOOST_CHECK_EQUAL(bin.histogram_max(), 1000);
22  BOOST_CHECK_EQUAL(
23  bin.theoretical_min(), std::numeric_limits<sample_type_t>::min());
24  BOOST_CHECK_EQUAL(
25  bin.theoretical_max(), std::numeric_limits<sample_type_t>::max());
26  BOOST_CHECK_EQUAL(bin.sample2bin(0), 0);
27  BOOST_CHECK_EQUAL(bin.sample2bin(5), 5);
28  BOOST_CHECK_EQUAL(bin.sample2bin(999), 999);
29  BOOST_CHECK_EQUAL(bin.bin2sample(0), 0);
30  BOOST_CHECK_EQUAL(bin.bin2sample(10), 10);
31 }
32 
33 } // anonymous namespace
34 
35 /**
36  * @test Verify the constructor in jb::integer_range_binning works as expected.
37  */
38 BOOST_AUTO_TEST_CASE(integer_range_binning_constructor_int) {
39  check_constructor<int>();
40 }
41 
42 /**
43  * @test Verify that jb::integer_range_binning works as expected.
44  */
45 BOOST_AUTO_TEST_CASE(integer_range_binning_basic_int) {
46  check_basic<int>();
47 }
48 
49 /**
50  * @test Verify the constructor in jb::integer_range_binning works as expected.
51  */
52 BOOST_AUTO_TEST_CASE(integer_range_binning_constructor_std_uint64) {
53  check_constructor<std::uint64_t>();
54 }
55 
56 /**
57  * @test Verify that jb::integer_range_binning works as expected.
58  */
59 BOOST_AUTO_TEST_CASE(integer_range_binning_basic_std_uint64) {
60  check_basic<std::uint64_t>();
61 }
BOOST_AUTO_TEST_CASE(integer_range_binning_constructor_int)
A histogram binning_strategy for integer numbers in a known range.