Line data Source code
1 : /**
2 : * @file TRMonRequest_test.cxx TRMonRequest class Unit Tests
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 : #include "dfmessages/TRMonRequest.hpp"
10 :
11 : /**
12 : * @brief Name of this test module
13 : */
14 : #define BOOST_TEST_MODULE TRMonRequest_test // NOLINT
15 :
16 : #include "TRACE/trace.h"
17 : #include "boost/test/unit_test.hpp"
18 :
19 : using namespace dunedaq::dfmessages;
20 :
21 : BOOST_AUTO_TEST_SUITE(TRMonRequest_test)
22 :
23 : /**
24 : * @brief Check that TRMonRequests have appropriate Copy/Move semantics
25 : */
26 2 : BOOST_AUTO_TEST_CASE(CopyAndMoveSemantics)
27 : {
28 1 : BOOST_REQUIRE(std::is_copy_constructible_v<TRMonRequest>);
29 1 : BOOST_REQUIRE(std::is_copy_assignable_v<TRMonRequest>);
30 1 : BOOST_REQUIRE(std::is_move_constructible_v<TRMonRequest>);
31 1 : BOOST_REQUIRE(std::is_move_assignable_v<TRMonRequest>);
32 1 : }
33 :
34 2 : BOOST_AUTO_TEST_CASE(SerDes_MsgPack)
35 : {
36 :
37 1 : TRMonRequest dr;
38 1 : dr.request_number = 1;
39 1 : dr.trigger_type_mask = 2;
40 1 : dr.run_number = 3;
41 1 : dr.data_destination = "test";
42 :
43 1 : auto bytes = dunedaq::serialization::serialize(dr, dunedaq::serialization::kMsgPack);
44 3 : TLOG(TLVL_INFO) << "MsgPack message size: " << bytes.size() << " bytes";
45 1 : TRMonRequest dr_deserialized = dunedaq::serialization::deserialize<TRMonRequest>(bytes);
46 :
47 1 : BOOST_REQUIRE_EQUAL(dr.request_number, dr_deserialized.request_number);
48 1 : BOOST_REQUIRE_EQUAL(dr.trigger_type_mask, dr_deserialized.trigger_type_mask);
49 1 : BOOST_REQUIRE_EQUAL(dr.run_number, dr_deserialized.run_number);
50 1 : BOOST_REQUIRE_EQUAL(dr.data_destination, dr_deserialized.data_destination);
51 1 : }
52 : BOOST_AUTO_TEST_SUITE_END()
|