X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=test%2Fexampletest.cpp;fp=test%2Fexampletest.cpp;h=32ad2a347e710f36da1e25950a7498426571df37;hb=bef4a9fc121deae7ba81687eee1c73fe61e5ca33;hp=0000000000000000000000000000000000000000;hpb=47b1f5c0294e079bc120dc8366977951aa0778bf;p=germs.git diff --git a/test/exampletest.cpp b/test/exampletest.cpp new file mode 100644 index 0000000..32ad2a3 --- /dev/null +++ b/test/exampletest.cpp @@ -0,0 +1,75 @@ +#ifndef __GENEORDERTEST_H__ +#define __GENEORDERTEST_H__ + +#include +#include + +/* + * 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 l1 (new long (12)); + std::auto_ptr 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