26 using namespace basis;
33 #define BASE_LOG(s) EMERGENCY_LOG(program_wide_logger::get(), s)
40 {
if (bv)
return "true";
else return "false"; }
42 unit_base::unit_base()
58 {
return c_total_tests - c_passed_tests; }
64 if (ret == common::IS_NEW) {
88 if (ret == common::IS_NEW) {
104 astring(
"no problem with: ") + assertion_name);
114 astring(
"Error in assertion ") + assertion_name +
":\n"
122 void unit_base::record_failed_int_compare(
int a,
int b,
126 astring(
"Error in assertion ") + assertion_name
127 +
a_sprintf(
": inappropriate values: %d & %d", a, b));
130 void unit_base::record_failed_double_compare(
double a,
double b,
134 astring(
"Error in assertion ") + assertion_name
135 +
a_sprintf(
": inappropriate values: %f & %f", a, b));
138 void unit_base::record_failed_pointer_compare(
const void *a,
const void *b,
142 astring(
"Error in assertion ") + assertion_name
143 +
a_sprintf(
": inappropriate values: %p & %p", a, b));
146 void unit_base::record_failed_tf_assertion(
bool result,
159 bool are_equal = (a == b);
168 bool are_equal = (a == b);
179 bool are_equal = (a == b);
192 bool are_equal = (a == b);
203 FUNCDEF(
"assert_equal integer");
204 bool are_equal = a == b;
211 FUNCDEF(
"assert_not_equal integer");
212 bool are_inequal = a != b;
219 FUNCDEF(
"assert_equal double");
220 bool are_equal = a == b;
227 FUNCDEF(
"assert_not_equal double");
228 bool are_inequal = a != b;
237 FUNCDEF(
"assert_equal void pointer");
238 bool are_equal = a == b;
246 FUNCDEF(
"assert_not_equal void pointer");
247 bool are_inequal = a != b;
276 if (c_total_tests == c_passed_tests) keyword =
"SUCCESS";
279 if (!c_total_tests) keyword =
"LAMENESS (no tests!)";
287 astring message = keyword +
" for "
289 +
a_sprintf(
": %d of %d unit tests passed.",
299 void unit_base::write_cppunit_xml()
302 astring logs_dir = environment::get(
"FEISTY_MEOW_LOGS");
303 if (logs_dir == astring::empty_string()) logs_dir =
"logs";
304 astring outfile = logs_dir +
"/"
320 for (
int i = 0; i < c_failed.
symbols(); i++) {
323 report.
open_tag(
"FailedTest", attribs);
330 report.
open_tag(
"FailureType", attribs);
334 report.
open_tag(
"Location", attribs);
337 report.
add_content(application_configuration::application_name());
355 for (
int i = 0; i < c_successful.
symbols(); i++) {
392 xml_out.write(text_report);
a_sprintf is a specialization of astring that provides printf style support.
int length() const
Returns the current reported length of the allocated C array.
Provides a dynamically resizable ASCII character string.
auto_synchronizer simplifies concurrent code by automatically unlocking.
A very common template for a dynamic array of bytes.
the base class of the most easily used and tested objects in the library.
virtual const char * class_name() const =0
Returns the bare name of this class as a constant character pointer.
Outcomes describe the state of completion for an operation.
virtual void text_form(base_string &state_fill) const =0
Provides a text view of all the important info owned by this object.
Provides file managment services using the standard I/O support.
Provides operations commonly needed on file names.
const basis::astring & raw() const
returns the astring that we're holding onto for the path.
filename basename() const
returns the base of the filename; no directory.
Provides a symbol_table that holds strings as the content.
const basis::astring & name(int index) const
returns the name held at the "index".
basis::outcome add(const basis::astring &name, const contents &storage)
Enters a symbol name into the table along with some contents.
int symbols() const
returns the number of symbols listed in the table.
Supports simple XML output with consistency checking.
basis::outcome add_content(const basis::astring &content)
stores content into the currently opened tag.
basis::outcome close_tag(const basis::astring &tag_name)
closes a previously added "tag_name".
basis::outcome open_tag(const basis::astring &tag_name, const structures::string_table &attributes)
adds a tag with "tag_name" and the "attributes", if any.
basis::astring generate()
writes the current state into a string and returns it.
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.
int total_tests() const
the total count of tests that have been run.
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.
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.
int passed_tests() const
count of successful tests run.
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::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_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.
int final_report()
generates a report of the total number of tests that succeeded.
int failed_tests() const
count of number of failed tests.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
Implements an application lock to ensure only one is running at once.
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
A logger that sends to the console screen using the standard output device.
A dynamic container class that holds any kind of object via pointers.
Useful support functions for unit testing, especially within hoople.
const int EXPECTED_MAXIMUM_TESTS
maximum number of tests expected.
const char * name_for_bools(bool bv)
const char * byte_array_phrase