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/TestCallerTest.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'examples/cppunittest/TestCallerTest.cpp') 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 #include 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(); } @@ -138,6 +156,26 @@ TestCallerTest::testPointerConstructor() } +void +TestCallerTest::testExpectFailureException() +{ + CppUnit::TestCaller caller( + m_testName, + &ExceptionThrower::testThrowFailureException ); + caller.run(); +} + + +void +TestCallerTest::testExpectException() +{ + CppUnit::TestCaller caller( + m_testName, + &ExceptionThrower::testThrowException ); + caller.run(); +} + + void TestCallerTest::checkNothingButConstructorCalled() { -- cgit v1.2.1