Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:19

0001 /*
0002  *  interval_t.cc
0003  *  EDMProto
0004  *
0005  *  Created by Chris Jones on 3/30/05.
0006  *  Changed by Viji Sundararajan on 29-Jun-05.
0007  *
0008  */
0009 
0010 #include "FWCore/Framework/interface/IOVSyncValue.h"
0011 #include "FWCore/Framework/interface/ValidityInterval.h"
0012 #include "cppunit/extensions/HelperMacros.h"
0013 
0014 using edm::IOVSyncValue;
0015 using edm::Timestamp;
0016 using edm::ValidityInterval;
0017 
0018 class testinterval : public CppUnit::TestFixture {
0019   CPPUNIT_TEST_SUITE(testinterval);
0020 
0021   CPPUNIT_TEST(comparisonTest);
0022   CPPUNIT_TEST(timestampAssignmentTest);
0023   CPPUNIT_TEST(intervalAssignmentTest);
0024 
0025   CPPUNIT_TEST_SUITE_END();
0026 
0027 public:
0028   void setUp() {}
0029   void tearDown() {}
0030 
0031   void comparisonTest();
0032   void timestampAssignmentTest();
0033   void intervalAssignmentTest();
0034 };
0035 
0036 ///registration of the test so that the runner can find it
0037 CPPUNIT_TEST_SUITE_REGISTRATION(testinterval);
0038 
0039 void testinterval::comparisonTest() {
0040   const IOVSyncValue invalid(IOVSyncValue::invalidIOVSyncValue());
0041 
0042   const Timestamp t_1(1);
0043   const IOVSyncValue one(t_1);
0044   const Timestamp t_2(2);
0045   const IOVSyncValue two(t_2);
0046 
0047   CPPUNIT_ASSERT(invalid == IOVSyncValue::invalidIOVSyncValue());
0048   CPPUNIT_ASSERT(one == IOVSyncValue(t_1));
0049 
0050   CPPUNIT_ASSERT(invalid != one);
0051 
0052   CPPUNIT_ASSERT(one < two);
0053   CPPUNIT_ASSERT(!(one > two));
0054   CPPUNIT_ASSERT(two > one);
0055   CPPUNIT_ASSERT(!(two < one));
0056 
0057   CPPUNIT_ASSERT(one != two);
0058   CPPUNIT_ASSERT(!(one == two));
0059 
0060   CPPUNIT_ASSERT(one <= two);
0061   CPPUNIT_ASSERT(one <= one);
0062   CPPUNIT_ASSERT(one >= one);
0063   CPPUNIT_ASSERT(!(one >= two));
0064 }
0065 
0066 void testinterval::timestampAssignmentTest() {
0067   const Timestamp t_1(1);
0068   const IOVSyncValue one(t_1);
0069 
0070   IOVSyncValue temp(IOVSyncValue::invalidIOVSyncValue());
0071   CPPUNIT_ASSERT(temp != one);
0072   temp = one;
0073   CPPUNIT_ASSERT(temp == one);
0074 }
0075 
0076 void testinterval::intervalAssignmentTest() {
0077   ValidityInterval temp;
0078   const Timestamp t_1(1);
0079   const IOVSyncValue s_1(t_1);
0080   const ValidityInterval oneAndTwo(s_1, IOVSyncValue(Timestamp(2)));
0081 
0082   CPPUNIT_ASSERT(temp != oneAndTwo);
0083   CPPUNIT_ASSERT(!(temp == oneAndTwo));
0084 
0085   temp = oneAndTwo;
0086   CPPUNIT_ASSERT(temp == oneAndTwo);
0087 }