Compare commits
2 Commits
5e8b1b73c7
...
3d01638da0
Author | SHA1 | Date | |
---|---|---|---|
3d01638da0 | |||
4ff1aa2d6d |
|
@ -27,10 +27,22 @@
|
|||
#include "util.h"
|
||||
#include "append-test-log.h"
|
||||
|
||||
// Local Types
|
||||
|
||||
typedef struct LogData LogData;
|
||||
|
||||
struct LogData
|
||||
{
|
||||
TestState state;
|
||||
TestLogEntry first, second;
|
||||
};
|
||||
|
||||
// Local Prototypes
|
||||
|
||||
static void append_to_empty(TestState *);
|
||||
static void append_to_existing(TestState *);
|
||||
static void a2e_chk_last(TestState *, LogData *);
|
||||
static void mk_log_data(LogData *);
|
||||
|
||||
static void chk_ptr_chg(
|
||||
TestState *,
|
||||
|
@ -91,41 +103,48 @@ append_to_empty(TestState *s)
|
|||
static void
|
||||
append_to_existing(TestState *s)
|
||||
{
|
||||
TestState test;
|
||||
TestLogEntry first, second;
|
||||
LogData ld;
|
||||
print("\tappend to existing\n");
|
||||
|
||||
// build initial state/log
|
||||
mk_sample_state(&test);
|
||||
first.text = "foo";
|
||||
first.next = &second;
|
||||
second.text = "bar";
|
||||
second.next = 0;
|
||||
test.first_log = &first;
|
||||
test.last_log = &second;
|
||||
|
||||
append_test_log(&test, "baz");
|
||||
mk_log_data(&ld);
|
||||
append_test_log(&ld.state, "baz");
|
||||
|
||||
// first shouldn't change
|
||||
print("\t\tfirst_log\n");
|
||||
chk_ptr_eq(
|
||||
s,
|
||||
"ERROR: append_test_log(): first_log:",
|
||||
test.first_log,
|
||||
&first
|
||||
ld.state.first_log,
|
||||
&ld.first
|
||||
);
|
||||
|
||||
// last should change
|
||||
a2e_chk_last(s, &ld);
|
||||
}
|
||||
|
||||
static void
|
||||
a2e_chk_last(TestState *s, LogData *ld)
|
||||
{
|
||||
print("\t\tlast_log\n");
|
||||
chk_ptr_chg(
|
||||
s,
|
||||
"\t\t\t",
|
||||
"ERROR: append_test_log(): last_log:",
|
||||
test.last_log,
|
||||
&second
|
||||
ld->state.last_log,
|
||||
&ld->second
|
||||
);
|
||||
}
|
||||
|
||||
static void
|
||||
mk_log_data(LogData *ld)
|
||||
{
|
||||
mk_sample_state(&ld->state);
|
||||
ld->state.first_log = &ld->first;
|
||||
ld->state.last_log = &ld->second;
|
||||
ld->first.text = "foo";
|
||||
ld->first.next = &ld->second;
|
||||
ld->second.text = "bar";
|
||||
ld->second.next = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
chk_ptr_chg(
|
||||
TestState *s,
|
||||
|
|
Loading…
Reference in New Issue
Block a user