From 13d33be824a0f6a3952045df7b97b35fc69520a8 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 22 Aug 2025 16:12:08 +0300 Subject: cover all functions + Not quite all lines due to sptree being dumb >:((((( --- tests/vec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/vec.c') 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 +/* 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); } -- cgit v1.2.3