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 : #include "serialization/Serialization.hpp"
16 :
17 : #include "boost/test/unit_test.hpp"
18 :
19 : using namespace dunedaq::datahandlinglibs;
20 :
21 : DUNE_DAQ_TYPESTRING(int, "int");
22 : DUNE_DAQ_TYPESTRING(double, "double");
23 :
24 : BOOST_AUTO_TEST_SUITE(datahandlinglibs_DataMoveCallbackRegistry_test)
25 :
26 : /**
27 : * @brief Tests for DataMoveCallbackRegistry singleton
28 : */
29 2 : BOOST_AUTO_TEST_CASE(DataMoveCallbackRegistry_get_callback)
30 : {
31 1 : auto confdb = std::make_shared<dunedaq::conffwk::Configuration>("oksconflibs:test/config/datahandlinglibs_DataMoveCallbackRegistry_test.data.xml");
32 1 : auto conf = confdb->get<dunedaq::appmodel::DataMoveCallbackConf>("id");
33 :
34 1 : auto registry = DataMoveCallbackRegistry::get();
35 :
36 : /**
37 : * @test No callback function registered with the given ID
38 : */
39 1 : BOOST_CHECK(registry->get_callback<int>(conf) == nullptr);
40 :
41 : /**
42 : * @test A registered callback function can be retrieved
43 : */
44 1 : registry->register_callback<int>(conf, [](int&&) {});
45 1 : BOOST_CHECK(registry->get_callback<int>(conf) != nullptr);
46 :
47 : /**
48 : * @test The registered callback function's parameter type and template argument must match
49 : */
50 1 : BOOST_CHECK_THROW(registry->get_callback<double>(conf), GenericConfigurationError);
51 1 : }
52 :
53 : BOOST_AUTO_TEST_SUITE_END()
|