Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:30

0001 #include "catch.hpp"
0002 #include "CondCore/CondHDF5ESSource/plugins/IOVSyncValue.h"
0003 //can't link to plugin so must include source
0004 #include "CondCore/CondHDF5ESSource/plugins/IOVSyncValue.cc"
0005 
0006 using namespace cond::hdf5;
0007 
0008 TEST_CASE("test cond::hdf5::findMatchingFirst", "[findMatchingFirst]") {
0009   SECTION("empty IOVs") {
0010     std::vector<IOVSyncValue> iovs;
0011 
0012     auto itFind = findMatchingFirst(iovs, {1, 0});
0013     REQUIRE(itFind == iovs.end());
0014   }
0015 
0016   SECTION("First element") {
0017     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0018 
0019     auto itFind = findMatchingFirst(iovs, {1, 0});
0020     REQUIRE(itFind == iovs.begin());
0021   }
0022 
0023   SECTION("Second element") {
0024     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0025 
0026     auto itFind = findMatchingFirst(iovs, {10, 0});
0027     REQUIRE(itFind == iovs.begin() + 1);
0028   }
0029 
0030   SECTION("Last element") {
0031     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0032 
0033     auto itFind = findMatchingFirst(iovs, {20, 0});
0034     REQUIRE(itFind == iovs.begin() + 2);
0035   }
0036 
0037   SECTION("Between first and second element") {
0038     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0039 
0040     auto itFind = findMatchingFirst(iovs, {5, 0});
0041     REQUIRE(itFind == iovs.begin());
0042   }
0043 
0044   SECTION("Between second and third element") {
0045     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0046 
0047     auto itFind = findMatchingFirst(iovs, {15, 0});
0048     REQUIRE(itFind == iovs.begin() + 1);
0049   }
0050 
0051   SECTION("After last element") {
0052     std::vector<IOVSyncValue> iovs = {{1, 0}, {10, 0}, {20, 0}};
0053 
0054     auto itFind = findMatchingFirst(iovs, {25, 0});
0055     REQUIRE(itFind == iovs.begin() + 2);
0056   }
0057 
0058   SECTION("Before first element") {
0059     std::vector<IOVSyncValue> iovs = {{2, 0}, {10, 0}, {20, 0}};
0060 
0061     auto itFind = findMatchingFirst(iovs, {1, 0});
0062     REQUIRE(itFind == iovs.end());
0063   }
0064 }