2023-11-07 19:20:33 -05:00
|
|
|
/*
|
|
|
|
|
|
|
|
9unit
|
|
|
|
Copyright (C) Jonathan Lamothe <jonathan@jlamothe.net>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
2023-11-09 18:24:48 -05:00
|
|
|
it under the terms of the GNU Lesser General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
2023-11-07 19:20:33 -05:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2023-11-09 18:24:48 -05:00
|
|
|
Lesser General Public License for more details.
|
2023-11-07 19:20:33 -05:00
|
|
|
|
2023-11-09 18:24:48 -05:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this program. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>.
|
2023-11-07 19:20:33 -05:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
|
|
|
|
#include "../9unit.h"
|
2023-11-09 15:48:51 -05:00
|
|
|
#include "util.h"
|
2023-11-07 19:20:33 -05:00
|
|
|
#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);
|
2023-11-14 18:08:19 -05:00
|
|
|
decl_test(initial_context);
|
|
|
|
decl_test(initial_full_context);
|
|
|
|
decl_test(initial_depth);
|
2023-11-14 18:53:43 -05:00
|
|
|
decl_test(initial_report);
|
2023-11-07 19:20:33 -05:00
|
|
|
|
|
|
|
// Public Functions
|
|
|
|
|
|
|
|
void
|
|
|
|
test_initial_state(TestState *s)
|
|
|
|
{
|
2023-11-08 18:38:42 -05:00
|
|
|
print("initial state\n");
|
2023-11-08 17:10:09 -05:00
|
|
|
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);
|
2023-11-14 18:08:19 -05:00
|
|
|
run_test(s, initial_context);
|
|
|
|
run_test(s, initial_full_context);
|
|
|
|
run_test(s, initial_depth);
|
2023-11-14 18:53:43 -05:00
|
|
|
run_test(s, initial_report);
|
2023-11-07 19:20:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Internal Functions
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-11-14 18:08:19 -05:00
|
|
|
def_test(initial_context, s)
|
|
|
|
{
|
|
|
|
TestState *scpy = s->ptr;
|
|
|
|
print("\tcontext\n");
|
|
|
|
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;
|
|
|
|
print("\tfull_context\n");
|
|
|
|
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;
|
|
|
|
print("\tdepth\n");
|
|
|
|
if (scpy->depth == 0) return test_success;
|
|
|
|
append_test_log(s, "initial depth was not zero");
|
|
|
|
return test_failure;
|
|
|
|
}
|
|
|
|
|
2023-11-14 18:53:43 -05:00
|
|
|
def_test(initial_report, s)
|
|
|
|
{
|
|
|
|
TestState *scpy = s->ptr;
|
|
|
|
print("\treport()\n");
|
|
|
|
if (scpy->report != 0) return test_success;
|
|
|
|
append_test_log(s, "initial report was null");
|
|
|
|
return test_failure;
|
|
|
|
}
|
|
|
|
|
2023-11-07 19:20:33 -05:00
|
|
|
//jl
|