feisty meow concerns codebase 2.140
unit_test::unit_base Class Reference

#include <unit_base.h>

Inherits basis::nameable.

Inherited by application_example [virtual], application_example [virtual], cromp_client_tester [virtual], cromp_decoder [virtual], cromp_server_tester [virtual], many_cromp_tester [virtual], t_amorph [virtual], test_address [virtual], test_angle [virtual], test_array, test_bcast_spocket [virtual], test_bin [virtual], test_bit_vector [virtual], test_blowfish [virtual], test_boilerplate [virtual], test_break_signal [virtual], test_byte_filer [virtual], test_byte_format [virtual], test_callstack_tracker [virtual], test_ccri_angle_average [virtual], test_chaos [virtual], test_command_line [virtual], test_directory [virtual], test_directory_tree [virtual], test_double_plus [virtual], test_doubly_linked_list [virtual], test_earth_time [virtual], test_ellipse [virtual], test_entity [virtual], test_enum_adapaters [virtual], test_fcopy [virtual], test_file_info, test_file_time, test_file_transfer_tentacle [virtual], test_filename [virtual], test_geometric [virtual], test_hash_table [virtual], test_huge_file [virtual], test_ini_parser [virtual], test_int_hash [virtual], test_math_ops [virtual], test_matrix [virtual], test_memory_limiter [virtual], test_mutex [virtual], test_node [virtual], test_object_packing [virtual], test_octopus_identity [virtual], test_octopus_security [virtual], test_packable_tree, test_parsing_csv [virtual], test_point [virtual], test_rectangle_warper [virtual], test_rsa [virtual], test_section_manager [virtual], test_sequence_tracker [virtual], test_set [virtual], test_singly_linked_list [virtual], test_sorts [virtual], test_span_manager [virtual], test_splitter [virtual], test_spocket [virtual], test_stack [virtual], test_string, test_string_table [virtual], test_symbol_table [virtual], test_symbol_tree, test_system_preconditions [virtual], test_system_values [virtual], test_tokenizer [virtual], test_tree [virtual], test_twofish [virtual], test_ucast_spocket [virtual], test_unique_id [virtual], test_unpacker [virtual], test_version [virtual], test_xml_generator [virtual], time_stamp_tester [virtual], and timer_driver_tester [virtual].

Collaboration diagram for unit_test::unit_base:

Public Member Functions

 unit_base ()
 
virtual ~unit_base ()
 
 DEFINE_CLASS_NAME ("unit_base")
 
int total_tests () const
 the total count of tests that have been run.
 
int passed_tests () const
 count of successful tests run.
 
int failed_tests () const
 count of number of failed tests.
 
bool failures_are_critical () const
 
void set_failures_are_critial (bool are_failures_critical)
 
