16static char UNIT_TEST_RESULTS_FILE[100];
25static FILE* _ps_unit_test_file = NULL;
35 snprintf(UNIT_TEST_RESULTS_FILE,
sizeof(UNIT_TEST_RESULTS_FILE),
39 _ps_unit_test_file = fopen(UNIT_TEST_RESULTS_FILE,
"w");
40 if (!_ps_unit_test_file) {
41 ps_abort(
"failed to create unit test report file.");
45 if (fprintf(_ps_unit_test_file,
"🤔 Unit test report for %s\n",
48 ps_abort(
"failed to write to unit test report file.");
50 fflush(_ps_unit_test_file);
58 fprintf(_ps_unit_test_file,
"🫡 Unit test report for %s: %s\n",
62 if (fclose(_ps_unit_test_file) != 0) {
63 ps_abort(
"failed to close unit test report file.");
73 fprintf(_ps_unit_test_file,
"%s %s:%llu:%s: %s\n", result ?
"✅" :
"❌",
78 fputc(
'\t', _ps_unit_test_file);
81 vfprintf(_ps_unit_test_file, msg, args);
83 fputc(
'\n', _ps_unit_test_file);
87 fflush(_ps_unit_test_file);
96 fprintf(_ps_unit_test_file,
97 "❌ %s:%llu:%s: %s\n\tAn error occured "
102 fflush(_ps_unit_test_file);
111 fprintf(_ps_unit_test_file,
"🤫 %s:%llu:%s: Output surpressed:\n\t%s\n",
113 fflush(_ps_unit_test_file);
121 fprintf(_ps_unit_test_file,
"🗣️ %s: Output unsurpressed: %s\n",
124 fflush(_ps_unit_test_file);
Defines assertion and abortion functionality.
#define ps_abort(msg)
Aborts the program with the given message.
void _PS_BEGIN_UNIT_TESTS(STR file)
void _PS_UNIT_ASSERT(int result, STR expr, STR func, u64 line, STR msg,...)
void PS_END_UNIT_TESTS(void)
End unit tests.
void _PS_UNIT_SUPPRESS(STR msg, STR func, u64 line)
void PS_UNIT_UNSUPPRESS(void)
Unsuppress unit test output.
bool surpressed_gave_error
Provides assertion macros for unit tests.