Commit 5b547677 authored by Chris Müller's avatar Chris Müller

Add tests for list modifiers (swap, remove, replace).

parent deffba65
......@@ -168,11 +168,47 @@ test_list_iterator(data)
}
static void
test_list_operation(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);
assert(cry_list_size(list) == 5);
struct CryPosition* middle = cry_list_index(list, 2);
assert(cry_list_remove(list, middle) == items + 2);
assert(cry_list_size(list) == 4);
struct CryPosition* begin = cry_list_begin(list);
assert(cry_list_data(begin) == items);
assert(cry_list_data(cry_list_step(begin, 1)) == items + 1);
assert(cry_list_data(cry_list_step(begin, 2)) == items + 3);
assert(cry_list_data(cry_list_step(begin, 3)) == items + 4);
assert(cry_list_remove(list, cry_list_begin(list)) == items);
assert(cry_list_remove(list, cry_list_end(list)) == items + 4);
assert(cry_list_size(list) == 2);
cry_list_free(list, 0);
}
static void
test_list(const_pointer data)
{
test_list_prepend_and_append(data);
test_list_iterator(data);
test_list_operation(data);
}
......
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