aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests/t-mem-pool.c
diff options
context:
space:
mode:
authorSeyi Kuforiji <kuforiji98@gmail.com>2025-01-17 13:29:24 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-17 14:35:11 -0800
commitc143dfa7ed4115d1fd7d23150a0314768377f108 (patch)
treea86502272d33ba3f52d9a400936f21b4a8ede5ef /t/unit-tests/t-mem-pool.c
parentaae2b431b003e7c55a1e359062c8547e6521098f (diff)
downloadgit-c143dfa7ed4115d1fd7d23150a0314768377f108.tar.gz
t/unit-tests: convert mem-pool test to use clar test framework
Adapt the mem-pool test script to use clar framework by using clar assertions where necessary.Test functions are created as a standalone to test different test cases. Mentored-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com> Acked-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests/t-mem-pool.c')
-rw-r--r--t/unit-tests/t-mem-pool.c31
1 files changed, 0 insertions, 31 deletions
diff --git a/t/unit-tests/t-mem-pool.c b/t/unit-tests/t-mem-pool.c
deleted file mode 100644
index fe500c704b..0000000000
--- a/t/unit-tests/t-mem-pool.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "test-lib.h"
-#include "mem-pool.h"
-
-static void setup_static(void (*f)(struct mem_pool *), size_t block_alloc)
-{
- struct mem_pool pool = { .block_alloc = block_alloc };
- f(&pool);
- mem_pool_discard(&pool, 0);
-}
-
-static void t_calloc_100(struct mem_pool *pool)
-{
- size_t size = 100;
- char *buffer = mem_pool_calloc(pool, 1, size);
- for (size_t i = 0; i < size; i++)
- check_int(buffer[i], ==, 0);
- if (!check(pool->mp_block != NULL))
- return;
- check(pool->mp_block->next_free != NULL);
- check(pool->mp_block->end != NULL);
-}
-
-int cmd_main(int argc UNUSED, const char **argv UNUSED)
-{
- TEST(setup_static(t_calloc_100, 1024 * 1024),
- "mem_pool_calloc returns 100 zeroed bytes with big block");
- TEST(setup_static(t_calloc_100, 1),
- "mem_pool_calloc returns 100 zeroed bytes with tiny block");
-
- return test_done();
-}