build a struct to represent a sample log
This commit is contained in:
parent
5e8b1b73c7
commit
4ff1aa2d6d
|
@ -27,10 +27,21 @@
|
|||
#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 mk_log_data(LogData *);
|
||||
|
||||
static void chk_ptr_chg(
|
||||
TestState *,
|
||||
|
@ -91,28 +102,18 @@ 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
|
||||
|
@ -121,11 +122,23 @@ append_to_existing(TestState *s)
|
|||
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