From a772db08cecec4bd6285b65f0e33019f6cf663dd Mon Sep 17 00:00:00 2001 From: jlamothe Date: Tue, 14 Nov 2023 19:33:02 +0000 Subject: [PATCH] try to rebuild log when first entry missing --- test/append-test-log.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/append-test-log.c b/test/append-test-log.c index a392b7a..e6bc467 100644 --- a/test/append-test-log.c +++ b/test/append-test-log.c @@ -42,6 +42,7 @@ struct LogData static void append_to_empty(TestState *); static void append_to_existing(TestState *); static void missing_last(TestState *); +static void missing_first(TestState *); static void chk_last(TestState *, LogData *, const char *); static void mk_log_data(LogData *); @@ -62,6 +63,7 @@ test_append_test_log(TestState *s) append_to_empty(s); append_to_existing(s); missing_last(s); + missing_first(s); } // Local Functions @@ -153,6 +155,32 @@ missing_last(TestState *s) free(ld.state.last_log); } +static void +missing_first(TestState *s) +{ + LogData ld; + print("\tfirst_log missing\n"); + mk_log_data(&ld); + ld.state.first_log = 0; + append_test_log(&ld.state, "baz"); + + // first_log should point to second + print("\t\tfirst_log\n"); + chk_ptr_eq( + s, + "ERROR: append_test_log(): first_log missing: first_log:", + ld.state.first_log, + &ld.second + ); + + chk_last( + s, + &ld, + "ERROR: append_test_log(): first_log missing: last_log:" + ); + free(ld.state.last_log); +} + static void chk_last(TestState *s, LogData *ld, const char *context) {