Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ccunit::UnitTest Class Reference

#include <UnitTest.hh>

Inheritance diagram for ccunit::UnitTest:

ccunit::TestComponent ComplexTest StackTest VoidTest List of all members.

Public Methods

 UnitTest (const string &name="(no name)")
 ctor -- set pass/fail counters to zero. More...

virtual ~UnitTest ()
 dtor -- does nothing. More...

virtual void report (ostream &ostr)
 Print a report on an output stream. More...

void _succeed ()
 Called when a test succeeds (increments pass counter). More...


Protected Methods

bool do_test (bool cond, const std::string &lbl, const char *fname, const char *fnt_name, long lineno)
void do_fail (const std::string &lbl, const char *fname, const char *fnt_name, long lineno)
virtual void run_tests ()=0
 override this to actually run tests; call TestComponent::run() to execute tests. More...


Private Methods

 UnitTest (const UnitTest &)
UnitTest & operator= (const UnitTest &)

Detailed Description

Unit testing class. Based on Allison's work (see www.cuj.com).

#

Id:
UnitTest.hh,v 1.3 2002/04/01 23:37:37 canislupus Exp
#

The UnitTest class is the basic building block for the testing framework. Users of this class are expected to derive classes based on this class, but specific to a testing a particular classes. (That sounds awful).

Author:
\URL[Dale K. Hawkins]{mailto:dhawkins@cdrgts.com}.
Version:
#
Revision:
1.3
# \begin{verbatim}
Log:
UnitTest.hh,v
Revision 1.3 2002/04/01 23:37:37 canislupus Progress on Doxygen integration. Added abstract report formatter (generator?). Doxygen output is not right *sigh*.

Revision 1.2 2002/03/29 20:15:06 canislupus Moving to doxygen (continued).

Revision 1.1.1.1 2002/03/28 20:16:56 canislupus

Revision 1.1 2001/04/12 17:47:14 dhawkins Initial checkin.

\end{verbatim}

See also:
TestSuite

Definition at line 79 of file UnitTest.hh.


Constructor & Destructor Documentation

ccunit::UnitTest::UnitTest const string &    name = "(no name)" [inline]
 

ctor -- set pass/fail counters to zero.

Definition at line 131 of file UnitTest.hh.

virtual ccunit::UnitTest::~UnitTest   [inline, virtual]
 

dtor -- does nothing.

Definition at line 86 of file UnitTest.hh.

ccunit::UnitTest::UnitTest const UnitTest &    [private]
 


Member Function Documentation

void ccunit::UnitTest::_succeed   [inline]
 

Called when a test succeeds (increments pass counter).

Definition at line 138 of file UnitTest.hh.

References ccunit::TestComponent::m_nPass.

Referenced by do_test, StackTest::testBadSize, StackTest::testOverflow, StackTest::testPopulate, and StackTest::testUnderflow.

void ccunit::UnitTest::do_fail const std::string &    lbl,
const char *    fname,
const char *    fnt_name,
long    lineno
[protected]
 

Create a failure

Parameters:
lbl  user defined test label
fname  C preprocessor defined filename
fnt_name  C preprocessor defined function name (of the test function)
lineno  C preprocessor defined line number

Definition at line 29 of file UnitTest.cc.

References ccunit::TestComponent::m_failures, and ccunit::TestComponent::m_nFail.

Referenced by do_test.

bool ccunit::UnitTest::do_test bool    cond,
const std::string &    lbl,
const char *    fname,
const char *    fnt_name,
long    lineno
[protected]
 

Execute a test.

Parameters:
cond  if false generate an ErrorReport, else run _succeed
lbl  user defined test label
fname  C preprocessor defined filename
fnt_name  C preprocessor defined function name (of the test function)
lineno  C preprocessor defined line number

Definition at line 15 of file UnitTest.cc.

References _succeed, and do_fail.

UnitTest& ccunit::UnitTest::operator= const UnitTest &    [private]
 

void ccunit::UnitTest::report ostream &    ostr [virtual]
 

Print a report on an output stream.

Implements ccunit::TestComponent.

Definition at line 37 of file UnitTest.cc.

References ccunit::TestComponent::checkRun, ccunit::TestComponent::m_failures, ccunit::TestComponent::m_hasRun, ccunit::TestComponent::m_nFail, and ccunit::TestComponent::m_nPass.

virtual void ccunit::UnitTest::run_tests   [protected, pure virtual]
 

override this to actually run tests; call TestComponent::run() to execute tests.

Implements ccunit::TestComponent.

Implemented in StackTest.


The documentation for this class was generated from the following files:
Generated on Tue Apr 2 15:33:28 2002 for libccunit by doxygen 1.2.14 written by Dimitri van Heesch, © 1997-2002

Project hosted on sourceforge SourceForge Logo