Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-04 05:18:25

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 class Complex {
0011 public:
0012   Complex(const double realInput, const double imgInput) : real(realInput), img(imgInput) {}
0013   Complex operator+(const Complex& number) {
0014     Complex temp(*this);
0015     temp.real += number.real;
0016     temp.img += number.img;
0017     return temp;
0018   }
0019   bool operator==(const Complex& number) const { return (real == number.real && img == number.img); }
0020 
0021   double real;
0022   double img;
0023 };
0024 
0025 class TestSiStripDCS : public CppUnit::TestFixture {
0026 public:
0027   TestSiStripDCS() {}
0028 
0029   void setUp() {
0030     m_10_1 = new Complex(10, 1);
0031     m_1_1 = new Complex(1, 1);
0032     m_11_2 = new Complex(11, 2);
0033   }
0034   void tearDown() {
0035     delete m_10_1;
0036     delete m_1_1;
0037     delete m_11_2;
0038   }
0039   void testEquality() {
0040     CPPUNIT_ASSERT(*m_10_1 == *m_10_1);
0041     CPPUNIT_ASSERT(!(*m_10_1 == *m_11_2));
0042   }
0043   void testAddition() { CPPUNIT_ASSERT(*m_10_1 + *m_1_1 == *m_11_2); }
0044 
0045   // Declare and build the test suite
0046   CPPUNIT_TEST_SUITE(TestSiStripDCS);
0047   CPPUNIT_TEST(testEquality);
0048   CPPUNIT_TEST(testAddition);
0049   CPPUNIT_TEST_SUITE_END();
0050 
0051   Complex *m_10_1, *m_1_1, *m_11_2;
0052 };
0053 
0054 // Register the test suite in the registry.
0055 // This way we will have to only pass the registry to the runner
0056 // and it will contain all the registered test suites.
0057 CPPUNIT_TEST_SUITE_REGISTRATION(TestSiStripDCS);