mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
@@ -3,33 +3,33 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int test_resizeArray() {
|
||||
//test single pointer
|
||||
int test_array() {
|
||||
//test allocation and free
|
||||
{
|
||||
Toy_Array* array = TOY_ALLOCATE_ARRAY(int, 1);
|
||||
TOY_FREE_ARRAY(int, array);
|
||||
Toy_Array* array = Toy_resizeArray(NULL, 1);
|
||||
array = Toy_resizeArray(array, 0);
|
||||
}
|
||||
|
||||
//test single pointer array
|
||||
//test initial data
|
||||
{
|
||||
Toy_Array* array = TOY_ALLOCATE_ARRAY(int, 10);
|
||||
Toy_Array* array = Toy_resizeArray(NULL, 10);
|
||||
|
||||
//check you can access the memory
|
||||
array->data[1] = 42;
|
||||
array->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
|
||||
TOY_FREE_ARRAY(int, array);
|
||||
Toy_resizeArray(array, 0);
|
||||
}
|
||||
|
||||
//test multiple pointer arrays
|
||||
//test multiple arrays (no overlaps or conflicts)
|
||||
{
|
||||
Toy_Array* array1 = TOY_ALLOCATE_ARRAY(int, 10);
|
||||
Toy_Array* array2 = TOY_ALLOCATE_ARRAY(int, 10);
|
||||
Toy_Array* array1 = Toy_resizeArray(NULL, 10);
|
||||
Toy_Array* array2 = Toy_resizeArray(NULL, 10);
|
||||
|
||||
array1->data[1] = 42; //access the given memory
|
||||
array2->data[1] = 42; //access the given memory
|
||||
array1->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
array2->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
|
||||
TOY_FREE_ARRAY(int, array1);
|
||||
TOY_FREE_ARRAY(int, array2);
|
||||
Toy_resizeArray(array1, 0);
|
||||
Toy_resizeArray(array2, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -40,7 +40,7 @@ int main() {
|
||||
int total = 0, res = 0;
|
||||
|
||||
{
|
||||
res = test_resizeArray();
|
||||
res = test_array();
|
||||
total += res;
|
||||
|
||||
if (res == 0) {
|
||||
|
||||
Reference in New Issue
Block a user