diff options
author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2001-06-11 18:56:23 +0000 |
---|---|---|
committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2001-06-11 18:56:23 +0000 |
commit | 0c5051a8acf83fd77a6094177eb0711d3f90d997 (patch) | |
tree | a0757b1cae952576f4497d40ccf3aa70a2bf84c8 /examples/cppunittest/FailingTestCase.cpp | |
parent | 021d0a2611777a06d948735e0ad36cb90ffd413b (diff) | |
download | cppunit-0c5051a8acf83fd77a6094177eb0711d3f90d997.tar.gz |
Examples/cppunittest/TestResultTest.
examples/cppunittest/TestResultTest.*: renamed TestListenerTest.*
* examples/cppunittest/*: added unit tests for:
HelperMacros, TestAssert, TestCaller, TestCase, TestFailure,
TestResult, TestSuite, TestDecoratorTest, TestSetUp, RepeatedTestTest,
Orthodox, Exception.
Diffstat (limited to 'examples/cppunittest/FailingTestCase.cpp')
-rw-r--r-- | examples/cppunittest/FailingTestCase.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/cppunittest/FailingTestCase.cpp b/examples/cppunittest/FailingTestCase.cpp new file mode 100644 index 0000000..f519438 --- /dev/null +++ b/examples/cppunittest/FailingTestCase.cpp @@ -0,0 +1,62 @@ +#include "FailingTestCase.h" + + +FailingTestCase::FailingTestCase( bool failSetUp, + bool failRunTest, + bool failTearDown ) : + CppUnit::TestCase( "FailingTestCase" ), + m_failSetUp( failSetUp ), + m_failRunTest( failRunTest ), + m_failTearDown( failTearDown ), + m_setUpCalled( false ), + m_runTestCalled( false ), + m_tearDownCalled( false ) +{ +} + + +FailingTestCase::~FailingTestCase() +{ +} + + +void +FailingTestCase::setUp() +{ + m_setUpCalled = true; + doFailure( m_failSetUp ); +} + + +void +FailingTestCase::tearDown() +{ + m_tearDownCalled = true; + doFailure( m_failTearDown ); +} + + +void +FailingTestCase::runTest() +{ + m_runTestCalled = true; + doFailure( m_failRunTest ); +} + + +void +FailingTestCase::doFailure( bool shouldFail ) +{ + if ( shouldFail ) + throw FailureException(); +} + + +void +FailingTestCase::verify( bool runTestCalled, + bool tearDownCalled ) +{ + CPPUNIT_ASSERT( m_setUpCalled ); + CPPUNIT_ASSERT_EQUAL( runTestCalled, m_runTestCalled ); + CPPUNIT_ASSERT_EQUAL( tearDownCalled, m_tearDownCalled ); +} |