]> ruin.nu Git - germs.git/blob - test/exampletest.cpp
some initial tests
[germs.git] / test / exampletest.cpp
1 #ifndef __GENEORDERTEST_H__
2 #define __GENEORDERTEST_H__
3
4 #include <cppunit/TestFixture.h>
5 #include <cppunit/extensions/HelperMacros.h>
6
7 /* 
8  * A test case that is designed to produce
9  * example errors and failures.
10  *
11  */
12
13 #define TESTNAME ExampleTest
14
15
16 class TESTNAME : public CPPUNIT_NS::TestFixture
17 {
18   CPPUNIT_TEST_SUITE( TESTNAME );
19   CPPUNIT_TEST( example );
20   CPPUNIT_TEST( anotherExample );
21   CPPUNIT_TEST( testAdd );
22   CPPUNIT_TEST( testEquals );
23   CPPUNIT_TEST_SUITE_END();
24
25 protected:
26
27         double m_value1;
28         double m_value2;
29 public:
30
31         void setUp (){
32                 m_value1 = 2.0;
33                 m_value2 = 3.0;
34         }
35
36 protected:
37
38         void example ()
39         {
40                 CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05);
41                 CPPUNIT_ASSERT (1 == 0);
42                 CPPUNIT_ASSERT (1 == 1);
43         }
44
45         void anotherExample ()
46         {
47                 CPPUNIT_ASSERT (1 == 2);
48         }
49
50         void testAdd ()
51         {
52                 double result = m_value1 + m_value2;
53                 CPPUNIT_ASSERT (result == 6.0);
54         }
55
56         void testEquals ()
57         {
58                 std::auto_ptr<long>     l1 (new long (12));
59                 std::auto_ptr<long>     l2 (new long (12));
60
61                 CPPUNIT_ASSERT_EQUAL (12, 12);
62                 CPPUNIT_ASSERT_EQUAL (12L, 12L);
63                 CPPUNIT_ASSERT_EQUAL (*l1, *l2);
64
65                 CPPUNIT_ASSERT (12L == 12L);
66                 CPPUNIT_ASSERT_EQUAL (12, 13);
67                 CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, 11.99, 0.5);
68         }
69 };
70
71 CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME );
72
73 #undef TESTNAME
74
75 #endif