Remaining asserts with functional effects
Description
There remains assert
that have function call with side effects.
csrc/opcua_types/sopc_encodeable.c:82: assert(SOPC_Encodeable_Delete(encTyp, encObject) == SOPC_STATUS_OK);
csrc/services/b2c/msg_browse_response_bs.c:assert(true ==
util_NodeClass__B_to_C(msg_browse_response_bs__p_NodeClass,
&ppResNodeClass[msg_browse_response_bs__p_bvi][msg_browse_response_bs__p_bri]))
tests/secure_channels/event_recorder.c:64: assert(SOPC_AsyncQueue_BlockingEnqueue(queue, ev) == SOPC_STATUS_OK);
tests/helpers/check_users.c:139: assert(SOPC_STATUS_OK == SOPC_NodeId_Compare(nodeId, &authorizedNodeId, &cmpNid));
tests/helpers/check_numeric_range.c:33: assert(SOPC_Array_Append_Values(str, text, len));
tests/helpers/check_numeric_range.c:67: assert(SOPC_Array_Append(str, end));
tests/helpers/check_event_handler.c:54: assert(SOPC_AsyncQueue_BlockingEnqueue(queue, ev) == SOPC_STATUS_OK);
tests/helpers/check_event_handler.c:65: assert(SOPC_AsyncQueue_BlockingDequeue(queue, (void**) &ev) == SOPC_STATUS_OK);
tests/helpers/check_event_handler.c:128: assert(SOPC_AsyncQueue_Init(&queue, "") == SOPC_STATUS_OK);
The list in not exhaustive on the test side.
In csrc
and tests/secure_channels
, the assert must be split and the assert should be done on the function result.
In tests/helpers
, the assert
can be replaced by ck_assert
.
Moreover, some asserts are expected to be triggered in unit tests, but asserts that are removed at compile time cannot pass such tests (see https://gitlab.com/systerel/S2OPC/blob/master/tests/helpers/check_dict.c#L396).
Edited by Pierre-Antoine BRAMERET