testTimestamp

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
/*
 *  eventid_t.cppunit.cc
 *  CMSSW
 *
 *  Created by Chris Jones on 8/8/05.
 *
 */

#include "cppunit/extensions/HelperMacros.h"

#include "DataFormats/Provenance/interface/Timestamp.h"

using namespace edm;

class testTimestamp : public CppUnit::TestFixture {
  CPPUNIT_TEST_SUITE(testTimestamp);

  CPPUNIT_TEST(constructTest);
  CPPUNIT_TEST(comparisonTest);

  CPPUNIT_TEST_SUITE_END();

public:
  void setUp() {}
  void tearDown() {}

  void constructTest();
  void comparisonTest();
};

///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(testTimestamp);

void testTimestamp::constructTest() {
  const TimeValue_t t = 2;

  Timestamp temp(t);

  CPPUNIT_ASSERT(temp.value() == t);

  CPPUNIT_ASSERT(Timestamp::invalidTimestamp() < Timestamp::beginOfTime());
  CPPUNIT_ASSERT(Timestamp::beginOfTime() < Timestamp::endOfTime());
}

void testTimestamp::comparisonTest() {
  const Timestamp small(1);
  const Timestamp med(2);

  CPPUNIT_ASSERT(small < med);
  CPPUNIT_ASSERT(small <= med);
  CPPUNIT_ASSERT(!(small == med));
  CPPUNIT_ASSERT(small != med);
  CPPUNIT_ASSERT(!(small > med));
  CPPUNIT_ASSERT(!(small >= med));
}