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/TestCallerTest.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/TestCallerTest.cpp')
-rw-r--r-- | examples/cppunittest/TestCallerTest.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/cppunittest/TestCallerTest.cpp b/examples/cppunittest/TestCallerTest.cpp index d9cab55..9aafd8f 100644 --- a/examples/cppunittest/TestCallerTest.cpp +++ b/examples/cppunittest/TestCallerTest.cpp @@ -1,10 +1,26 @@ #include "TestCallerTest.h" +#include "FailureException.h" #include <cppunit/extensions/TestSuiteBuilder.h> #include <cppunit/extensions/HelperMacros.h> CPPUNIT_TEST_SUITE_REGISTRATION( TestCallerTest ); +void +TestCallerTest::ExceptionThrower::testThrowFailureException() +{ + throw FailureException(); +} + + +void +TestCallerTest::ExceptionThrower::testThrowException() +{ + throw CppUnit::Exception( "expected Exception" ); +} + + + TestCallerTest::TestCallerTest() : m_testName( "TrackedTestCaseCaller" ) { @@ -24,6 +40,8 @@ TestCallerTest::suite() suite.addTestCaller( "testBasicConstructor", &TestCallerTest::testBasicConstructor ); suite.addTestCaller( "testReferenceConstructor", &TestCallerTest::testReferenceConstructor ); suite.addTestCaller( "testPointerConstructor", &TestCallerTest::testPointerConstructor ); + suite.addTestCaller( "testExpectFailureException", &TestCallerTest::testExpectFailureException ); + suite.addTestCaller( "testExpectException", &TestCallerTest::testExpectException ); return suite.takeSuite(); } @@ -139,6 +157,26 @@ TestCallerTest::testPointerConstructor() void +TestCallerTest::testExpectFailureException() +{ + CppUnit::TestCaller<ExceptionThrower,FailureException> caller( + m_testName, + &ExceptionThrower::testThrowFailureException ); + caller.run(); +} + + +void +TestCallerTest::testExpectException() +{ + CppUnit::TestCaller<ExceptionThrower,CppUnit::Exception> caller( + m_testName, + &ExceptionThrower::testThrowException ); + caller.run(); +} + + +void TestCallerTest::checkNothingButConstructorCalled() { CPPUNIT_ASSERT_EQUAL( 1, m_constructorCount ); |