ensure the log doesn't change when the message is null

This commit is contained in:
jlamothe 2023-11-14 19:59:13 +00:00
parent a772db08ce
commit 2a092d1050

View File

@ -43,6 +43,7 @@ static void append_to_empty(TestState *);
static void append_to_existing(TestState *); static void append_to_existing(TestState *);
static void missing_last(TestState *); static void missing_last(TestState *);
static void missing_first(TestState *); static void missing_first(TestState *);
static void null_message(TestState *);
static void chk_last(TestState *, LogData *, const char *); static void chk_last(TestState *, LogData *, const char *);
static void mk_log_data(LogData *); static void mk_log_data(LogData *);
@ -64,6 +65,7 @@ test_append_test_log(TestState *s)
append_to_existing(s); append_to_existing(s);
missing_last(s); missing_last(s);
missing_first(s); missing_first(s);
null_message(s);
} }
// Local Functions // Local Functions
@ -181,6 +183,33 @@ missing_first(TestState *s)
free(ld.state.last_log); 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 static void
chk_last(TestState *s, LogData *ld, const char *context) chk_last(TestState *s, LogData *ld, const char *context)
{ {