From: Martin Wilck Date: Thu, 21 Nov 2024 21:52:34 +0000 (+0100) Subject: testsuite: test-hash: add a test for deleting a single element X-Git-Tag: v34~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69e594794c0892194d2e0c779c43aa3379e88671;p=thirdparty%2Fkmod.git testsuite: test-hash: add a test for deleting a single element ...using n_buckets = 32, which will cause a step size of 1. This test fails, and will be fixed by the next commit. Signed-off-by: Martin Wilck Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/257 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/test-hash.c b/testsuite/test-hash.c index cfe5a8e4..1ec820d1 100644 --- a/testsuite/test-hash.c +++ b/testsuite/test-hash.c @@ -171,6 +171,22 @@ static int test_hash_iter_after_del(const struct test *t) DEFINE_TEST(test_hash_iter_after_del, .description = "test hash_iter, after deleting element"); +static int test_hash_del(const struct test *t) +{ + struct hash *h = hash_new(32, NULL); + const char *k1 = "k1"; + const char *v1 = "v1"; + + hash_add(h, k1, v1); + hash_del(h, k1); + + hash_free(h); + + return 0; +} +DEFINE_TEST(test_hash_del, .description = "test add / delete a single element", + .expected_fail = true); + static int test_hash_free(const struct test *t) { struct hash *h = hash_new(8, countfreecalls);