Compare commits

..

No commits in common. "6539b87ea945e89c93e43c242cd3440d076abe19" and "e5cad7cd20030a712e48d5f8fdb3706d8942a2bc" have entirely different histories.

2 changed files with 7 additions and 97 deletions

View File

@ -350,7 +350,7 @@ print_log(TestState *s)
TestLogEntry *e = s->first_log;
while(e)
{
if(e->text) print("\n%s", e->text);
if(e->text) print("%s\n", e->text);
else print("(empty message)\n");
e = e->next;
}
@ -389,8 +389,7 @@ reindex(TestState *s)
else if (s->last_log) // we have a last log but no first?
{
s->first_log = s->last_log;
log_test_context(s);
append_test_log(s, "potential memory leak in test log");
fprint(2, "potential memory leak in test log\n");
}
}

View File

@ -44,13 +44,7 @@ static void missing_last(TestState *);
static void missing_first(TestState *);
static void null_message(TestState *);
static TestResult null_state(TestState *);
static void chk_empty_first(TestState *, void *);
static void chk_first(TestState *, void *);
static void chk_second(TestState *, void *);
static void chk_last(TestState *, void *);
static void mf_chk_first(TestState *, void *);
static void mf_chk_second(TestState *, void *);
static void mf_chk_third(TestState*, void *);
static void mk_log_data(LogData *);
static void chk_ptr_chg(
@ -83,16 +77,8 @@ append_to_empty(TestState *s)
TestState test;
mk_sample_state(&test);
append_test_log(&test, "foo");
// first_log
test_context_with(
s,
"first_log",
chk_empty_first,
&test
);
// last_log
chk_ptr_ne(s, "first_log", test.first_log, 0);
chk_str_eq(s, "first_log->text", test.first_log->text, "foo");
chk_ptr_eq(s, "last_log", test.last_log, test.first_log);
}
@ -102,8 +88,7 @@ append_to_existing(TestState *s)
LogData ld;
mk_log_data(&ld);
append_test_log(&ld.state, "baz");
test_context_with(s, "first_log", chk_first, &ld);
test_context_with(s, "second log", chk_second, &ld);
chk_ptr_eq(s, "first_log", ld.state.first_log, &ld.first);
test_context_with(s, "last_log", chk_last, &ld);
}
@ -114,8 +99,7 @@ missing_last(TestState *s)
mk_log_data(&ld);
ld.state.last_log = 0;
append_test_log(&ld.state, "baz");
test_context_with(s, "first_log", chk_first, &ld);
test_context_with(s, "second log", chk_second, &ld);
chk_ptr_eq(s, "first_log", ld.state.first_log, &ld.first);
test_context_with(s, "last_log", chk_last, &ld);
}
@ -126,7 +110,7 @@ missing_first(TestState *s)
mk_log_data(&ld);
ld.state.first_log = 0;
append_test_log(&ld.state, "baz");
test_context_with(s, "first_log", mf_chk_first, &ld);
chk_ptr_eq(s, "first_log", ld.state.first_log, &ld.second);
test_context_with(s, "last_log", chk_last, &ld);
}
@ -148,48 +132,6 @@ null_state(TestState *)
return test_success;
}
static void
chk_empty_first(TestState *s, void *ptr)
{
TestState *test = ptr;
chk_str_eq(s, "text", test->first_log->text, "foo");
chk_ptr_eq(s, "next", test->first_log->next, 0);
}
static void
chk_first(TestState *s, void *ptr)
{
LogData *ld = ptr;
// first_log
chk_ptr_eq(
s,
0,
ld->state.first_log,
&ld->first
);
// next
chk_ptr_eq(
s,
"next",
ld->state.first_log->next,
&ld->second
);
}
static void
chk_second(TestState *s, void *ptr)
{
LogData *ld = ptr;
chk_ptr_eq(
s,
"next",
ld->second.next,
ld->state.last_log
);
}
static void
chk_last(TestState *s, void *ptr)
{
@ -201,37 +143,6 @@ chk_last(TestState *s, void *ptr)
free(ld->state.last_log);
}
static void
mf_chk_first(TestState *s, void *ptr)
{
LogData *ld = ptr;
chk_ptr_eq(s, 0, ld->state.first_log, &ld->second);
test_context_with(s, "next", mf_chk_second, ptr);
}
static void
mf_chk_second(TestState *s, void *ptr)
{
LogData *ld = ptr;
TestLogEntry *e = ld->second.next;
chk_str_eq(s, "text", e->text, "<no context>");
test_context_with(s, "next", mf_chk_third, ptr);
}
static void
mf_chk_third(TestState *s, void *ptr)
{
LogData *ld = ptr;
TestLogEntry *e = ld->second.next->next;
chk_str_eq(
s,
"text",
e->text,
"potential memory leak in test log"
);
chk_ptr_eq(s, "next", e->next, ld->state.last_log);
}
static void
mk_log_data(LogData *ld)
{