Commit 67493c26 authored by Chris Müller's avatar Chris Müller

Add some unittest cases for CryLists.

parent 0ab5f72a
......@@ -91,9 +91,8 @@ test_queue(const_pointer data)
}
static void
test_list(const_pointer data)
test_list_prepend_and_append(const_pointer data)
{
int items[] = { 1, 2, 3, 4, 5 };
struct CryList* list = cry_list_new();
......@@ -131,6 +130,53 @@ test_list(const_pointer data)
}
static void
test_list_iterator(data)
{
int items[] = { 1, 2, 3, 4, 5 };
struct CryList* list = cry_list_new();
cry_list_append(list, items);
cry_list_append(list, items + 1);
cry_list_append(list, items + 2);
cry_list_append(list, items + 3);
cry_list_append(list, items + 4);
struct CryPosition* pos = cry_list_begin(list);
assert(cry_list_prev(pos) == 0);
assert(cry_list_data(pos) == items);
pos = cry_list_next(pos);
assert(cry_list_data(pos) == items + 1);
pos = cry_list_next(pos);
assert(cry_list_data(pos) == items + 2);
pos = cry_list_next(pos);
assert(cry_list_data(pos) == items + 3);
pos = cry_list_next(pos);
assert(cry_list_data(pos) == items + 4);
assert(pos == cry_list_end(list));
assert(cry_list_next(pos) == 0);
cry_list_free(list, 0);
}
static void
test_list(const_pointer data)
{
test_list_prepend_and_append(data);
test_list_iterator(data);
}
cry_test_structures(void)
{
cry_unittest_run("structures.stack", test_stack, 0, 10);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment