Line data Source code
1 : /**
2 : * @file datahandlinglibs_DataMoveCallbackRegistry_test.cxx Unit tests for DataMoveCallbackRegistry
3 : *
4 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : /**
10 : * @brief Name of this test module
11 : */
12 : #define BOOST_TEST_MODULE datahandlinglibs_DataMoveCallbackRegistry_test // NOLINT
13 :
14 : #include "datahandlinglibs/DataMoveCallbackRegistry.hpp"
15 :
16 : #include "boost/test/unit_test.hpp"
17 :
18 : using namespace dunedaq::datahandlinglibs;
19 :
20 : BOOST_AUTO_TEST_SUITE(datahandlinglibs_DataMoveCallbackRegistry_test)
21 :
22 : /**
23 : * @brief Tests for DataMoveCallbackRegistry singleton
24 : */
25 2 : BOOST_AUTO_TEST_CASE(DataMoveCallbackRegistry_get_callback)
26 : {
27 1 : auto registry = DataMoveCallbackRegistry::get();
28 :
29 : /**
30 : * @test No callback function registered with the given ID
31 : */
32 1 : BOOST_CHECK(registry->get_callback<int>("id") == nullptr);
33 :
34 : /**
35 : * @test A registered callback function can be retrieved
36 : */
37 1 : registry->register_callback<int>("id", [](int&&) {});
38 1 : BOOST_CHECK(registry->get_callback<int>("id") != nullptr);
39 :
40 : /**
41 : * @test The registered callback function's parameter type and template argument must match
42 : */
43 3 : BOOST_CHECK_THROW(registry->get_callback<double>("id"), GenericConfigurationError);
44 1 : }
45 :
46 : BOOST_AUTO_TEST_SUITE_END()
|