From 0c5051a8acf83fd77a6094177eb0711d3f90d997 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Mon, 11 Jun 2001 18:56:23 +0000 Subject: 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. --- examples/cppunittest/FailingTestCase.cpp | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/cppunittest/FailingTestCase.cpp (limited to 'examples/cppunittest/FailingTestCase.cpp') 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 ); +} -- cgit v1.2.1