Line data Source code
1 : #include "artdaq/DAQrate/detail/MergeParameterSets.hh"
2 :
3 : #define BOOST_TEST_MODULE MergeParameterSets_t
4 : #include <boost/test/unit_test.hpp>
5 :
6 : BOOST_AUTO_TEST_SUITE(MergeParameterSets_test)
7 :
8 2 : BOOST_AUTO_TEST_CASE(Simple)
9 : {
10 1 : fhicl::ParameterSet p1, p2;
11 3 : p1.put<std::string>("test_str", "test1");
12 3 : p1.put<int>("test_int", 1);
13 :
14 3 : p2.put<std::string>("another_str", "test2");
15 2 : p2.put<bool>("test_bool", false);
16 :
17 1 : auto p3 = artdaq::merge(p1, p2);
18 :
19 3 : BOOST_REQUIRE(p3.has_key("test_str"));
20 3 : BOOST_REQUIRE(p3.has_key("another_str"));
21 :
22 3 : BOOST_REQUIRE_EQUAL(p3.get<int>("test_int"), 1);
23 3 : BOOST_REQUIRE_EQUAL(p3.get<bool>("test_bool"), false);
24 1 : }
25 :
26 2 : BOOST_AUTO_TEST_CASE(Overwrite)
27 : {
28 1 : fhicl::ParameterSet p1, p2;
29 3 : p1.put<std::string>("test_str", "test1");
30 3 : p1.put<int>("test_int", 1);
31 :
32 3 : p2.put<std::string>("test_str", "test2");
33 2 : p2.put<bool>("test_bool", false);
34 :
35 1 : auto p3 = artdaq::merge(p1, p2);
36 :
37 3 : BOOST_REQUIRE(p3.has_key("test_str"));
38 :
39 3 : BOOST_REQUIRE_EQUAL(p3.get<std::string>("test_str"), "test2");
40 3 : BOOST_REQUIRE_EQUAL(p3.get<int>("test_int"), 1);
41 3 : BOOST_REQUIRE_EQUAL(p3.get<bool>("test_bool"), false);
42 1 : }
43 :
44 : BOOST_AUTO_TEST_SUITE_END()
|