From e69a2d0375671fd1e995036b0c9291013140db79 Mon Sep 17 00:00:00 2001 From: jlamothe Date: Thu, 9 Nov 2023 21:12:21 +0000 Subject: [PATCH] check all counts when comparing test states --- test/util.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/test/util.c b/test/util.c index 502723b..c030a00 100644 --- a/test/util.c +++ b/test/util.c @@ -47,6 +47,33 @@ static void compare_run( const TestState * ); +// compare the passed value of two states +static void compare_passed( + TestState *, + const char *, + const char *, + const TestState *, + const TestState * +); + +// compare the failed value of two states +static void compare_failed( + TestState *, + const char *, + const char *, + const TestState *, + const TestState * +); + +// compare the pending value of two states +static void compare_pending( + TestState *, + const char *, + const char *, + const TestState *, + const TestState * +); + // compare two ints static void compare_ints( TestState *, @@ -69,6 +96,9 @@ compare_states( ) { compare_run(s, prefix, context, expected, actual); + compare_passed(s, prefix, context, expected, actual); + compare_failed(s, prefix, context, expected, actual); + compare_pending(s, prefix, context, expected, actual); } // Local Functions @@ -89,6 +119,54 @@ compare_run( compare_ints(s, full_context, expected->run, actual->run); } +static void +compare_passed( + TestState *s, + const char *prefix, + const char *context, + const TestState *expected, + const TestState *actual +) +{ + char full_context[STR_BUF_SIZE]; + print(prefix); + print("passed\n"); + snprintf(full_context, STR_BUF_SIZE, "%s passed:", context); + compare_ints(s, full_context, expected->passed, actual->passed); +} + +static void +compare_failed( + TestState *s, + const char *prefix, + const char *context, + const TestState *expected, + const TestState *actual +) +{ + char full_context[STR_BUF_SIZE]; + print(prefix); + print("failed\n"); + snprintf(full_context, STR_BUF_SIZE, "%s failed:", context); + compare_ints(s, full_context, expected->failed, actual->failed); +} + +static void +compare_pending( + TestState *s, + const char *prefix, + const char *context, + const TestState *expected, + const TestState *actual +) +{ + char full_context[STR_BUF_SIZE]; + print(prefix); + print("pending\n"); + snprintf(full_context, STR_BUF_SIZE, "%s pending:", context); + compare_ints(s, full_context, expected->pending, actual->pending); +} + static void compare_ints( TestState *s,