minor edits and testing of initial TestState value
This commit is contained in:
113
test/tests.c
113
test/tests.c
@@ -21,11 +21,122 @@
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
||||
#include "../9unit.h"
|
||||
|
||||
#define decl_test(n) static TestResult n(TestState *)
|
||||
#define def_test(n, s) static TestResult n(TestState *s)
|
||||
|
||||
// Internal Prototypes
|
||||
|
||||
static void test(TestState *);
|
||||
static void test_initial_state(TestState *);
|
||||
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);
|
||||
|
||||
// Public Functions
|
||||
|
||||
void
|
||||
main()
|
||||
{
|
||||
print("Tests not yet implemented.\n");
|
||||
run_tests(&tests);
|
||||
exits(0);
|
||||
}
|
||||
|
||||
// Internal Functions
|
||||
|
||||
static void
|
||||
tests(TestState *s)
|
||||
{
|
||||
if (!s) exits("ERROR: no TestState");
|
||||
|
||||
// Make a copy of the initial TestState and store it
|
||||
TestState scpy;
|
||||
memcpy(&scpy, s, sizeof(TestState));
|
||||
s->ptr = &scpy;
|
||||
|
||||
test_initial_state(s);
|
||||
}
|
||||
|
||||
static void
|
||||
test_initial_state(TestState *s)
|
||||
{
|
||||
print("Testing initial state\n");
|
||||
run_test(s, &initial_test_count);
|
||||
run_test(s, &initial_pass_count);
|
||||
run_test(s, &initial_fail_count);
|
||||
run_test(s, &initial_pend_count);
|
||||
run_test(s, &initial_first_log);
|
||||
run_test(s, &initial_last_log);
|
||||
run_test(s, &initial_ptr);
|
||||
}
|
||||
|
||||
def_test(initial_test_count, s)
|
||||
{
|
||||
TestState *scpy = s->ptr;
|
||||
print("\trun\n");
|
||||
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;
|
||||
print("\tfailed\n");
|
||||
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;
|
||||
print("\tfirst_log\n");
|
||||
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;
|
||||
print("\tlast_log\n");
|
||||
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;
|
||||
print("\tptr\n");
|
||||
if (scpy->ptr == 0) return test_success;
|
||||
append_test_log(s, "initial ptr was not null");
|
||||
return test_failure;
|
||||
}
|
||||
|
||||
//jl
|
||||
|
||||
Reference in New Issue
Block a user