From ff8ab43201e5c862003d9353016409c13691562c Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Sat, 8 Feb 2025 22:13:25 +0300 Subject: Changed comments style, added array deletion functions --- tests/arraypop.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/arraypop.c (limited to 'tests/arraypop.c') diff --git a/tests/arraypop.c b/tests/arraypop.c new file mode 100644 index 0000000..fce459f --- /dev/null +++ b/tests/arraypop.c @@ -0,0 +1,25 @@ +#define CONTAINER_IMPLEMENTATION +#include "../include/container.h" + +#include + +int main(int argc, char *argv[]) { + int buf[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + int* a = array_new_buffer_copy(int, buf, 10); + array_pop(a); + array_pop_at(a, 0); + array_pop_at(a, 4); /* should remove 5 */ + for (size_t i = 0; i < array_size(a); ++i) { + printf("array[%zu] = %i\n", i, a[i]); + } + size_t sz = array_size(a); + for (size_t i = 1; i < sz - 1; ++i) { + printf("removing element at index %zu: %i\n", i, a[1]); + array_pop_at(a, 1); + } + for (size_t i = 0; i < array_size(a); ++i) { + printf("array[%zu] = %i\n", i, a[i]); + } + array_pop_at(a, array_size(a) - 1); + array_free(a); +} -- cgit v1.2.3-70-g09d2