summaryrefslogtreecommitdiff
path: root/examples/cppunittest/TestCallerTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/cppunittest/TestCallerTest.cpp')
-rw-r--r--examples/cppunittest/TestCallerTest.cpp38
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 );