Skip to content

Commit

Permalink
test(core): add test for removing keys from UA_KeyValueMap
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoll authored and jpfr committed Nov 26, 2024
1 parent 8211771 commit d783ab5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/check_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit d783ab5

Please sign in to comment.