diff options
author | justanothercatgirl <sotov@twistea.su> | 2025-02-08 22:13:25 +0300 |
---|---|---|
committer | justanothercatgirl <sotov@twistea.su> | 2025-02-08 22:13:25 +0300 |
commit | ff8ab43201e5c862003d9353016409c13691562c (patch) | |
tree | d186e830acfbc21b5cc771ce58a1cc09c0e7610c /tests/arraypop.c | |
parent | e14c6bc3801be29eb5a64c813754b170a67d4956 (diff) |
Changed comments style, added array deletion functions
Diffstat (limited to 'tests/arraypop.c')
-rw-r--r-- | tests/arraypop.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 <stdio.h> + +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); +} |