From 2a092d10501d71fcc01b58105c848cb08332c8a0 Mon Sep 17 00:00:00 2001 From: jlamothe Date: Tue, 14 Nov 2023 19:59:13 +0000 Subject: [PATCH] ensure the log doesn't change when the message is null --- test/append-test-log.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/append-test-log.c b/test/append-test-log.c index e6bc467..213c9f0 100644 --- a/test/append-test-log.c +++ b/test/append-test-log.c @@ -43,6 +43,7 @@ static void append_to_empty(TestState *); static void append_to_existing(TestState *); static void missing_last(TestState *); static void missing_first(TestState *); +static void null_message(TestState *); static void chk_last(TestState *, LogData *, const char *); static void mk_log_data(LogData *); @@ -64,6 +65,7 @@ test_append_test_log(TestState *s) append_to_existing(s); missing_last(s); missing_first(s); + null_message(s); } // Local Functions @@ -181,6 +183,33 @@ missing_first(TestState *s) free(ld.state.last_log); } +static void +null_message(TestState *s) +{ + LogData ld; + print("\tnull message\n"); + mk_log_data(&ld); + append_test_log(&ld.state, 0); + + // first shouldn't change + print("\t\tfirst_log\n"); + chk_ptr_eq( + s, + "ERROR: append_test_log(): null message: first_log:", + ld.state.first_log, + &ld.first + ); + + // last shouldn't change + print("\t\tlast_log\n"); + chk_ptr_eq( + s, + "ERROR: append_test_log(): null message: last_log:", + ld.state.last_log, + &ld.second + ); +} + static void chk_last(TestState *s, LogData *ld, const char *context) {