Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:29

0001 #include "catch.hpp"
0002 
0003 #include "DataFormats/Provenance/interface/CompactHash.h"
0004 #include "FWCore/Utilities/interface/Digest.h"
0005 
0006 namespace {
0007   using TestHash = edm::CompactHash<100>;
0008 }
0009 
0010 TEST_CASE("CompactHash", "[CompactHash]") {
0011   SECTION("Default construction is invalid") { REQUIRE(TestHash{}.isValid() == false); }
0012 
0013   SECTION("Basic operations") {
0014     cms::Digest d("foo");
0015     auto result = d.digest().bytes;
0016 
0017     TestHash id{result};
0018     REQUIRE(id.isValid() == true);
0019     REQUIRE(id.compactForm() == result);
0020 
0021     TestHash id2 = id;
0022     REQUIRE(id2.isValid() == true);
0023     REQUIRE(id2.compactForm() == result);
0024 
0025     cms::Digest b("bar");
0026     auto diffResult = b.digest().bytes;
0027     REQUIRE(id2 == TestHash{result});
0028     REQUIRE(id2 != TestHash{diffResult});
0029 
0030     REQUIRE(id2 > TestHash{diffResult});
0031     REQUIRE(TestHash{diffResult} < id2);
0032 
0033     REQUIRE(not(id2 < id2));
0034   }
0035 }