aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/arraypop.c25
-rw-r--r--tests/binary_search.c1
-rw-r--r--tests/dynarray.c1
-rw-r--r--tests/dynarray_struct.c1
-rw-r--r--tests/hashset.c1
-rw-r--r--tests/hmap.c1
-rw-r--r--tests/linked_list.c1
-rw-r--r--tests/log.c1
-rw-r--r--tests/obscure.c1
-rw-r--r--tests/types.c1
10 files changed, 34 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);
+}
diff --git a/tests/binary_search.c b/tests/binary_search.c
index ce35d14..425cd1e 100644
--- a/tests/binary_search.c
+++ b/tests/binary_search.c
@@ -31,3 +31,4 @@ int main(void) {
}
return EXIT_SUCCESS;
}
+/* vim: set ts=8 noet: */
diff --git a/tests/dynarray.c b/tests/dynarray.c
index 3312234..b36f0c5 100644
--- a/tests/dynarray.c
+++ b/tests/dynarray.c
@@ -100,3 +100,4 @@ exit_fail:
array_free(test_arr);
exit(EXIT_FAILURE);
}
+/* vim: set ts=8 noet: */
diff --git a/tests/dynarray_struct.c b/tests/dynarray_struct.c
index 7675ab4..7cc6e92 100644
--- a/tests/dynarray_struct.c
+++ b/tests/dynarray_struct.c
@@ -38,3 +38,4 @@ int main(void)
array_free(points);
return 0;
}
+/* vim: set ts=8 noet: */
diff --git a/tests/hashset.c b/tests/hashset.c
index b438d22..45ae57a 100644
--- a/tests/hashset.c
+++ b/tests/hashset.c
@@ -70,3 +70,4 @@ int main(void) {
hset_free(&set);
return retval;
}
+/* vim: set ts=8 noet: */
diff --git a/tests/hmap.c b/tests/hmap.c
index 920c854..7336082 100644
--- a/tests/hmap.c
+++ b/tests/hmap.c
@@ -103,3 +103,4 @@ int main(void) {
}
return 0;
}
+/* vim: set ts=8 noet: */
diff --git a/tests/linked_list.c b/tests/linked_list.c
index 7068e83..d7e2cf3 100644
--- a/tests/linked_list.c
+++ b/tests/linked_list.c
@@ -46,3 +46,4 @@ int main(void) {
ll_free(&list_2);
return 0;
}
+/* vim: set ts=8 noet: */
diff --git a/tests/log.c b/tests/log.c
index e4d1c1e..1db1406 100644
--- a/tests/log.c
+++ b/tests/log.c
@@ -20,3 +20,4 @@ int main() {
urmom();
LCRIT(1, "This is considered critical");
}
+/* vim: set ts=8 noet: */
diff --git a/tests/obscure.c b/tests/obscure.c
index 7b6f1fd..6c567fb 100644
--- a/tests/obscure.c
+++ b/tests/obscure.c
@@ -22,3 +22,4 @@ int main(void) {
return (data[0][69] == 42 && data[1][42] == 69 ? 0 : 1);
// OS will free it for me
}
+/* vim: set ts=8 noet: */
diff --git a/tests/types.c b/tests/types.c
index 94d6cbe..f8615f7 100644
--- a/tests/types.c
+++ b/tests/types.c
@@ -34,3 +34,4 @@ i32 main(void) {
return (j == -1 && i+1 == 0 ? 0 : 1);
}
+/* vim: set ts=8 noet: */