Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:05

0001 #define CATCH_CONFIG_MAIN
0002 #include "catch.hpp"
0003 
0004 #include "DQMOffline/Trigger/interface/EgHLTTrigCodes.h"
0005 
0006 TEST_CASE("EgHLTTrigCodes", "[EgHLTTrigCodes]") {
0007   std::vector<std::string> names = {{"Foo"}, {"Bar"}, {"Ish"}, {"Tar"}, {"ash"}};
0008   constexpr unsigned int kFoo = 0b1;
0009   constexpr unsigned int kBar = 0b10;
0010   constexpr unsigned int kIsh = 0b100;
0011   constexpr unsigned int kTar = 0b1000;
0012   constexpr unsigned int kash = 0b10000;
0013 
0014   using bits = egHLT::TrigCodes::TrigBitSet;
0015   SECTION("Sorted") {
0016     //This will sort to
0017     // ash, Bar, Foo Ish Tar
0018 
0019     std::unique_ptr<egHLT::TrigCodes> codes(egHLT::TrigCodes::makeCodes(names));
0020 
0021     REQUIRE(codes->getCode("ash") == bits(kash));
0022     REQUIRE(codes->getCode("Bar") == bits(kBar));
0023     REQUIRE(codes->getCode("Foo") == bits(kFoo));
0024     REQUIRE(codes->getCode("Ish") == bits(kIsh));
0025     REQUIRE(codes->getCode("Tar") == bits(kTar));
0026   }
0027 
0028   SECTION("Select multiple") {
0029     std::unique_ptr<egHLT::TrigCodes> codes(egHLT::TrigCodes::makeCodes(names));
0030     REQUIRE(codes->getCode("ash:Ish") == bits(kash | kIsh));
0031     REQUIRE(codes->getCode("Bar:Foo:Tar") == bits(kBar | kFoo | kTar));
0032     REQUIRE(codes->getCode("Tar:Foo:Bar") == bits(kTar | kFoo | kBar));
0033   }
0034 
0035   SECTION("Missing") {
0036     std::unique_ptr<egHLT::TrigCodes> codes(egHLT::TrigCodes::makeCodes(names));
0037     REQUIRE(codes->getCode("BAD") == bits());
0038     REQUIRE(codes->getCode("Tar:BAD:Bar") == bits(kTar | kBar));
0039 
0040     //no partial match
0041     REQUIRE(codes->getCode("as") == bits());
0042     REQUIRE(codes->getCode("ashton") == bits());
0043   }
0044 }