From d783ab5a3948709f87671c0511bb36260fd37f30 Mon Sep 17 00:00:00 2001 From: Sebastian Goll Date: Tue, 26 Nov 2024 15:01:25 +0100 Subject: [PATCH] test(core): add test for removing keys from UA_KeyValueMap --- tests/check_utils.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/check_utils.c b/tests/check_utils.c index 540f7e8652a..b3f8bccf502 100644 --- a/tests/check_utils.c +++ b/tests/check_utils.c @@ -567,6 +567,22 @@ START_TEST(idOrderString) { ck_assert(UA_NodeId_order(&id_str_d, &id_str_c) == UA_ORDER_MORE); } END_TEST +START_TEST(kvmRemove) { + UA_KeyValueMap *kvm = UA_KeyValueMap_new(); + + UA_UInt16 value_1 = 1; + UA_KeyValueMap_setScalar(kvm, UA_QUALIFIEDNAME(0, "value-1"), (void *)&value_1, + &UA_TYPES[UA_TYPES_UINT16]); + UA_UInt16 value_2 = 2; + UA_KeyValueMap_setScalar(kvm, UA_QUALIFIEDNAME(0, "value-2"), (void *)&value_2, + &UA_TYPES[UA_TYPES_UINT16]); + + UA_KeyValueMap_remove(kvm, UA_QUALIFIEDNAME(0, "value-1")); + ck_assert(UA_KeyValueMap_contains(kvm, UA_QUALIFIEDNAME(0, "value-2"))); + + UA_KeyValueMap_delete(kvm); +} END_TEST + static Suite* testSuite_Utils(void) { Suite *s = suite_create("Utils"); TCase *tc_endpointUrl_split = tcase_create("EndpointUrl_split"); @@ -598,6 +614,10 @@ static Suite* testSuite_Utils(void) { tcase_add_test(tc1, idOrderString); suite_add_tcase(s, tc2); + TCase *tc3 = tcase_create("test keyvaluemap"); + tcase_add_test(tc3, kvmRemove); + suite_add_tcase(s, tc3); + return s; }