196 lines
4.5 KiB
C
196 lines
4.5 KiB
C
/*
|
|
|
|
9unit
|
|
Copyright (C) Jonathan Lamothe <jonathan@jlamothe.net>
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
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.
|
|
|
|
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
|
|
Lesser General Public License for more details.
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
#include <u.h>
|
|
#include <libc.h>
|
|
|
|
#include "../9unit.h"
|
|
#include "util.h"
|
|
#include "initial-state.h"
|
|
|
|
// Internal Prototypes
|
|
|
|
static TestResult initial_test_count(TestState *, void *);
|
|
static TestResult initial_pass_count(TestState *, void *);
|
|
static TestResult initial_fail_count(TestState *, void *);
|
|
static TestResult initial_pend_count(TestState *, void *);
|
|
static TestResult initial_first_log(TestState *, void *);
|
|
static TestResult initial_last_log(TestState *, void *);
|
|
static TestResult initial_ptr(TestState *, void *);
|
|
static TestResult initial_context(TestState *, void *);
|
|
static TestResult initial_full_context(TestState *, void *);
|
|
static TestResult initial_depth(TestState *, void *);
|
|
static TestResult initial_report(TestState *, void *);
|
|
|
|
// Public Functions
|
|
|
|
void
|
|
test_initial_state(TestState *s, void *ptr)
|
|
{
|
|
single_test_context(s, "run", initial_test_count, ptr);
|
|
single_test_context(s, "passsed", initial_pass_count, ptr);
|
|
single_test_context(s, "failed", initial_fail_count, ptr);
|
|
single_test_context(s, "pending", initial_pend_count, ptr);
|
|
single_test_context(s, "first_log", initial_first_log, ptr);
|
|
single_test_context(s, "last_log", initial_last_log, ptr);
|
|
single_test_context(s, "ptr", initial_ptr, ptr);
|
|
single_test_context(s, "context", initial_context, ptr);
|
|
single_test_context(s, "full_context", initial_full_context, ptr);
|
|
single_test_context(s, "depth", initial_depth, ptr);
|
|
single_test_context(s, "report()", initial_report, ptr);
|
|
}
|
|
|
|
// Internal Functions
|
|
|
|
static TestResult
|
|
initial_test_count(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->run == 0) return test_success;
|
|
append_test_log(s, "initial run was nonzero");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_pass_count(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->passed == 0) return test_success;
|
|
append_test_log(s, "initial passed was nonzero");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_fail_count(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->failed == 0) return test_success;
|
|
append_test_log(s, "initial failed was nonzero");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_pend_count(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->pending == 0) return test_success;
|
|
append_test_log(s, "initial pending was nonzero");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_first_log(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->first_log == 0) return test_success;
|
|
append_test_log(s, "initial first_log was not null");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_last_log(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->last_log == 0) return test_success;
|
|
append_test_log(s, "initial last_log was not null");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_ptr(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = s->ptr;
|
|
if (scpy->ptr == 0) return test_success;
|
|
append_test_log(s, "initial ptr was not null");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_context(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->context == 0) return test_success;
|
|
append_test_log(s, "initial context was not null");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_full_context(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->context == 0) return test_success;
|
|
append_test_log(s, "initial full_context was not null");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_depth(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = ptr;
|
|
if (scpy->depth == 0) return test_success;
|
|
append_test_log(s, "initial depth was not zero");
|
|
return test_failure;
|
|
}
|
|
|
|
static TestResult
|
|
initial_report(
|
|
TestState *s,
|
|
void *ptr
|
|
)
|
|
{
|
|
TestState *scpy = s->ptr;
|
|
if (scpy->report != 0) return test_success;
|
|
append_test_log(s, "initial report was null");
|
|
return test_failure;
|
|
}
|
|
|
|
//jl
|