aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/test.c b/test.c
index 0a30e33..0d92ff7 100644
--- a/test.c
+++ b/test.c
@@ -189,21 +189,26 @@ TEST(unpack_struct_simple, "unpack_struct simple")
int main(void)
{
extern struct test __start_tests, __stop_tests;
+ struct test *tests = &__start_tests;
+ ptrdiff_t length = &__stop_tests - &__start_tests;
int ret = EXIT_SUCCESS;
+ assert(length >= 0);
+
pack_trace = PACK_TRACE_OFF;
- for (struct test *t = &__start_tests; t < &__stop_tests; t++) {
- if (t->func()) {
- printf(" OK %s\n", t->desc);
+ printf("1..%tu\n", length);
+ for (ptrdiff_t i = 0; i < length; i++) {
+ if (tests[i].func()) {
+ printf("ok %tu - %s\n", i + 1, tests[i].desc);
continue;
}
pack_trace = PACK_TRACE_ALL;
- fprintf(stderr, ">>> Test failure trace for '%s'\n", t->desc);
- t->func();
+ fprintf(stderr, ">>> Test failure trace for '%s'\n", tests[i].desc);
+ tests[i].func();
fprintf(stderr, "<<<\n");
pack_trace = PACK_TRACE_OFF;
- printf("FAIL %s\n", t->desc);
+ printf("not ok - %tu %s\n", i + 1, tests[i].desc);
ret = EXIT_FAILURE;
}