UnitTesting Class Referenceabstract

Public Member Functions

virtual ~UnitTesting ()
 Destructor. More...
 
Index get_tests_count () const
 Returns the number of tests which have been performed by the test case. More...
 
Index get_tests_passed_count () const
 Returns the number of tests which have passed the test case. More...
 
Index get_tests_failed_count () const
 Returns the number of tests which have failed the test case. More...
 
Index get_random_tests_number () const
 Returns the number of iterations for loops of random tests. More...
 
const bool & get_display () const
 Returns the display messages to the screen value of this object. More...
 
void set_tests_count (const Index &)
 
void set_tests_passed_count (const Index &)
 
void set_tests_failed_count (const Index &)
 
void set_random_tests_number (const Index &)
 
void set_message (const string &)
 
void set_display (const bool &)
 
void assert_true (const bool &, const string &)
 
void assert_false (const bool &, const string &)
 
virtual void run_test_case ()=0
 This method runs all the methods contained in the test case.
 
void print_results ()
 

Protected Attributes

Index tests_count
 Number of performed tests. More...
 
Index tests_passed_count
 Number of tests which have passed the test case. More...
 
Index tests_failed_count
 Number of tests which have failed the test case. More...
 
Index random_tests_number
 Number of iterations in random tests loops. More...
 
bool display = true
 True if messages from this class are to be displayed, false otherwise. More...
 
const int n = omp_get_max_threads()
 
ThreadPool * thread_pool = new ThreadPool(n)
 
ThreadPoolDevice * thread_pool_device = new ThreadPoolDevice(thread_pool, n)
 

Detailed Description

Definition at line 29 of file unit_testing.h.

Constructor & Destructor Documentation

◆ UnitTesting()

UnitTesting ( )
explicit

Definition at line 11 of file unit_testing.cpp.

◆ ~UnitTesting()

~UnitTesting ( )
virtual

Destructor.

Definition at line 23 of file unit_testing.cpp.

Member Function Documentation

◆ assert_false()

void assert_false ( const bool &  condition,
const string &  error_message 
)

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
conditionExpression of the condition to be tested.
error_messageError message to be appended to the information message, typically the file name and the line where the condition has been tested.

Definition at line 148 of file unit_testing.cpp.

◆ assert_true()

void assert_true ( const bool &  condition,
const string &  error_message 
)

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
conditionExpression of the condition to be tested.
error_messageError message to be appended to the information message, typically the file name and the line where the condition has been tested.

Definition at line 122 of file unit_testing.cpp.

◆ get_display()

const bool & get_display ( ) const

Returns the display messages to the screen value of this object.

Definition at line 62 of file unit_testing.cpp.

◆ get_random_tests_number()

Index get_random_tests_number ( ) const

Returns the number of iterations for loops of random tests.

Definition at line 54 of file unit_testing.cpp.

◆ get_tests_count()

Index get_tests_count ( ) const

Returns the number of tests which have been performed by the test case.

Definition at line 30 of file unit_testing.cpp.

◆ get_tests_failed_count()

Index get_tests_failed_count ( ) const

Returns the number of tests which have failed the test case.

Definition at line 46 of file unit_testing.cpp.

◆ get_tests_passed_count()

Index get_tests_passed_count ( ) const

Returns the number of tests which have passed the test case.

Definition at line 38 of file unit_testing.cpp.

◆ print_results()

void print_results ( )

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 174 of file unit_testing.cpp.

◆ set_display()

void set_display ( const bool &  new_display)

Sets a new display value to this object.

Parameters
new_displayDisplay value.

Definition at line 107 of file unit_testing.cpp.

◆ set_random_tests_number()

void set_random_tests_number ( const Index &  new_random_tests_number)

Sets a new value for the number of iterations in loops of random tests.

Parameters
new_random_tests_numberNumber of random tests in each loop.

Definition at line 98 of file unit_testing.cpp.

◆ set_tests_count()

void set_tests_count ( const Index &  new_tests_count)

Sets a new value for the number of tests performed by the test case.

Parameters
new_tests_countNumber of tests performed.

Definition at line 71 of file unit_testing.cpp.

◆ set_tests_failed_count()

void set_tests_failed_count ( const Index &  new_tests_failed_count)

Sets a new value for the number of tests which have failed the test case.

Parameters
new_tests_failed_countNumber of tests failed.

Definition at line 89 of file unit_testing.cpp.

◆ set_tests_passed_count()

void set_tests_passed_count ( const Index &  new_tests_passed_count)

Sets a new value for the number of tests which have passed the test case.

Parameters
new_tests_passed_countNumber of tests passed.

Definition at line 80 of file unit_testing.cpp.

Member Data Documentation

◆ display

bool display = true
protected

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

Definition at line 93 of file unit_testing.h.

◆ n

const int n = omp_get_max_threads()
protected

Definition at line 95 of file unit_testing.h.

◆ random_tests_number

Index random_tests_number
protected

Number of iterations in random tests loops.

Definition at line 89 of file unit_testing.h.

◆ tests_count

Index tests_count
protected

Number of performed tests.

Definition at line 77 of file unit_testing.h.

◆ tests_failed_count

Index tests_failed_count
protected

Number of tests which have failed the test case.

Definition at line 85 of file unit_testing.h.

◆ tests_passed_count

Index tests_passed_count
protected

Number of tests which have passed the test case.

Definition at line 81 of file unit_testing.h.

◆ thread_pool

ThreadPool* thread_pool = new ThreadPool(n)
protected

Definition at line 96 of file unit_testing.h.

◆ thread_pool_device

ThreadPoolDevice* thread_pool_device = new ThreadPoolDevice(thread_pool, n)
protected

Definition at line 97 of file unit_testing.h.


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