1 #ifndef TESTPATHTEST_H 2 #define TESTPATHTEST_H 3 4 #include <cppunit/extensions/HelperMacros.h> 5 #include <cppunit/TestPath.h> 6 #include <cppunit/TestCase.h> 7 #include <stdexcept> 8 9 10 /*! \class TestPathTest 11 * \brief Unit tests for class TestPath. 12 */ 13 class TestPathTest : public CPPUNIT_NS::TestFixture 14 { 15 CPPUNIT_TEST_SUITE( TestPathTest ); 16 CPPUNIT_TEST( testDefaultConstructor ); 17 CPPUNIT_TEST( testAddTest ); 18 CPPUNIT_TEST_EXCEPTION( testGetTestAtThrow1, std::out_of_range ); 19 CPPUNIT_TEST_EXCEPTION( testGetTestAtThrow2, std::out_of_range ); 20 CPPUNIT_TEST( testGetChildTest ); 21 CPPUNIT_TEST( testGetChildTestManyTests ); 22 CPPUNIT_TEST_EXCEPTION( testGetChildTestThrowIfNotValid, std::out_of_range ); 23 CPPUNIT_TEST( testAddPath ); 24 CPPUNIT_TEST( testAddInvalidPath ); 25 CPPUNIT_TEST( testRemoveTests ); 26 CPPUNIT_TEST( testRemoveTest ); 27 CPPUNIT_TEST_EXCEPTION( testRemoveTestThrow1, std::out_of_range ); 28 CPPUNIT_TEST_EXCEPTION( testRemoveTestThrow2, std::out_of_range ); 29 CPPUNIT_TEST( testUp ); 30 CPPUNIT_TEST_EXCEPTION( testUpThrow, std::out_of_range ); 31 CPPUNIT_TEST( testInsert ); 32 CPPUNIT_TEST( testInsertAtEnd ); 33 CPPUNIT_TEST_EXCEPTION( testInsertThrow1, std::out_of_range ); 34 CPPUNIT_TEST_EXCEPTION( testInsertThrow2, std::out_of_range ); 35 CPPUNIT_TEST( testInsertPath ); 36 CPPUNIT_TEST_EXCEPTION( testInsertPathThrow, std::out_of_range ); 37 CPPUNIT_TEST( testInsertPathDontThrowIfInvalid ); 38 CPPUNIT_TEST( testRootConstructor ); 39 CPPUNIT_TEST( testPathSliceConstructorCopyUntilEnd ); 40 CPPUNIT_TEST( testPathSliceConstructorCopySpecifiedCount ); 41 CPPUNIT_TEST( testPathSliceConstructorCopyNone ); 42 CPPUNIT_TEST( testPathSliceConstructorNegativeIndex ); 43 CPPUNIT_TEST( testPathSliceConstructorAfterEndIndex ); 44 CPPUNIT_TEST( testPathSliceConstructorNegativeIndexUntilEnd ); 45 CPPUNIT_TEST( testPathSliceConstructorNegativeIndexNone ); 46 CPPUNIT_TEST( testToStringNoTest ); 47 CPPUNIT_TEST( testToStringOneTest ); 48 CPPUNIT_TEST( testToStringHierarchy ); 49 CPPUNIT_TEST( testPathStringConstructorRoot ); 50 CPPUNIT_TEST( testPathStringConstructorEmptyIsRoot ); 51 CPPUNIT_TEST( testPathStringConstructorHierarchy ); 52 CPPUNIT_TEST_EXCEPTION( testPathStringConstructorBadRootThrow, std::invalid_argument ); 53 CPPUNIT_TEST( testPathStringConstructorRelativeRoot ); 54 CPPUNIT_TEST( testPathStringConstructorRelativeRoot2 ); 55 CPPUNIT_TEST_EXCEPTION( testPathStringConstructorThrow1, std::invalid_argument ); 56 CPPUNIT_TEST( testPathStringConstructorRelativeHierarchy ); 57 CPPUNIT_TEST_EXCEPTION( testPathStringConstructorBadRelativeHierarchyThrow, std::invalid_argument ); 58 CPPUNIT_TEST_SUITE_END(); 59 60 public: 61 /*! Constructs a TestPathTest object. 62 */ 63 TestPathTest(); 64 65 /// Destructor. 66 virtual ~TestPathTest(); 67 68 void setUp(); 69 void tearDown(); 70 71 void testDefaultConstructor(); 72 void testAddTest(); 73 void testGetTestAtThrow1(); 74 void testGetTestAtThrow2(); 75 void testGetChildTest(); 76 void testGetChildTestManyTests(); 77 void testGetChildTestThrowIfNotValid(); 78 79 void testAddPath(); 80 void testAddInvalidPath(); 81 82 void testRemoveTests(); 83 void testRemoveTest(); 84 void testRemoveTestThrow1(); 85 void testRemoveTestThrow2(); 86 void testUp(); 87 void testUpThrow(); 88 89 void testInsert(); 90 void testInsertAtEnd(); 91 void testInsertThrow1(); 92 void testInsertThrow2(); 93 94 void testInsertPath(); 95 void testInsertPathThrow(); 96 void testInsertPathDontThrowIfInvalid(); 97 98 void testRootConstructor(); 99 void testPathSliceConstructorCopyUntilEnd(); 100 void testPathSliceConstructorCopySpecifiedCount(); 101 void testPathSliceConstructorCopyNone(); 102 void testPathSliceConstructorNegativeIndex(); 103 void testPathSliceConstructorAfterEndIndex(); 104 void testPathSliceConstructorNegativeIndexUntilEnd(); 105 void testPathSliceConstructorNegativeIndexNone(); 106 107 void testToStringNoTest(); 108 void testToStringOneTest(); 109 void testToStringHierarchy(); 110 111 void testPathStringConstructorRoot(); 112 void testPathStringConstructorEmptyIsRoot(); 113 void testPathStringConstructorHierarchy(); 114 void testPathStringConstructorBadRootThrow(); 115 void testPathStringConstructorRelativeRoot(); 116 void testPathStringConstructorRelativeRoot2(); 117 void testPathStringConstructorThrow1(); 118 void testPathStringConstructorRelativeHierarchy(); 119 void testPathStringConstructorBadRelativeHierarchyThrow(); 120 121 private: 122 /// Prevents the use of the copy constructor. 123 TestPathTest( const TestPathTest © ); 124 125 /// Prevents the use of the copy operator. 126 void operator =( const TestPathTest © ); 127 128 private: 129 CPPUNIT_NS::TestPath *m_path; 130 CPPUNIT_NS::TestCase *m_test1; 131 CPPUNIT_NS::TestCase *m_test2; 132 CPPUNIT_NS::TestCase *m_test3; 133 CPPUNIT_NS::TestCase *m_test4; 134 CPPUNIT_NS::TestSuite *m_suite1; 135 CPPUNIT_NS::TestSuite *m_suite2; 136 CPPUNIT_NS::TestCase *m_testSuite2a; 137 CPPUNIT_NS::TestCase *m_testSuite2b; 138 }; 139 140 141 142 #endif // TESTPATHTEST_H 143