re-implemented test using new convenience functions

This commit is contained in:
jlamothe
2023-11-21 05:12:41 +00:00
7 changed files with 261 additions and 706 deletions

View File

@@ -26,129 +26,23 @@
#include "util.h"
#include "initial-state.h"
// Internal Prototypes
static void tests(TestState *);
decl_test(initial_test_count);
decl_test(initial_pass_count);
decl_test(initial_fail_count);
decl_test(initial_pend_count);
decl_test(initial_first_log);
decl_test(initial_last_log);
decl_test(initial_ptr);
decl_test(initial_context);
decl_test(initial_full_context);
decl_test(initial_depth);
decl_test(initial_report);
// Public Functions
void
test_initial_state(TestState *s)
test_initial_state(TestState *s, void *ptr)
{
single_test_context(s, "run", initial_test_count);
single_test_context(s, "passsed", initial_pass_count);
single_test_context(s, "failed", initial_fail_count);
single_test_context(s, "pending", initial_pend_count);
single_test_context(s, "first_log", initial_first_log);
single_test_context(s, "last_log", initial_last_log);
single_test_context(s, "ptr", initial_ptr);
single_test_context(s, "context", initial_context);
single_test_context(s, "full_context", initial_full_context);
single_test_context(s, "depth", initial_depth);
single_test_context(s, "report()", initial_report);
}
// Internal Functions
def_test(initial_test_count, s)
{
TestState *scpy = s->ptr;
if (scpy->run == 0) return test_success;
append_test_log(s, "initial run was nonzero");
return test_failure;
}
def_test(initial_pass_count, s)
{
TestState *scpy = s->ptr;
print("\tpassed\n");
if (scpy->passed == 0) return test_success;
append_test_log(s, "initial passed was nonzero");
return test_failure;
}
def_test(initial_fail_count, s)
{
TestState *scpy = s->ptr;
if (scpy->failed == 0) return test_success;
append_test_log(s, "initial failed was nonzero");
return test_failure;
}
def_test(initial_pend_count, s)
{
TestState *scpy = s->ptr;
print("\tpending\n");
if (scpy->pending == 0) return test_success;
append_test_log(s, "initial pending was nonzero");
return test_failure;
}
def_test(initial_first_log, s)
{
TestState *scpy = s->ptr;
if (scpy->first_log == 0) return test_success;
append_test_log(s, "initial first_log was not null");
return test_failure;
}
def_test(initial_last_log, s)
{
TestState *scpy = s->ptr;
if (scpy->last_log == 0) return test_success;
append_test_log(s, "initial last_log was not null");
return test_failure;
}
def_test(initial_ptr, s)
{
TestState *scpy = s->ptr;
if (scpy->ptr == 0) return test_success;
append_test_log(s, "initial ptr was not null");
return test_failure;
}
def_test(initial_context, s)
{
TestState *scpy = s->ptr;
if (scpy->context == 0) return test_success;
append_test_log(s, "initial context was not null");
return test_failure;
}
def_test(initial_full_context, s)
{
TestState *scpy = s->ptr;
if (scpy->context == 0) return test_success;
append_test_log(s, "initial full_context was not null");
return test_failure;
}
def_test(initial_depth, s)
{
TestState *scpy = s->ptr;
if (scpy->depth == 0) return test_success;
append_test_log(s, "initial depth was not zero");
return test_failure;
}
def_test(initial_report, s)
{
TestState *scpy = s->ptr;
if (scpy->report != 0) return test_success;
append_test_log(s, "initial report was null");
return test_failure;
TestState *scpy = ptr;
chk_int_eq(s, "run", scpy->run, 0);
chk_int_eq(s, "passsed", scpy->passed, 0);
chk_int_eq(s, "failed", scpy->failed, 0);
chk_int_eq(s, "pending", scpy->pending, 0);
chk_ptr_eq(s, "first_log", scpy->first_log, 0);
chk_ptr_eq(s, "last_log", scpy->last_log, 0);
chk_ptr_eq(s, "ptr", scpy->ptr, 0);
chk_ptr_eq(s, "context", scpy->context, 0);
chk_ptr_eq(s, "full_context", scpy->full_context, 0);
chk_int_eq(s, "depth", scpy->depth, 0);
chk_ptr_ne(s, "report()", scpy->report, 0);
}
//jl