Compare commits
6 Commits
3d01638da0
...
1d306f32c0
Author | SHA1 | Date | |
---|---|---|---|
1d306f32c0 | |||
bcfd584608 | |||
2a092d1050 | |||
a772db08ce | |||
47638ef0b7 | |||
580af62244 |
|
@ -41,7 +41,11 @@ struct LogData
|
|||
|
||||
static void append_to_empty(TestState *);
|
||||
static void append_to_existing(TestState *);
|
||||
static void a2e_chk_last(TestState *, LogData *);
|
||||
static void missing_last(TestState *);
|
||||
static void missing_first(TestState *);
|
||||
static void null_message(TestState *);
|
||||
decl_test(null_state);
|
||||
static void chk_last(TestState *, LogData *, const char *);
|
||||
static void mk_log_data(LogData *);
|
||||
|
||||
static void chk_ptr_chg(
|
||||
|
@ -60,6 +64,10 @@ test_append_test_log(TestState *s)
|
|||
print("append_test_log()\n");
|
||||
append_to_empty(s);
|
||||
append_to_existing(s);
|
||||
missing_last(s);
|
||||
missing_first(s);
|
||||
null_message(s);
|
||||
run_test(s, null_state);
|
||||
}
|
||||
|
||||
// Local Functions
|
||||
|
@ -112,22 +120,112 @@ append_to_existing(TestState *s)
|
|||
print("\t\tfirst_log\n");
|
||||
chk_ptr_eq(
|
||||
s,
|
||||
"ERROR: append_test_log(): first_log:",
|
||||
"ERROR: append_test_log(): append to existing: first_log:",
|
||||
ld.state.first_log,
|
||||
&ld.first
|
||||
);
|
||||
|
||||
a2e_chk_last(s, &ld);
|
||||
chk_last(
|
||||
s,
|
||||
&ld,
|
||||
"ERROR: append_test_log(): append to existing: last_log:"
|
||||
);
|
||||
free(ld.state.last_log);
|
||||
}
|
||||
|
||||
static void
|
||||
a2e_chk_last(TestState *s, LogData *ld)
|
||||
missing_last(TestState *s)
|
||||
{
|
||||
LogData ld;
|
||||
print("\tlast_log missing\n");
|
||||
mk_log_data(&ld);
|
||||
ld.state.last_log = 0;
|
||||
append_test_log(&ld.state, "baz");
|
||||
|
||||
// first shouldn't change
|
||||
print("\t\tfirst_log\n");
|
||||
chk_ptr_eq(
|
||||
s,
|
||||
"ERROR: append_test_log(): last_log missing: first_log:",
|
||||
ld.state.first_log,
|
||||
&ld.first
|
||||
);
|
||||
|
||||
chk_last(
|
||||
s,
|
||||
&ld,
|
||||
"ERROR: append_test_log(): last_log missing: last_log:"
|
||||
);
|
||||
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
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
decl_test(null_state)
|
||||
{
|
||||
append_test_log(0, "foo");
|
||||
return test_success;
|
||||
}
|
||||
|
||||
static void
|
||||
chk_last(TestState *s, LogData *ld, const char *context)
|
||||
{
|
||||
print("\t\tlast_log\n");
|
||||
chk_ptr_chg(
|
||||
s,
|
||||
"\t\t\t",
|
||||
"ERROR: append_test_log(): last_log:",
|
||||
context,
|
||||
ld->state.last_log,
|
||||
&ld->second
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
static void test_pass(TestState *);
|
||||
static void test_fail(TestState *);
|
||||
static void test_pend(TestState *);
|
||||
static void null_state(TestState *);
|
||||
decl_test(null_state);
|
||||
static void null_test(TestState *);
|
||||
decl_test(always_passes);
|
||||
decl_test(always_fails);
|
||||
|
@ -46,7 +46,7 @@ test_run_test(TestState *s)
|
|||
test_pass(s);
|
||||
test_fail(s);
|
||||
test_pend(s);
|
||||
null_state(s);
|
||||
run_test(s, null_state);
|
||||
null_test(s);
|
||||
}
|
||||
|
||||
|
@ -130,13 +130,11 @@ test_pend(TestState *s)
|
|||
);
|
||||
}
|
||||
|
||||
static void
|
||||
null_state(TestState *)
|
||||
decl_test(null_state)
|
||||
{
|
||||
print("\tnull state\n");
|
||||
|
||||
// make sure it doesn't crash
|
||||
run_test(0, always_passes);
|
||||
return test_success;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue
Block a user