mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Expanded array tests, read more
Getting the array's length is still not available yet, so I'm not marking arrays as done - but everything that is there is tested. I've also tweaked the assert output callbacks to also print 'assert failure'.
This commit is contained in:
@@ -6,30 +6,30 @@
|
||||
int test_array() {
|
||||
//test allocation and free
|
||||
{
|
||||
Toy_Array* array = Toy_resizeArray(NULL, 1);
|
||||
array = Toy_resizeArray(array, 0);
|
||||
Toy_Array* array = TOY_ARRAY_ALLOCATE();
|
||||
TOY_ARRAY_FREE(array);
|
||||
}
|
||||
|
||||
//test initial data
|
||||
{
|
||||
Toy_Array* array = Toy_resizeArray(NULL, 10);
|
||||
Toy_Array* array = TOY_ARRAY_ALLOCATE();
|
||||
|
||||
//check you can access the memory
|
||||
array->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
|
||||
Toy_resizeArray(array, 0);
|
||||
TOY_ARRAY_FREE(array);
|
||||
}
|
||||
|
||||
//test multiple arrays (no overlaps or conflicts)
|
||||
{
|
||||
Toy_Array* array1 = Toy_resizeArray(NULL, 10);
|
||||
Toy_Array* array2 = Toy_resizeArray(NULL, 10);
|
||||
Toy_Array* array1 = TOY_ARRAY_ALLOCATE();
|
||||
Toy_Array* array2 = TOY_ARRAY_ALLOCATE();
|
||||
|
||||
array1->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
array2->data[1] = TOY_VALUE_FROM_INTEGER(42);
|
||||
|
||||
Toy_resizeArray(array1, 0);
|
||||
Toy_resizeArray(array2, 0);
|
||||
TOY_ARRAY_FREE(array1);
|
||||
TOY_ARRAY_FREE(array2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user