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