aboutsummaryrefslogtreecommitdiffstats
path: root/tests/arraypop.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arraypop.c')
-rw-r--r--tests/arraypop.c25
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);
+}