Flood::UnitTesting Class Reference

This class contains a minimal set of utilities needed for automated unit testing.

#include <UnitTesting.h>

List of all members.

Public Member Functions

 UnitTesting (void)
virtual ~UnitTesting (void)
int get_tests_count (void)
int get_tests_passed_count (void)
int get_tests_failed_count (void)
std::string & get_message (void)
bool get_display (void)
void set_tests_count (int)
void set_tests_passed_count (int)
void set_tests_failed_count (int)
void set_message (const std::string &)
void set_display (bool)
void assert_true (bool, const std::string &)
void assert_false (bool, const std::string &)
virtual void run_test_case (void)=0
void print_results (void)

Protected Attributes

int tests_count
int tests_passed_count
int tests_failed_count
std::string message
bool display


Detailed Description

Definition at line 29 of file UnitTesting.h.


Constructor & Destructor Documentation

Flood::UnitTesting::UnitTesting ( void   )  [explicit]

General constructor. It constructs a test case with default values:

  • Message: empty
  • Tests count: 0
  • Tests passed: 0
  • Tests failed: 0
  • Display: true

Definition at line 38 of file UnitTesting.cpp.

Flood::UnitTesting::~UnitTesting ( void   )  [virtual]

Destructor.

Definition at line 54 of file UnitTesting.cpp.


Member Function Documentation

void Flood::UnitTesting::assert_false ( bool  condition,
const std::string &  error_message 
)

This method checks that a condition is false. It increases the number of tests by one. It increases the number of tests passed by one if the condition is false. It increases the number of tests failed by one if the condition is true. It appends to the information message an error message is the condition is not satisfied.

Parameters:
condition Expression of the condition to be tested.
error_message Error message to be appended to the information message, typically the file name and the line where the condition has been tested.

Definition at line 243 of file UnitTesting.cpp.

void Flood::UnitTesting::assert_true ( bool  condition,
const std::string &  error_message 
)

This method checks that a condition is true. It increases the number of tests by one. It increases the number of tests passed by one if the condition is true. It increases the number of tests failed by one if the condition is false. It appends to the information message an error message is the condition is not satisfied.

Parameters:
condition Expression of the condition to be tested.
error_message Error message to be appended to the information message, typically the file name and the line where the condition has been tested.

Definition at line 215 of file UnitTesting.cpp.

bool Flood::UnitTesting::get_display ( void   ) 

This method returns the display messages to the screen value of this object.

Definition at line 105 of file UnitTesting.cpp.

std::string & Flood::UnitTesting::get_message ( void   ) 

This method returns a reference to the test case information message.

Definition at line 95 of file UnitTesting.cpp.

int Flood::UnitTesting::get_tests_count ( void   ) 

This method returns the number of tests which have been performed by the test case.

Definition at line 65 of file UnitTesting.cpp.

int Flood::UnitTesting::get_tests_failed_count ( void   ) 

This method returns the number of tests which have failed the test case.

Definition at line 85 of file UnitTesting.cpp.

int Flood::UnitTesting::get_tests_passed_count ( void   ) 

This method returns the number of tests which have passed the test case.

Definition at line 75 of file UnitTesting.cpp.

void Flood::UnitTesting::print_results ( void   ) 

This method prints the test case results to the screen:

  • Information message.
  • Number of tests performed.
  • Number of tests passed.
  • Number of tests failed.
  • Concluding remarks.

Definition at line 271 of file UnitTesting.cpp.

virtual void Flood::UnitTesting::run_test_case ( void   )  [pure virtual]

This method runs all the methods contained in the test case.

void Flood::UnitTesting::set_display ( bool  new_display  ) 

This method sets a new display value to this object.

Parameters:
new_display Display value.

Definition at line 198 of file UnitTesting.cpp.

void Flood::UnitTesting::set_message ( const std::string &  new_message  ) 

This method sets a new test case information message.

Parameters:
new_message Information message.

Definition at line 187 of file UnitTesting.cpp.

void Flood::UnitTesting::set_tests_count ( int  new_tests_count  ) 

This method sets a new value for the number of tests performed by the test case.

Parameters:
new_tests_count Number of tests performed.

Definition at line 116 of file UnitTesting.cpp.

void Flood::UnitTesting::set_tests_failed_count ( int  new_tests_failed_count  ) 

This method sets a new value for the number of tests which have failed the test case.

Parameters:
new_tests_failed_count Number of tests failed.

Definition at line 164 of file UnitTesting.cpp.

void Flood::UnitTesting::set_tests_passed_count ( int  new_tests_passed_count  ) 

This method sets a new value for the number of tests which have passed the test case.

Parameters:
new_tests_passed_count Number of tests passed.

Definition at line 140 of file UnitTesting.cpp.


Member Data Documentation

bool Flood::UnitTesting::display [protected]

True if messages from this class are to be displayed, false otherwise.

Definition at line 97 of file UnitTesting.h.

std::string Flood::UnitTesting::message [protected]

String with the test case information.

Definition at line 93 of file UnitTesting.h.

Number of performed tests.

Definition at line 81 of file UnitTesting.h.

Number of tests which have failed the test case.

Definition at line 89 of file UnitTesting.h.

Number of tests which have passed the test case.

Definition at line 85 of file UnitTesting.h.


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

Generated on Fri Jul 30 09:52:01 2010 for Flood by  doxygen 1.5.9