TestSiStripBaseDelay

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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestRunner.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>

#include "CondFormats/SiStripObjects/interface/SiStripBaseDelay.h"

class TestSiStripBaseDelay : public CppUnit::TestFixture {
public:
  TestSiStripBaseDelay() {}

  void setUp() {
    totDelays = 4;

    detId.push_back(0);
    detId.push_back(1);
    detId.push_back(2);
    detId.push_back(3);

    coarseDelay.push_back(0);
    coarseDelay.push_back(3);
    coarseDelay.push_back(1);
    coarseDelay.push_back(2);

    fineDelay = coarseDelay;

    for (unsigned int i = 0; i < totDelays; ++i) {
      delay.put(detId[i], coarseDelay[i], fineDelay[i]);
    }
  }

  void tearDown() {}

  void testDelays() {
    std::vector<SiStripBaseDelay::Delay> delays;
    delay.delays(delays);
    CPPUNIT_ASSERT(delays.size() == totDelays);
  }

  void testCoarseDelay() {
    for (unsigned int i = 0; i < totDelays; ++i) {
      CPPUNIT_ASSERT(delay.coarseDelay(i) == coarseDelay[i]);
    }
  }

  void testFineDelay() {
    for (unsigned int i = 0; i < totDelays; ++i) {
      CPPUNIT_ASSERT(delay.fineDelay(i) == fineDelay[i]);
    }
  }

  void testDelay() {
    for (unsigned int i = 0; i < totDelays; ++i) {
      CPPUNIT_ASSERT(delay.delay(i) == coarseDelay[i] * 25 + fineDelay[i] * (25 / 24.));
    }
  }

  CPPUNIT_TEST_SUITE(TestSiStripBaseDelay);
  CPPUNIT_TEST(testDelays);
  CPPUNIT_TEST(testCoarseDelay);
  CPPUNIT_TEST(testFineDelay);
  CPPUNIT_TEST(testDelay);
  CPPUNIT_TEST_SUITE_END();

  SiStripBaseDelay delay;
  unsigned int totDelays;
  std::vector<uint32_t> detId;
  std::vector<uint16_t> coarseDelay;
  std::vector<uint16_t> fineDelay;
};

CPPUNIT_TEST_SUITE_REGISTRATION(TestSiStripBaseDelay);