summaryrefslogtreecommitdiff
path: root/examples/cppunittest/TestPathTest.h
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-12 18:28:48 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2002-04-12 18:28:48 +0000
commited406a2966e62072fa6afaca8abc578db7c0c9fb (patch)
treeab8d2ffb462c3c955b2e339e8cc19f1a6be8bd0f /examples/cppunittest/TestPathTest.h
parentfc9c76622b19adfcdebce682d9d49db8fb9336ef (diff)
downloadcppunit-ed406a2966e62072fa6afaca8abc578db7c0c9fb.tar.gz
Makefile.
Makefile.am: added examples/qt to tar ball release. * TODO: heavily updated. * contrib/msvc/CppUnit*.wwtpl: changed base class for unit test to TestFixture. * include/cppunit/Test.h: removed toString() method. Not used by the framework and source of confusions with getName(). Added getChildTestCount() and getChildTestAt(), introducing the composite pattern at top level. Added utility methods findTest() and findTestPath(). * src/cppunit/Test.cpp: added. Implementation of new utility methods. * include/cppunit/TestCase.h: * src/cppunit/TestCase.cpp: inherits TestLeaf. Removed toString(), run(void) and defaultResult(). Removed default constructor. * src/cppunit/TestCase.cpp: * src/cppunit/TestSuite.cpp: fixed some includes that used "" instead of <>. * include/cppunit/TestComposite.h: * src/cppunit/TestComposite.cpp: added. Common implementation of Test for composite tests (TestSuite). * include/cppunit/TestFailure.h: * src/cppunit/TestFailure.cpp: removed toString(). * include/cppunit/TestLeaf.h: * src/cppunit/TestLeaf.cpp: added. Common implementation of Test for single test (TestCase). * include/cppunit/TestListener.h: added TimingListener example to documentation. * include/cppunit/TestPath.h: * src/cppunit/TestPath.cpp: added. List of test traversed to access a test in the test hierarchy. * include/cppunit/TestRunner.h: added. Generic TestRunner. * src/cppunit/TestRunner.cpp: moved to TextTestRunner.cpp. Added new implementation of includecppunit/TestRunner.h. * include/cppunit/TestSuite.h: * src/cppunit/TestSuite.cpp: inherits TestComposite and implements new Test interface. Removed toString(). * src/cppunit/TextTestRunner.cpp: moved from TestRunner.cpp. Implementation of include/cppunit/ui/text/TestRunner.h. * include/cppunit/extensions/RepeatedTest.h: * src/cppunit/RepeatedTest.cpp: removed toString(). * include/cppunit/extensions/TestDecorator.h: inherits TestLeaf. Removed toString() * include/cppunit/XmlOutputter.h: * src/cppunit/XmlOutputter.cpp: * examples/cppunittest/XmlOutputterTest.cpp: * examples/cppunittest/XmlOutputterTest.h: XML outputter now escape node content. Add unit test for that bug (#540944). Added style sheet support. Modified XML structure: failure message as its own element. * src/msvc/testrunner/TestRunnerModel.h: * src/msvc/testrunner/TestRunnerModel.cpp: used Test::findTest() to find a test by name instead of using RTTI. Added toAnsiString() for convertion when compiling as UNICODE. * src/msvc/testrunner/TreeHierarchyDlg.h: * src/msvc/testrunner/TreeHierarchyDlg.cpp: used new composite interface of Test to explorer the test hierarchy instead of RTTI. * examples/cppunittest/TestPathTest.h: * examples/cppunittest/TestPathTest.cpp: added, unit tests for TestPath. * examples/cppunittest/TestCaseTest.h: * examples/cppunittest/TestCaseTest.cpp: added test for TestLeaf. * examples/cppunittest/TestSuiteTest.h: * examples/cppunittest/TestSuiteTest.cpp: added test for TestComposite and new Test interface.
Diffstat (limited to 'examples/cppunittest/TestPathTest.h')
-rw-r--r--examples/cppunittest/TestPathTest.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/examples/cppunittest/TestPathTest.h b/examples/cppunittest/TestPathTest.h
new file mode 100644
index 0000000..6ed4a98
--- /dev/null
+++ b/examples/cppunittest/TestPathTest.h
@@ -0,0 +1,142 @@
+#ifndef TESTPATHTEST_H
+#define TESTPATHTEST_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestPath.h>
+#include <cppunit/TestCase.h>
+#include <stdexcept>
+
+
+/*! \class TestPathTest
+ * \brief Unit tests for class TestPath.
+ */
+class TestPathTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( TestPathTest );
+ CPPUNIT_TEST( testDefaultConstructor );
+ CPPUNIT_TEST( testAddTest );
+ CPPUNIT_TEST_EXCEPTION( testGetTestAtThrow1, std::out_of_range );
+ CPPUNIT_TEST_EXCEPTION( testGetTestAtThrow2, std::out_of_range );
+ CPPUNIT_TEST( testGetChildTest );
+ CPPUNIT_TEST( testGetChildTestManyTests );
+ CPPUNIT_TEST_EXCEPTION( testGetChildTestThrowIfNotValid, std::out_of_range );
+ CPPUNIT_TEST( testAddPath );
+ CPPUNIT_TEST( testAddInvalidPath );
+ CPPUNIT_TEST( testRemoveTests );
+ CPPUNIT_TEST( testRemoveTest );
+ CPPUNIT_TEST_EXCEPTION( testRemoveTestThrow1, std::out_of_range );
+ CPPUNIT_TEST_EXCEPTION( testRemoveTestThrow2, std::out_of_range );
+ CPPUNIT_TEST( testUp );
+ CPPUNIT_TEST_EXCEPTION( testUpThrow, std::out_of_range );
+ CPPUNIT_TEST( testInsert );
+ CPPUNIT_TEST( testInsertAtEnd );
+ CPPUNIT_TEST_EXCEPTION( testInsertThrow1, std::out_of_range );
+ CPPUNIT_TEST_EXCEPTION( testInsertThrow2, std::out_of_range );
+ CPPUNIT_TEST( testInsertPath );
+ CPPUNIT_TEST_EXCEPTION( testInsertPathThrow, std::out_of_range );
+ CPPUNIT_TEST( testInsertPathDontThrowIfInvalid );
+ CPPUNIT_TEST( testRootConstructor );
+ CPPUNIT_TEST( testPathSliceConstructorCopyUntilEnd );
+ CPPUNIT_TEST( testPathSliceConstructorCopySpecifiedCount );
+ CPPUNIT_TEST( testPathSliceConstructorCopyNone );
+ CPPUNIT_TEST( testPathSliceConstructorNegativeIndex );
+ CPPUNIT_TEST( testPathSliceConstructorAfterEndIndex );
+ CPPUNIT_TEST( testPathSliceConstructorNegativeIndexUntilEnd );
+ CPPUNIT_TEST( testPathSliceConstructorNegativeIndexNone );
+ CPPUNIT_TEST( testToStringNoTest );
+ CPPUNIT_TEST( testToStringOneTest );
+ CPPUNIT_TEST( testToStringHierarchy );
+ CPPUNIT_TEST( testPathStringConstructorRoot );
+ CPPUNIT_TEST( testPathStringConstructorEmptyIsRoot );
+ CPPUNIT_TEST( testPathStringConstructorHierarchy );
+ CPPUNIT_TEST_EXCEPTION( testPathStringConstructorBadRootThrow, std::invalid_argument );
+ CPPUNIT_TEST( testPathStringConstructorRelativeRoot );
+ CPPUNIT_TEST( testPathStringConstructorRelativeRoot2 );
+ CPPUNIT_TEST_EXCEPTION( testPathStringConstructorThrow1, std::invalid_argument );
+ CPPUNIT_TEST( testPathStringConstructorRelativeHierarchy );
+ CPPUNIT_TEST_EXCEPTION( testPathStringConstructorBadRelativeHierarchyThrow, std::invalid_argument );
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ /*! Constructs a TestPathTest object.
+ */
+ TestPathTest();
+
+ /// Destructor.
+ virtual ~TestPathTest();
+
+ void setUp();
+ void tearDown();
+
+ void testDefaultConstructor();
+ void testAddTest();
+ void testGetTestAtThrow1();
+ void testGetTestAtThrow2();
+ void testGetChildTest();
+ void testGetChildTestManyTests();
+ void testGetChildTestThrowIfNotValid();
+
+ void testAddPath();
+ void testAddInvalidPath();
+
+ void testRemoveTests();
+ void testRemoveTest();
+ void testRemoveTestThrow1();
+ void testRemoveTestThrow2();
+ void testUp();
+ void testUpThrow();
+
+ void testInsert();
+ void testInsertAtEnd();
+ void testInsertThrow1();
+ void testInsertThrow2();
+
+ void testInsertPath();
+ void testInsertPathThrow();
+ void testInsertPathDontThrowIfInvalid();
+
+ void testRootConstructor();
+ void testPathSliceConstructorCopyUntilEnd();
+ void testPathSliceConstructorCopySpecifiedCount();
+ void testPathSliceConstructorCopyNone();
+ void testPathSliceConstructorNegativeIndex();
+ void testPathSliceConstructorAfterEndIndex();
+ void testPathSliceConstructorNegativeIndexUntilEnd();
+ void testPathSliceConstructorNegativeIndexNone();
+
+ void testToStringNoTest();
+ void testToStringOneTest();
+ void testToStringHierarchy();
+
+ void testPathStringConstructorRoot();
+ void testPathStringConstructorEmptyIsRoot();
+ void testPathStringConstructorHierarchy();
+ void testPathStringConstructorBadRootThrow();
+ void testPathStringConstructorRelativeRoot();
+ void testPathStringConstructorRelativeRoot2();
+ void testPathStringConstructorThrow1();
+ void testPathStringConstructorRelativeHierarchy();
+ void testPathStringConstructorBadRelativeHierarchyThrow();
+
+private:
+ /// Prevents the use of the copy constructor.
+ TestPathTest( const TestPathTest &copy );
+
+ /// Prevents the use of the copy operator.
+ void operator =( const TestPathTest &copy );
+
+private:
+ CppUnit::TestPath *m_path;
+ CppUnit::TestCase *m_test1;
+ CppUnit::TestCase *m_test2;
+ CppUnit::TestCase *m_test3;
+ CppUnit::TestCase *m_test4;
+ CppUnit::TestSuite *m_suite1;
+ CppUnit::TestSuite *m_suite2;
+ CppUnit::TestCase *m_testSuite2a;
+ CppUnit::TestCase *m_testSuite2b;
+};
+
+
+
+#endif // TESTPATHTEST_H