further cleanup and organization
This commit is contained in:
27
test/array.c
Normal file
27
test/array.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#define L_ARRAY_IMPLEMENTATION
|
||||
#include "../include/array.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int test_l_array() {
|
||||
int RETURN_CODE = 0;
|
||||
printf("test_l_array() : ");
|
||||
|
||||
LArray* array = l_array_create();
|
||||
|
||||
int number_1 = 5;
|
||||
int number_2 = 15;
|
||||
|
||||
l_array_append(array, &number_2);
|
||||
l_array_append(array, &number_1);
|
||||
|
||||
if (*(int*)array->items[0] != 15) RETURN_CODE++;
|
||||
if (*(int*)array->items[1] != 5) RETURN_CODE++;
|
||||
if (array->count != 2) RETURN_CODE++;
|
||||
if (array->capacity != 8) RETURN_CODE++;
|
||||
|
||||
l_array_clear(array);
|
||||
if (array->items != NULL) RETURN_CODE++;
|
||||
|
||||
printf("%d\n", RETURN_CODE);
|
||||
return RETURN_CODE;
|
||||
}
|
||||
37
test/test.c
37
test/test.c
@@ -1,31 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#define L_ARRAY_IMPLEMENTATION
|
||||
#include "../include/array.h"
|
||||
#include "assert.h"
|
||||
#include "../include/version.h"
|
||||
|
||||
#define TEST_FUNCTION
|
||||
|
||||
static int test_l_array() {
|
||||
int RETURN_CODE = 0;
|
||||
|
||||
LArray* array = l_array_create();
|
||||
|
||||
int number_1 = 5;
|
||||
int number_2 = 15;
|
||||
|
||||
l_array_append(array, &number_2);
|
||||
l_array_append(array, &number_1);
|
||||
|
||||
assert(*(int*)array->items[0] == 15);
|
||||
assert(*(int*)array->items[1] == 5);
|
||||
assert(array->count == 2);
|
||||
assert(array->capacity == 8);
|
||||
|
||||
l_array_clear(array);
|
||||
assert(array->items == NULL);
|
||||
|
||||
return RETURN_CODE;
|
||||
}
|
||||
int test_l_array();
|
||||
|
||||
int main(void) {
|
||||
printf("AUTHOR: %s\n", L_TYPES_AUTHOR);
|
||||
@@ -33,9 +9,10 @@ int main(void) {
|
||||
printf("VERSION: %s\n", L_TYPES_VERSION);
|
||||
printf("LICENSE: %s\n\n", L_TYPES_LICENSE);
|
||||
|
||||
int RETURN_CODE = 0;
|
||||
|
||||
if (
|
||||
test_l_array()
|
||||
) return 1;
|
||||
return 0;
|
||||
RETURN_CODE += test_l_array();
|
||||
|
||||
printf("\nError Total: %d\n", RETURN_CODE);
|
||||
return RETURN_CODE;
|
||||
}
|
||||
Reference in New Issue
Block a user