File indexing completed on 2024-04-06 12:12:27
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "cppunit/extensions/HelperMacros.h"
0010
0011 #include "FWCore/Framework/interface/IOVSyncValue.h"
0012 #include "FWCore/Utilities/interface/Exception.h"
0013
0014 using namespace edm;
0015
0016 class testIOVSyncValue : public CppUnit::TestFixture {
0017 CPPUNIT_TEST_SUITE(testIOVSyncValue);
0018
0019 CPPUNIT_TEST(constructTest);
0020 CPPUNIT_TEST(constructTimeTest);
0021 CPPUNIT_TEST(comparisonTest);
0022 CPPUNIT_TEST(comparisonTimeTest);
0023 CPPUNIT_TEST(invalidComparisonTest);
0024
0025 CPPUNIT_TEST_SUITE_END();
0026
0027 public:
0028 void setUp() {}
0029 void tearDown() {}
0030
0031 void constructTest();
0032 void comparisonTest();
0033 void constructTimeTest();
0034 void comparisonTimeTest();
0035 void invalidComparisonTest();
0036 };
0037
0038
0039 CPPUNIT_TEST_SUITE_REGISTRATION(testIOVSyncValue);
0040
0041 void testIOVSyncValue::constructTest() {
0042 {
0043 const EventID t(2, 0, 0);
0044
0045 IOVSyncValue temp(t);
0046
0047 CPPUNIT_ASSERT(temp.eventID() == t);
0048
0049 CPPUNIT_ASSERT(IOVSyncValue::invalidIOVSyncValue() != temp);
0050 CPPUNIT_ASSERT(!(IOVSyncValue::invalidIOVSyncValue() == temp));
0051 CPPUNIT_ASSERT(IOVSyncValue::beginOfTime() < temp);
0052 CPPUNIT_ASSERT(IOVSyncValue::endOfTime() > temp);
0053 }
0054 CPPUNIT_ASSERT(IOVSyncValue::invalidIOVSyncValue() < IOVSyncValue::beginOfTime());
0055 CPPUNIT_ASSERT(IOVSyncValue::beginOfTime() < IOVSyncValue::endOfTime());
0056
0057 {
0058 const EventID t(2, 3, 1);
0059
0060 IOVSyncValue temp(t);
0061
0062 CPPUNIT_ASSERT(temp.eventID() == t);
0063 CPPUNIT_ASSERT(temp.luminosityBlockNumber() == 3);
0064
0065 CPPUNIT_ASSERT(IOVSyncValue::invalidIOVSyncValue() != temp);
0066 CPPUNIT_ASSERT(!(IOVSyncValue::invalidIOVSyncValue() == temp));
0067 CPPUNIT_ASSERT(IOVSyncValue::beginOfTime() < temp);
0068 CPPUNIT_ASSERT(IOVSyncValue::endOfTime() > temp);
0069 }
0070 }
0071
0072 void testIOVSyncValue::constructTimeTest() {
0073 const Timestamp t(2);
0074
0075 IOVSyncValue temp(t);
0076
0077 CPPUNIT_ASSERT(temp.time() == t);
0078
0079 CPPUNIT_ASSERT(IOVSyncValue::invalidIOVSyncValue() < IOVSyncValue::beginOfTime());
0080 CPPUNIT_ASSERT(IOVSyncValue::beginOfTime() < IOVSyncValue::endOfTime());
0081
0082 CPPUNIT_ASSERT(IOVSyncValue::invalidIOVSyncValue() != temp);
0083 CPPUNIT_ASSERT(!(IOVSyncValue::invalidIOVSyncValue() == temp));
0084 CPPUNIT_ASSERT(IOVSyncValue::beginOfTime() < temp);
0085 CPPUNIT_ASSERT(IOVSyncValue::endOfTime() > temp);
0086 }
0087
0088 void testIOVSyncValue::comparisonTest() {
0089 {
0090 const IOVSyncValue small(EventID(1, 1, 1));
0091 const IOVSyncValue med(EventID(2, 1, 2));
0092
0093 CPPUNIT_ASSERT(small.comparable(med));
0094 CPPUNIT_ASSERT(small < med);
0095 CPPUNIT_ASSERT(small <= med);
0096 CPPUNIT_ASSERT(!(small == med));
0097 CPPUNIT_ASSERT(small != med);
0098 CPPUNIT_ASSERT(!(small > med));
0099 CPPUNIT_ASSERT(!(small >= med));
0100 }
0101 {
0102 const IOVSyncValue small(EventID(2, 1, 1));
0103 const IOVSyncValue med(EventID(2, 1, 2));
0104
0105 CPPUNIT_ASSERT(small < med);
0106 CPPUNIT_ASSERT(small <= med);
0107 CPPUNIT_ASSERT(!(small == med));
0108 CPPUNIT_ASSERT(small != med);
0109 CPPUNIT_ASSERT(!(small > med));
0110 CPPUNIT_ASSERT(!(small >= med));
0111 }
0112 {
0113 const IOVSyncValue small(EventID(2, 1, 2));
0114 const IOVSyncValue med(EventID(3, 1, 1));
0115
0116 CPPUNIT_ASSERT(small < med);
0117 CPPUNIT_ASSERT(small <= med);
0118 CPPUNIT_ASSERT(!(small == med));
0119 CPPUNIT_ASSERT(small != med);
0120 CPPUNIT_ASSERT(!(small > med));
0121 CPPUNIT_ASSERT(!(small >= med));
0122 }
0123 {
0124 const IOVSyncValue small(EventID(2, 2, 1));
0125 const IOVSyncValue med(EventID(2, 2, 2));
0126
0127 CPPUNIT_ASSERT(small < med);
0128 CPPUNIT_ASSERT(small <= med);
0129 CPPUNIT_ASSERT(!(small == med));
0130 CPPUNIT_ASSERT(small != med);
0131 CPPUNIT_ASSERT(!(small > med));
0132 CPPUNIT_ASSERT(!(small >= med));
0133 }
0134 {
0135 const IOVSyncValue small(EventID(2, 1, 3));
0136 const IOVSyncValue med(EventID(2, 2, 2));
0137
0138 CPPUNIT_ASSERT(small < med);
0139 CPPUNIT_ASSERT(small <= med);
0140 CPPUNIT_ASSERT(!(small == med));
0141 CPPUNIT_ASSERT(small != med);
0142 CPPUNIT_ASSERT(!(small > med));
0143 CPPUNIT_ASSERT(!(small >= med));
0144 }
0145 }
0146
0147 void testIOVSyncValue::comparisonTimeTest() {
0148 const IOVSyncValue small(Timestamp(1));
0149 const IOVSyncValue med(Timestamp(2));
0150
0151 CPPUNIT_ASSERT(small.comparable(med));
0152 CPPUNIT_ASSERT(small < med);
0153 CPPUNIT_ASSERT(small <= med);
0154 CPPUNIT_ASSERT(!(small == med));
0155 CPPUNIT_ASSERT(small != med);
0156 CPPUNIT_ASSERT(!(small > med));
0157 CPPUNIT_ASSERT(!(small >= med));
0158 }
0159
0160 void testIOVSyncValue::invalidComparisonTest() {
0161 const IOVSyncValue timeBased(Timestamp(1));
0162 const IOVSyncValue eventBased(EventID(3, 2, 1));
0163
0164 CPPUNIT_ASSERT(!timeBased.comparable(eventBased));
0165 CPPUNIT_ASSERT(!eventBased.comparable(timeBased));
0166 CPPUNIT_ASSERT_THROW([&]() { return timeBased < eventBased; }(), cms::Exception);
0167 CPPUNIT_ASSERT_THROW([&]() { return timeBased <= eventBased; }(), cms::Exception);
0168 CPPUNIT_ASSERT(!(timeBased == eventBased));
0169 CPPUNIT_ASSERT(timeBased != eventBased);
0170 CPPUNIT_ASSERT_THROW([&]() { return timeBased > eventBased; }(), cms::Exception);
0171 CPPUNIT_ASSERT_THROW([&]() { return timeBased >= eventBased; }(), cms::Exception);
0172 }