From 5e8b1b73c769ab7f012c2ee322c7f3f2d09e0608 Mon Sep 17 00:00:00 2001 From: jlamothe Date: Mon, 13 Nov 2023 01:27:07 +0000 Subject: [PATCH] make sure last_log changes, but isn't null on append --- test/append-test-log.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/append-test-log.c b/test/append-test-log.c index 2d19797..e05107e 100644 --- a/test/append-test-log.c +++ b/test/append-test-log.c @@ -21,6 +21,7 @@ #include #include +#include #include "../9unit.h" #include "util.h" @@ -31,6 +32,14 @@ static void append_to_empty(TestState *); static void append_to_existing(TestState *); +static void chk_ptr_chg( + TestState *, + const char *, + const char *, + const void *, + const void * +); + // Public Functions void @@ -105,6 +114,50 @@ append_to_existing(TestState *s) test.first_log, &first ); + + // last should change + print("\t\tlast_log\n"); + chk_ptr_chg( + s, + "\t\t\t", + "ERROR: append_test_log(): last_log:", + test.last_log, + &second + ); +} + +static void +chk_ptr_chg( + TestState *s, + const char *prefix, + const char *context, + const void *actual, + const void *prohibited +) +{ + char str[STR_BUF_SIZE]; + + // make sure it's changed + print(prefix); + print("changed\n"); + snprintf(str, STR_BUF_SIZE, "%s changed:", context); + chk_ptr_ne( + s, + str, + actual, + prohibited + ); + + // make sure it's not null + print(prefix); + print("not null\n"); + snprintf(str, STR_BUF_SIZE, "%s not null:", context); + chk_ptr_ne( + s, + str, + actual, + 0 + ); } //jl