void assert_equal (const basis::hoople_standard &a, const basis::hoople_standard &b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that the objects a and b are equal.
 
void assert_not_equal (const basis::hoople_standard &a, const basis::hoople_standard &b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that objects a and b are NOT equal.
 
void assert_equal (const basis::byte_array &a, const basis::byte_array &b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that the byte_arrays a and b are equal.
 
void assert_not_equal (const basis::byte_array &a, const basis::byte_array &b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that the byte_arrays a and b are not equal.
 
void assert_equal (int a, int b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that integers a and b are equal.
 
void assert_not_equal (int a, int b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that integers a and b are NOT equal.
 
void assert_equal (double a, double b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that doubles a and b are equal.
 
void assert_not_equal (double a, double b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that doubles a and b are NOT equal.
 
void assert_equal (const void *a, const void *b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that void pointers a and b are equal.
 
void assert_not_equal (const void *a, const void *b, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that void pointers a and b are NOT equal.
 
void assert_true (bool result, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that the "result" is a true boolean.
 
void assert_false (bool result, const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 tests that the "result" is a false boolean.
 
void record_pass (const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 very general recording of a successful test; better to use asserts.
 
void record_fail (const basis::astring &class_name, const basis::astring &test_name, const basis::astring &diagnostic_info)
 very general recording of a failed test; better to use asserts.
 
int final_report ()
 generates a report of the total number of tests that succeeded.
 
- Public Member Functions inherited from basis::nameable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer.
 

Detailed Description

Definition at line 58 of file unit_base.h.

Constructor & Destructor Documentation

◆ unit_base()

unit_test::unit_base::unit_base ( )

Definition at line 42 of file unit_base.cpp.

◆ ~unit_base()

unit_test::unit_base::~unit_base ( )
virtual

Definition at line 52 of file unit_base.cpp.

Member Function Documentation

◆ assert_equal() [1/5]

void unit_test::unit_base::assert_equal ( const basis::byte_array &  a,
const basis::byte_array &  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that the byte_arrays a and b are equal.

Definition at line 176 of file unit_base.cpp.

References unit_test::byte_array_phrase, basis::nameable::class_name(), FUNCDEF, basis::array< contents >::length(), and test_name.

◆ assert_equal() [2/5]

void unit_test::unit_base::assert_equal ( const basis::hoople_standard &  a,
const basis::hoople_standard &  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that the objects a and b are equal.

Definition at line 156 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_equal() [3/5]

void unit_test::unit_base::assert_equal ( const void *  a,
const void *  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that void pointers a and b are equal.

note that you can use this to compare any two pointers as long as you cast them to (void *) first. this reports whether the two have the same address in memory, but nothing about their contents.

Definition at line 235 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_equal() [4/5]

void unit_test::unit_base::assert_equal ( double  a,
double  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that doubles a and b are equal.

Definition at line 218 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_equal() [5/5]

void unit_test::unit_base::assert_equal ( int  a,
int  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that integers a and b are equal.

Definition at line 202 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_false()

void unit_test::unit_base::assert_false ( bool  result,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that the "result" is a false boolean.

Definition at line 260 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_not_equal() [1/5]

void unit_test::unit_base::assert_not_equal ( const basis::byte_array &  a,
const basis::byte_array &  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that the byte_arrays a and b are not equal.

Definition at line 189 of file unit_base.cpp.

References unit_test::byte_array_phrase, basis::nameable::class_name(), FUNCDEF, basis::array< contents >::length(), and test_name.

◆ assert_not_equal() [2/5]

void unit_test::unit_base::assert_not_equal ( const basis::hoople_standard &  a,
const basis::hoople_standard &  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that objects a and b are NOT equal.

Definition at line 165 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_not_equal() [3/5]

void unit_test::unit_base::assert_not_equal ( const void *  a,
const void *  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that void pointers a and b are NOT equal.

Definition at line 244 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_not_equal() [4/5]

void unit_test::unit_base::assert_not_equal ( double  a,
double  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that doubles a and b are NOT equal.

Definition at line 226 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_not_equal() [5/5]

void unit_test::unit_base::assert_not_equal ( int  a,
int  b,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that integers a and b are NOT equal.

Definition at line 210 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ assert_true()

void unit_test::unit_base::assert_true ( bool  result,
const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

tests that the "result" is a true boolean.

Definition at line 253 of file unit_base.cpp.

References basis::nameable::class_name(), FUNCDEF, and test_name.

◆ DEFINE_CLASS_NAME()

unit_test::unit_base::DEFINE_CLASS_NAME ( "unit_base"  )

◆ failed_tests()

int unit_test::unit_base::failed_tests ( ) const

count of number of failed tests.

Definition at line 58 of file unit_base.cpp.

◆ failures_are_critical()

bool unit_test::unit_base::failures_are_critical ( ) const
inline

report whether we consider test errors to be a critical failure. if true, then any error causes a non-zero exit return from the unit test. if false, then the successful zero exit occurs instead. this allows a test which is known to fail to not break the build (ahem, borked blowfish!).

Definition at line 70 of file unit_base.h.

◆ final_report()

int unit_test::unit_base::final_report ( )

generates a report of the total number of tests that succeeded.

the return value of this can be used as the exit value of the overall test. if there are any failures, then a failure result is returned (non-zero). otherwise the successful exit status of zero is returned.

Definition at line 267 of file unit_base.cpp.

References configuration::application_configuration::application_name(), BASE_LOG, filesystem::filename::basename(), filesystem::filename::raw(), and structures::symbol_table< contents >::symbols().

◆ passed_tests()

int unit_test::unit_base::passed_tests ( ) const

count of successful tests run.

Definition at line 56 of file unit_base.cpp.

◆ record_fail()

void unit_test::unit_base::record_fail ( const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

very general recording of a failed test; better to use asserts.

Definition at line 94 of file unit_base.cpp.

References BASE_LOG, basis::nameable::class_name(), and test_name.

◆ record_pass()

void unit_test::unit_base::record_pass ( const basis::astring &  class_name,
const basis::astring &  test_name,
const basis::astring &  diagnostic_info 
)

very general recording of a successful test; better to use asserts.

Definition at line 71 of file unit_base.cpp.

References BASE_LOG, basis::nameable::class_name(), and test_name.

◆ set_failures_are_critial()

void unit_test::unit_base::set_failures_are_critial ( bool  are_failures_critical)
inline

Definition at line 77 of file unit_base.h.

◆ total_tests()

int unit_test::unit_base::total_tests ( ) const

the total count of tests that have been run.

Definition at line 54 of file unit_base.cpp.


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