partially testing run_test()

This commit is contained in:
jlamothe
2023-11-09 20:48:51 +00:00
parent 1e5423b564
commit c2f8972d9c
5 changed files with 177 additions and 7 deletions

View File

@@ -22,11 +22,14 @@
#include <libc.h>
#include "../9unit.h"
#include "util.h"
#include "run-test.h"
// Internal Prototypes
static void test_passing(TestState *);
static void mk_sample_state(TestState *);
decl_test(always_passes);
// Public Functions
@@ -39,12 +42,45 @@ test_run_test(TestState *s)
// Internal Functions
static
void test_passing(TestState *s)
static void
test_passing(TestState *s)
{
void *oldptr = s->ptr;
TestState expected, actual;
print("\tpassing\n");
s->ptr = oldptr;
// expected result
memset(&expected, 0, sizeof(TestState));
expected.passed = 2;
expected.failed = 2;
expected.pending = 3;
expected.run = 7;
// actual result
mk_sample_state(&actual);
run_test(&actual, always_passes);
compare_states(
s,
"\t\t",
"ERROR: run_test(): passing:",
&expected,
&actual
);
}
static void
mk_sample_state(TestState *s)
{
memset(s, 0, sizeof(TestState));
s->passed = 1;
s->failed = 2;
s->pending = 3;
s->run = 6;
}
decl_test(always_passes)
{
return test_success;
}
//jl