72 lines
1.6 KiB
C
72 lines
1.6 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 "run-test-with.h"
|
||
|
|
||
|
// Internal Prototypes
|
||
|
|
||
|
static TestResult test_run_test_with_test(TestState *, void *);
|
||
|
|
||
|
// Public Functions
|
||
|
|
||
|
void
|
||
|
test_run_test_with(TestState *s)
|
||
|
{
|
||
|
TestState actual, expected;
|
||
|
|
||
|
// build initial state
|
||
|
mk_sample_state(&actual);
|
||
|
void
|
||
|
*pass_in = malloc(0),
|
||
|
*passed_in = 0;
|
||
|
actual.ptr = &passed_in;
|
||
|
|
||
|
// run it and see what was passed
|
||
|
run_test_with(&actual, test_run_test_with_test, pass_in);
|
||
|
chk_ptr_eq(s, "value passed", passed_in, pass_in);
|
||
|
|
||
|
// ensure the state was updated correctly
|
||
|
mk_sample_state(&expected);
|
||
|
expected.passed = 2;
|
||
|
expected.run = 7;
|
||
|
expected.ptr = &passed_in;
|
||
|
chk_TestState_eq(s, "resulting state", &actual, &expected);
|
||
|
|
||
|
free(pass_in);
|
||
|
}
|
||
|
|
||
|
// Internal Functions
|
||
|
|
||
|
static TestResult
|
||
|
test_run_test_with_test(TestState *s, void *ptr)
|
||
|
{
|
||
|
void **passed_in = s->ptr;
|
||
|
*passed_in = ptr;
|
||
|
return test_success;
|
||
|
}
|
||
|
|
||
|
//jl
|