Line data Source code
1 :
2 : /**
3 : * @file DetID_test.cxx DetID class Unit Tests
4 : *
5 : * This is part of the DUNE DAQ Application Framework, copyright 2022.
6 : * Licensing/copyright details are in the COPYING file that you should have
7 : * received with this code.
8 : */
9 :
10 : #include "detdataformats/DetID.hpp"
11 :
12 : #define BOOST_TEST_MODULE DetID_test
13 :
14 : #include "boost/test/unit_test.hpp"
15 :
16 : #include <string>
17 : #include <vector>
18 :
19 : using namespace dunedaq::detdataformats;
20 :
21 : BOOST_AUTO_TEST_SUITE(DetID_test)
22 :
23 2 : BOOST_AUTO_TEST_CASE(Comprehensive)
24 : {
25 :
26 1 : DetID detid = { DetID::Subdetector::kND_GAr };
27 :
28 1 : BOOST_REQUIRE(detid.is_in_valid_state());
29 :
30 1 : std::ostringstream ostr;
31 1 : ostr << detid;
32 1 : std::string output = ostr.str();
33 1 : BOOST_TEST_MESSAGE("Stream operator: " << output);
34 :
35 1 : BOOST_REQUIRE(!output.empty());
36 1 : auto pos = output.find("subdetector: ND_GAr");
37 1 : BOOST_REQUIRE(pos != std::string::npos);
38 :
39 1 : std::istringstream iss(ostr.str());
40 1 : DetID detid_from_stream;
41 1 : iss >> detid_from_stream;
42 1 : BOOST_REQUIRE_EQUAL(detid_from_stream.version, detid.version);
43 1 : BOOST_REQUIRE_EQUAL(detid_from_stream.subdetector, detid.subdetector);
44 :
45 1 : DetID detid_default;
46 1 : BOOST_REQUIRE(!detid_default.is_in_valid_state());
47 :
48 1 : }
49 :
50 : BOOST_AUTO_TEST_SUITE_END()
|