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>(
32 1 : "oksconflibs:test/config/datahandlinglibs_DataMoveCallbackRegistry_test.data.xml");
33 1 : auto conf = confdb->get<dunedaq::appmodel::DataMoveCallbackConf>("id");
34 :
35 1 : auto registry = DataMoveCallbackRegistry::get();
36 :
37 : /**
38 : * @test No callback function registered with the given ID
39 : */
40 1 : BOOST_CHECK(registry->get_callback<int>(conf) == nullptr);
41 :
42 : /**
43 : * @test A registered callback function can be retrieved
44 : */
45 1 : registry->register_callback<int>(conf, [](int&&) {});
46 1 : BOOST_CHECK(registry->get_callback<int>(conf) != nullptr);
47 :
48 : /**
49 : * @test The registered callback function's parameter type and template argument must match
50 : */
51 1 : BOOST_CHECK_THROW(registry->get_callback<double>(conf), GenericConfigurationError);
52 1 : }
53 :
54 : BOOST_AUTO_TEST_SUITE_END()
|