File indexing completed on 2024-04-06 11:59:50
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 {
0012 public:
0013 Complex( const double realInput, const double imgInput) :
0014 real(realInput),
0015 img(imgInput)
0016 {
0017 }
0018 Complex operator+( const Complex & number )
0019 {
0020 Complex temp(*this);
0021 temp.real += number.real;
0022 temp.img += number.img;
0023 return temp;
0024 }
0025 bool operator==(const Complex & number) const
0026 {
0027 return( real == number.real && img == number.img );
0028 }
0029
0030 double real;
0031 double img;
0032 };
0033
0034 class TestSiStripDCS : public CppUnit::TestFixture {
0035 public:
0036 TestSiStripDCS() {}
0037
0038 void setUp()
0039 {
0040 m_10_1 = new Complex(10, 1);
0041 m_1_1 = new Complex(1, 1);
0042 m_11_2 = new Complex(11, 2);
0043 }
0044 void tearDown()
0045 {
0046 delete m_10_1;
0047 delete m_1_1;
0048 delete m_11_2;
0049 }
0050 void testEquality()
0051 {
0052 CPPUNIT_ASSERT( *m_10_1 == *m_10_1 );
0053 CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
0054 }
0055 void testAddition()
0056 {
0057 CPPUNIT_ASSERT( *m_10_1 + *m_1_1 == *m_11_2 );
0058 }
0059
0060
0061 CPPUNIT_TEST_SUITE( TestSiStripDCS );
0062 CPPUNIT_TEST( testEquality );
0063 CPPUNIT_TEST( testAddition );
0064 CPPUNIT_TEST_SUITE_END();
0065
0066 Complex * m_10_1, * m_1_1, * m_11_2;
0067 };
0068
0069
0070
0071
0072 CPPUNIT_TEST_SUITE_REGISTRATION( TestSiStripDCS );