Commit cf8cc7b6 authored by Chris Müller's avatar Chris Müller

test: add array test_cases for test environment.

parent 523d8156
......@@ -3,33 +3,25 @@
#include <assert.h>
static void
test_array(const_pointer data)
test_array_allocation(const_pointer data)
{
int items[] = { 1, 2, 3, 4, 5 };
struct CryArray* array = cry_array_new(sizeof(int), 4, 8);
char text[] = { 'A', 'B', 'C', 'D', 'E' };
struct CryArray* array = cry_array_new(2, 4);
assert(cry_array_size(array) == 0);
assert(cry_array_elementsize(array) == sizeof(int));
assert(cry_array_alloc(array) == 4);
assert(cry_array_alloc(array) == 4);
cry_array_append(array, items);
cry_array_append(array, text, 2);
assert(cry_array_size(array) == 1);
assert(cry_array_size(array) == 2);
assert(cry_array_alloc(array) == 4);
cry_array_append(array, items + 1);
cry_array_append(array, text + 2, 3);
assert(cry_array_size(array) == 2);
assert(cry_array_size(array) == 5);
assert(cry_array_alloc(array) == 8);
cry_array_append_range(array, items + 2, 2);
assert(cry_array_size(array) == 4);
assert(cry_array_alloc(array) == 4);
cry_array_append(array, items + 4);
assert(cry_array_alloc(array) == 12);
cry_array_free(array);
cry_array_free(array);
}
......@@ -37,5 +29,5 @@ test_array(const_pointer data)
void
cry_test_arrays(void)
{
cry_unittest_run("structures.array.allocation", test_array, 0, 10);
cry_unittest_run("structures.array.allocation", test_array_allocation, 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