test: added test for reserve

This commit is contained in:
2026-04-18 20:34:42 -06:00
parent 8fdd5f3981
commit 1ca3defacc
2 changed files with 52 additions and 10 deletions

View File

@@ -276,7 +276,7 @@ ArrayListErr arraylist_remove_at(ArrayList *arr, size_t index, void *out) {
}
if (arr->len < 1) {
return ARRLIST_OK;
return ARRLIST_EMPTY;
}
if (out != NULL) {
@@ -359,11 +359,9 @@ ArrayListErr arraylist_reserve(ArrayList *arr, size_t size_to_reserve) {
return ARRLIST_NULL_ARG;
}
if (size_to_reserve < 1) {
return ARRLIST_INVALID_CAPACITY;
}
if (arr->capacity + size_to_reserve > SIZE_MAX / arr->elem_size ||
size_to_reserve > SIZE_MAX / arr->elem_size) {
if (arr->capacity + size_to_reserve > SIZE_MAX / arr->elem_size) {
return ARRLIST_ALLOC_OVERFLOW;
}