Line data Source code
1 : #include "artdaq/DAQrate/detail/FragCounter.hh"
2 : #include "canvas/Utilities/Exception.h"
3 :
4 : using artdaq::detail::FragCounter;
5 :
6 : #define BOOST_TEST_MODULE FragCounter_t
7 : #include <boost/test/unit_test.hpp>
8 :
9 : BOOST_AUTO_TEST_SUITE(FragCounter_test)
10 :
11 2 : BOOST_AUTO_TEST_CASE(Construct)
12 : {
13 1 : FragCounter f1;
14 1 : }
15 :
16 2 : BOOST_AUTO_TEST_CASE(nSlots)
17 : {
18 1 : FragCounter f1;
19 1 : BOOST_REQUIRE_EQUAL(f1.nSlots(), 0ul);
20 1 : }
21 :
22 2 : BOOST_AUTO_TEST_CASE(Apply)
23 : {
24 1 : FragCounter f;
25 1 : f.incSlot(0);
26 1 : BOOST_REQUIRE_EQUAL(f.slotCount(0), 1ul);
27 1 : f.incSlot(1, 4);
28 1 : BOOST_REQUIRE_EQUAL(f.slotCount(1), 4ul);
29 1 : f.incSlot(1);
30 1 : BOOST_REQUIRE_EQUAL(f.slotCount(1), 5ul);
31 1 : f.incSlot(1, 2);
32 1 : BOOST_REQUIRE_EQUAL(f.slotCount(1), 7ul);
33 1 : BOOST_REQUIRE_EQUAL(f.slotCount(2), 0ul);
34 1 : BOOST_REQUIRE_EQUAL(f.count(), 8ul);
35 1 : }
36 :
37 2 : BOOST_AUTO_TEST_CASE(ApplyWithOffset)
38 : {
39 1 : FragCounter f;
40 1 : f.incSlot(4);
41 1 : BOOST_REQUIRE_EQUAL(f.slotCount(4), 1ul);
42 1 : f.incSlot(5, 4);
43 1 : BOOST_REQUIRE_EQUAL(f.slotCount(5), 4ul);
44 1 : f.incSlot(5);
45 1 : BOOST_REQUIRE_EQUAL(f.slotCount(5), 5ul);
46 1 : f.incSlot(5, 2);
47 1 : BOOST_REQUIRE_EQUAL(f.slotCount(5), 7ul);
48 1 : BOOST_REQUIRE_EQUAL(f.slotCount(6), 0ul);
49 1 : BOOST_REQUIRE_EQUAL(f.count(), 8ul);
50 1 : }
51 :
52 : BOOST_AUTO_TEST_SUITE_END()
|