diff options
Diffstat (limited to 'utest/utest-test.c')
| -rw-r--r-- | utest/utest-test.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/utest/utest-test.c b/utest/utest-test.c index 591ee32..df7d51b 100644 --- a/utest/utest-test.c +++ b/utest/utest-test.c @@ -2,23 +2,28 @@ static int a, b; -/* This should pass */ -TEST_BEGIN(test_pass) +void test_pass_run(utest *t) { - asserteq(a, 0); - assertneq(a, b); - expect(b > a, "expected b > a"); - TEST_OUT + asserteq(t, a, 0); + assertneq(t, a, b); + expect(t, b > a, "expected b > a"); } -TEST_END -/* This should fail */ -TEST_BEGIN(test_fail) +void test_fail_run(utest *t) { - expect(0, "oopsie!"); - TEST_OUT + expect(t, 0, "oopsie!"); +} + +void test_crash_run(utest *t) +{ + int *x = NULL; + *x = 8; +} + +void test_timeout_run(utest *t) +{ + sleep(10); } -TEST_END void test_init(void) { @@ -26,9 +31,16 @@ void test_init(void) printf("hello, world!\n\n"); } -void test_destroy(void) +void test_cleanup(void) { printf("\ngood bye!\n"); } -RUN_TEST_SUITE(test_init, test_destroy, test_pass, test_fail); +utest tests[] = { + UTEST_INIT_S(test_pass, 0), + UTEST_INIT_S(test_fail, 0), + UTEST_INIT_S(test_crash, 0), + UTEST_INIT_S(test_timeout, 1), +}; + +RUN_TEST_SUITE(test_init, test_cleanup, tests); |
