Add dynamic arrays
This commit is contained in:
@@ -9,4 +9,7 @@ add_executable(cute_tiled_test cute_tiled_test.c)
|
||||
target_link_libraries(cute_tiled_test LINK_PRIVATE Breeze)
|
||||
|
||||
add_executable(heap_test heap_test.c)
|
||||
target_link_libraries(heap_test LINK_PRIVATE Breeze)
|
||||
target_link_libraries(heap_test LINK_PRIVATE Breeze)
|
||||
|
||||
add_executable(array_test array_test.c)
|
||||
target_link_libraries(array_test LINK_PRIVATE Breeze)
|
||||
|
||||
52
engine/tests/array_test.c
Normal file
52
engine/tests/array_test.c
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <breeze.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
bzLoggerInit();
|
||||
int *arr = bzArrayNew(int, 5);
|
||||
|
||||
int i, j;
|
||||
|
||||
BZ_ASSERT(bzArraySize(arr) == 0);
|
||||
for (i = 0; i < 20000; i += 50) {
|
||||
for (j = 0; j < i; ++j)
|
||||
bzArrayPush(arr, j);
|
||||
bzArrayFree(arr);
|
||||
arr = bzArrayNew(int, 5);
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
bzArrayPush(arr, 1);
|
||||
bzArrayPush(arr, 2);
|
||||
bzArrayPush(arr, 3);
|
||||
bzArrayPush(arr, 4);
|
||||
bzArrayDel(arr, i);
|
||||
bzArrayFree(arr);
|
||||
arr = bzArrayNew(int, 5);
|
||||
bzArrayPush(arr, 1);
|
||||
bzArrayPush(arr, 2);
|
||||
bzArrayPush(arr, 3);
|
||||
bzArrayPush(arr, 4);
|
||||
//darray_delswap(arr, i);
|
||||
bzArrayFree(arr);
|
||||
arr = bzArrayNew(int, 5);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; ++i) {
|
||||
bzArrayPush(arr, 1);
|
||||
bzArrayPush(arr, 2);
|
||||
bzArrayPush(arr, 3);
|
||||
bzArrayPush(arr, 4);
|
||||
bzArrayIns(arr, i, 5);
|
||||
BZ_ASSERT(arr[i] == 5);
|
||||
if (i < 4)
|
||||
BZ_ASSERT(arr[4] == 4);
|
||||
bzArrayFree(arr);
|
||||
arr = bzArrayNew(int, 5);
|
||||
}
|
||||
bzArrayFree(arr);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user