From 3309ac7aeeb071d2e455c3eb02feb2bbf248d511 Mon Sep 17 00:00:00 2001 From: jlamothe Date: Fri, 10 Nov 2023 22:44:42 +0000 Subject: [PATCH] made compare_ints() and compare_ptrs() accessible from outside util --- test/util.c | 88 ++++++++++++++++++++++------------------------------- test/util.h | 16 ++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/test/util.c b/test/util.c index 85b77b0..7f1517e 100644 --- a/test/util.c +++ b/test/util.c @@ -110,22 +110,6 @@ static void compare_ptr( const TestState * ); -// compare two ints -static void compare_ints( - TestState *, - const char *, - int, - int -); - -// compare two pointers -static void compare_ptrs( - TestState *, - const char *, - void *, - void * -); - decl_test(compare_ints_test); decl_test(compare_ptrs_test); @@ -159,6 +143,42 @@ compare_states( compare_ptr(s, prefix, context, expected, actual); } +void +compare_ints( + TestState *s, + const char *context, + int expected, + int actual +) +{ + void *old_ptr = s->ptr; + CompareInts ci; + ci.context = context; + ci.expected = expected; + ci.actual = actual; + s->ptr = &ci; + run_test(s, compare_ints_test); + s->ptr = old_ptr; +} + +void +compare_ptrs( + TestState *s, + const char *context, + void *expected, + void *actual +) +{ + void *old_ptr = s->ptr; + ComparePtrs cp; + cp.context = context; + cp.expected = expected; + cp.actual = actual; + s->ptr = &cp; + run_test(s, compare_ptrs_test); + s->ptr = old_ptr; +} + // Local Functions static void @@ -273,42 +293,6 @@ compare_ptr( compare_ptrs(s, full_context, expected->ptr, actual->ptr); } -static void -compare_ints( - TestState *s, - const char *context, - int expected, - int actual -) -{ - void *old_ptr = s->ptr; - CompareInts ci; - ci.context = context; - ci.expected = expected; - ci.actual = actual; - s->ptr = &ci; - run_test(s, compare_ints_test); - s->ptr = old_ptr; -} - -static void -compare_ptrs( - TestState *s, - const char *context, - void *expected, - void *actual -) -{ - void *old_ptr = s->ptr; - ComparePtrs cp; - cp.context = context; - cp.expected = expected; - cp.actual = actual; - s->ptr = &cp; - run_test(s, compare_ptrs_test); - s->ptr = old_ptr; -} - def_test(compare_ints_test, s) { const CompareInts *ci = s->ptr; diff --git a/test/util.h b/test/util.h index eaca9f9..1f51ce2 100644 --- a/test/util.h +++ b/test/util.h @@ -36,4 +36,20 @@ extern void compare_states( const TestState * // actual state ); +// compare two ints +extern void compare_ints( + TestState *, + const char *, // the error context + int, // the expected value + int // the actual value +); + +// compare two pointers +extern void compare_ptrs( + TestState *, + const char *, // the error context + void *, // the expected value + void * // the actual value +); + //jl