libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 5f85b13c7bd8588e90b8acbafff06ae65c60a85c
parent b3c57e9b87e294aedcb1ae954772a4767d1ddce9
Author: lash <dev@holbrook.no>
Date:   Sat, 22 Mar 2025 22:39:28 +0000

Add set get config test

Diffstat:
Msrc/lq/config.c | 2+-
Msrc/test/test_config.c | 11+++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/lq/config.c b/src/lq/config.c @@ -92,7 +92,7 @@ int lq_config_set(int k, void *v) { l = sizeof(void*); break; case LQ_TYP_STR: - l = strlen((char*)v); + l = strlen((char*)v) + 1; break; case LQ_TYP_NUM: l = sizeof(long*); diff --git a/src/test/test_config.c b/src/test/test_config.c @@ -24,7 +24,7 @@ START_TEST(check_register) { } END_TEST -START_TEST(check_set) { +START_TEST(check_set_get) { int r; long v; char *p; @@ -47,6 +47,13 @@ START_TEST(check_set) { v = *((long*)p); ck_assert_int_eq(v, 42); + r = lq_config_get(2, (void**)&p); + ck_assert_int_eq(r, ERR_OK); + ck_assert_str_eq(p, "foobarbaz"); + + r = lq_config_get(3, (void**)&p); + ck_assert_int_eq(r, ERR_OVERFLOW); + lq_config_free(); } END_TEST @@ -59,7 +66,7 @@ Suite * common_suite(void) { tc = tcase_create("core"); tcase_add_test(tc, check_core); tcase_add_test(tc, check_register); - tcase_add_test(tc, check_set); + tcase_add_test(tc, check_set_get); suite_add_tcase(s, tc); return s;