summaryrefslogtreecommitdiff
path: root/tests/vec.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-08-22 16:12:08 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2025-08-22 16:12:08 +0300
commit13d33be824a0f6a3952045df7b97b35fc69520a8 (patch)
treef2f36de33eeb0e9d366ea49bd722993ba57950b1 /tests/vec.c
parentb0d619e2c9595f4ec05463e87be9d0d3423c0a70 (diff)
downloadconts-13d33be824a0f6a3952045df7b97b35fc69520a8.tar.gz
conts-13d33be824a0f6a3952045df7b97b35fc69520a8.zip
cover all functionsHEADmaster
+ Not quite all lines due to sptree being dumb >:(((((
Diffstat (limited to 'tests/vec.c')
-rw-r--r--tests/vec.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/vec.c b/tests/vec.c
index 8531b14..1ed5f72 100644
--- a/tests/vec.c
+++ b/tests/vec.c
@@ -14,6 +14,12 @@
#include <conts/vec.h>
+/* used for sorting testing */
+static int int_comp(int *a, int *b)
+{
+ return *a - *b;
+}
+
int main()
{
#if defined(COVERAGE)
@@ -55,10 +61,32 @@ int main()
* maybe fails?) */
ints_shrink(&ints, 1000000);
+ /* so the above is equivalent to */
+ assert(ints_reserve(&ints, 1000000));
+ assert(ints_len(&ints) == 1000000);
+
for (int i = 1000000 - 1; i >= 0; --i) {
ints_remove(&ints, i);
}
assert(ints_len(&ints) == 0);
+ /* test out resetting as well */
+ assert(ints_reserve(&ints, 10));
+ assert(ints_len(&ints) == 10);
+
+ ints_reset(&ints);
+ assert(ints_len(&ints) == 0);
+
+ /* try out sorting and special accesses */
+ ints_append(&ints, 3);
+ ints_append(&ints, 2);
+ ints_append(&ints, 1);
+
+ ints_sort(&ints, int_comp);
+
+ assert(*ints_back(&ints) == 3);
+ assert(*ints_pop(&ints) == 3);
+ assert(*ints_back(&ints) == 2);
+
ints_destroy(&ints);
}