Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:41

0001 #include <cppunit/TestFixture.h>
0002 #include <cppunit/extensions/HelperMacros.h>
0003 #include <cppunit/TestResult.h>
0004 #include <cppunit/TestRunner.h>
0005 #include <cppunit/ui/text/TestRunner.h>
0006 #include <cppunit/TestResultCollector.h>
0007 #include <cppunit/TextTestProgressListener.h>
0008 #include <cppunit/CompilerOutputter.h>
0009 
0010 #include "CondFormats/SiStripObjects/interface/SiStripBaseDelay.h"
0011 
0012 class TestSiStripBaseDelay : public CppUnit::TestFixture {
0013 public:
0014   TestSiStripBaseDelay() {}
0015 
0016   void setUp() {
0017     totDelays = 4;
0018 
0019     detId.push_back(0);
0020     detId.push_back(1);
0021     detId.push_back(2);
0022     detId.push_back(3);
0023 
0024     coarseDelay.push_back(0);
0025     coarseDelay.push_back(3);
0026     coarseDelay.push_back(1);
0027     coarseDelay.push_back(2);
0028 
0029     fineDelay = coarseDelay;
0030 
0031     for (unsigned int i = 0; i < totDelays; ++i) {
0032       delay.put(detId[i], coarseDelay[i], fineDelay[i]);
0033     }
0034   }
0035 
0036   void tearDown() {}
0037 
0038   void testDelays() {
0039     std::vector<SiStripBaseDelay::Delay> delays;
0040     delay.delays(delays);
0041     CPPUNIT_ASSERT(delays.size() == totDelays);
0042   }
0043 
0044   void testCoarseDelay() {
0045     for (unsigned int i = 0; i < totDelays; ++i) {
0046       CPPUNIT_ASSERT(delay.coarseDelay(i) == coarseDelay[i]);
0047     }
0048   }
0049 
0050   void testFineDelay() {
0051     for (unsigned int i = 0; i < totDelays; ++i) {
0052       CPPUNIT_ASSERT(delay.fineDelay(i) == fineDelay[i]);
0053     }
0054   }
0055 
0056   void testDelay() {
0057     for (unsigned int i = 0; i < totDelays; ++i) {
0058       CPPUNIT_ASSERT(delay.delay(i) == coarseDelay[i] * 25 + fineDelay[i] * (25 / 24.));
0059     }
0060   }
0061 
0062   CPPUNIT_TEST_SUITE(TestSiStripBaseDelay);
0063   CPPUNIT_TEST(testDelays);
0064   CPPUNIT_TEST(testCoarseDelay);
0065   CPPUNIT_TEST(testFineDelay);
0066   CPPUNIT_TEST(testDelay);
0067   CPPUNIT_TEST_SUITE_END();
0068 
0069   SiStripBaseDelay delay;
0070   unsigned int totDelays;
0071   std::vector<uint32_t> detId;
0072   std::vector<uint16_t> coarseDelay;
0073   std::vector<uint16_t> fineDelay;
0074 };
0075 
0076 CPPUNIT_TEST_SUITE_REGISTRATION(TestSiStripBaseDelay);