idaeim studio
 Utility

Checker Class Reference

A Checker is used to compare expected against obtained results for unit testing. More...

#include <Checker.hh>

List of all members.

Public Member Functions

bool check (bool passed)
 Updates the check accounting.
template<typename OBJECT >
bool check (const std::string &description, OBJECT &expected, OBJECT &obtained)
 Checks two objects.
bool check (const std::string &description, long double expected, long double obtained)
 Checks two long double values.
bool check (const std::string &description, double expected, double obtained)
 Checks two double values.
bool check (const std::string &description, unsigned long long expected, unsigned long long obtained)
 Checks two unsigned long long values.
bool check (const std::string &description, long long expected, long long obtained)
 Checks two long long values.
bool check (const std::string &description, unsigned long expected, unsigned long obtained)
 Checks two unsigned long values.
bool check (const std::string &description, long expected, long obtained)
 Checks two long values.
bool check (const std::string &description, unsigned int expected, unsigned int obtained)
 Checks two unsigned int values.
bool check (const std::string &description, int expected, int obtained)
 Checks two int values.
bool check (const std::string &description, unsigned short expected, unsigned short obtained)
 Checks two short unsigned short.
bool check (const std::string &description, short expected, short obtained)
 Checks two short values.
bool check (const std::string &description, bool expected, bool obtained)
 Checks two bool values.
bool check (const std::string &description, void *expected, void *obtained)
 Checks two addresses.
bool check (const std::string &description, std::string &expected, std::string &obtained)
 Checks two string objects.
bool check (const std::string &description, std::ostringstream &expected, std::ostringstream &obtained)
 Checks the contents of two ostringstream objects.
 Checker ()

Public Attributes

int Checks_Passed
 Total number of Checks where expected matched obtained.
int Checks_Total
 Total number of Checks performed.
bool Reset_Values
 Set to true to reset (clear) the expected and obtained values when possible.
bool Verbose
 Set to true to always show both the expected and obtained values.

Static Public Attributes

static const char *const ID
 Class identification name with source code version and date.


Detailed Description

A Checker is used to compare expected against obtained results for unit testing.

Each check function compares (==) the expected against the obtained.

A message line is printed to cout of the form:

PASS|FAIL: <description<

where "PASS" is used if the comparison is true, "FAIL" otherwise.

If the comparison fails, or verbose is true, the expected and obtained values are printed on the following lines:

====> expected|obtained [<length<:<NL>]: <expected<|<obtained<

For strings, and the strings contained in ostringstreams, their length is listed and they are started on a new line.

N.B.: The contents of string and ostringstream arguments are cleared after use if Reset_Values is true (the default).

Each function returns the result of the comparison.

Author:
Bradford Castalia 1.2

Constructor & Destructor Documentation

Checker (  ) 


Member Function Documentation

bool check ( const std::string &  description,
std::ostringstream &  expected,
std::ostringstream &  obtained 
)

Checks the contents of two ostringstream objects.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

Referenced by Checker::check().

bool check ( const std::string &  description,
std::string &  expected,
std::string &  obtained 
)

Checks two string objects.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
void *  expected,
void *  obtained 
)

Checks two addresses.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
bool  expected,
bool  obtained 
)

Checks two bool values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
short  expected,
short  obtained 
)

Checks two short values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
unsigned short  expected,
unsigned short  obtained 
)

Checks two short unsigned short.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
int  expected,
int  obtained 
)

Checks two int values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
unsigned int  expected,
unsigned int  obtained 
)

Checks two unsigned int values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
long  expected,
long  obtained 
)

Checks two long values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
unsigned long  expected,
unsigned long  obtained 
)

Checks two unsigned long values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
long long  expected,
long long  obtained 
)

Checks two long long values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
unsigned long long  expected,
unsigned long long  obtained 
)

Checks two unsigned long long values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
double  expected,
double  obtained 
)

Checks two double values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
long double  expected,
long double  obtained 
)

Checks two long double values.

Parameters:
description A brief description of what is being checked.
expected The expected result.
obtained The obtained result.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

bool check ( const std::string &  description,
OBJECT &  expected,
OBJECT &  obtained 
) [inline]

Checks two objects.

The objects being checked must provide operator== and operator<< methods. The results of operator== will determine if the check passes (true) or fails (false). If the test fails or Verbose is true operator<< will be used to list each OBJECT to cout (stdout).

Parameters:
description A brief description of what is being checked.
expected The expected OBJECT.
obtained The obtained OBJECT.
Returns:
true if the check passed; false otherwise. The check accumulators will be updated accordingly.

References Checker::check(), and Checker::Verbose.

bool check ( bool  passed  ) 

Updates the check accounting.

The Checks_Total accumulator is incremented. The Checks_Passed accumulator is incremented if passed is true.

Parameters:
passed true if the external test passed; false otherwise.
Returns:
The passed value.

The Checks_Total accumulator is incremented. The Checks_Passed accumulator is incremented if passed is true.

Parameters:
passed true if the external test passed; false otherwise.
Returns:
The passed value.


Member Data Documentation

const char *const ID [static]

Initial value:

        "idaeim::Checker (1.14 2009/03/23 18:22:47)"
Class identification name with source code version and date.

Total number of Checks performed.

Total number of Checks where expected matched obtained.

bool Verbose

Set to true to always show both the expected and obtained values.

Referenced by Checker::check().

Set to true to reset (clear) the expected and obtained values when possible.


The documentation for this class was generated from the following files:

Generated on Mon Oct 12 19:59:40 2009 for Utility by  doxygen 1.5.8