]> ruin.nu Git - germs.git/blobdiff - test/exampletest.cpp
some initial tests
[germs.git] / test / exampletest.cpp
diff --git a/test/exampletest.cpp b/test/exampletest.cpp
new file mode 100644 (file)
index 0000000..32ad2a3
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef __GENEORDERTEST_H__
+#define __GENEORDERTEST_H__
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+/* 
+ * A test case that is designed to produce
+ * example errors and failures.
+ *
+ */
+
+#define TESTNAME ExampleTest
+
+
+class TESTNAME : public CPPUNIT_NS::TestFixture
+{
+  CPPUNIT_TEST_SUITE( TESTNAME );
+  CPPUNIT_TEST( example );
+  CPPUNIT_TEST( anotherExample );
+  CPPUNIT_TEST( testAdd );
+  CPPUNIT_TEST( testEquals );
+  CPPUNIT_TEST_SUITE_END();
+
+protected:
+
+       double m_value1;
+       double m_value2;
+public:
+
+       void setUp (){
+               m_value1 = 2.0;
+               m_value2 = 3.0;
+       }
+
+protected:
+
+       void example ()
+       {
+               CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05);
+               CPPUNIT_ASSERT (1 == 0);
+               CPPUNIT_ASSERT (1 == 1);
+       }
+
+       void anotherExample ()
+       {
+               CPPUNIT_ASSERT (1 == 2);
+       }
+
+       void testAdd ()
+       {
+               double result = m_value1 + m_value2;
+               CPPUNIT_ASSERT (result == 6.0);
+       }
+
+       void testEquals ()
+       {
+               std::auto_ptr<long>     l1 (new long (12));
+               std::auto_ptr<long>     l2 (new long (12));
+
+               CPPUNIT_ASSERT_EQUAL (12, 12);
+               CPPUNIT_ASSERT_EQUAL (12L, 12L);
+               CPPUNIT_ASSERT_EQUAL (*l1, *l2);
+
+               CPPUNIT_ASSERT (12L == 12L);
+               CPPUNIT_ASSERT_EQUAL (12, 13);
+               CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, 11.99, 0.5);
+       }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME );
+
+#undef TESTNAME
+
+#endif