Commit 4817a3af authored by Chris Müller's avatar Chris Müller

Move tests for data structures in its own files

parent 28bf64eb
......@@ -2,6 +2,7 @@ set(TEST crystal_unittests)
set(SOURCES
main.c
array.c
structures.c
)
......
#include "unittest.h"
#include "structures/array.h"
#include <assert.h>
static void
test_array(const_pointer data)
{
int items[] = { 1, 2, 3, 4, 5 };
struct CryArray* array = cry_array_new(sizeof(int), 4, 8);
assert(cry_array_size(array) == 0);
assert(cry_array_elementsize(array) == sizeof(int));
assert(cry_array_alloc(array) == 4);
cry_array_append(array, items);
assert(cry_array_size(array) == 1);
cry_array_append(array, items + 1);
assert(cry_array_size(array) == 2);
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);
}
void
cry_test_arrays(void)
{
cry_unittest_run("structures.array.allocation", test_array, 0, 10);
}
#include "unittest.h"
void cry_test_matrix();
void cry_test_structures();
void cry_test_arrays();
int
main(int argc, char** argv)
......@@ -10,6 +10,7 @@ main(int argc, char** argv)
cry_unittest_initialize(argc, argv);
cry_test_structures();
cry_test_arrays();
cry_unittest_finalize();
......
......@@ -3,6 +3,7 @@
#include "structures/list.h"
#include "structures/stack.h"
#include "structures/queue.h"
#include "structures/array.h"
static void
......@@ -203,6 +204,7 @@ test_list_operation(data)
}
static void
test_list(const_pointer data)
{
......@@ -212,7 +214,7 @@ test_list(const_pointer data)
}
void
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