Skip to content

Improve branch coverage testing for base 64, specifically around preconditions #1836

Closed as not planned

Description

We are at ~80% branch coverage, which could be improved to get closer to ~100%
image

https://dev.azure.com/azure-sdk/public/_build/results?buildId=990064&_a=summary&tab=ms.vss-codecoverage-web.code-coverage-details&view=codecoverage-tab
image

AZ_NODISCARD az_result
az_base64_encode(az_span destination_base64_text, az_span source_bytes, int32_t* out_written)
{
_az_PRECONDITION_VALID_SPAN(destination_base64_text, 4, false);
_az_PRECONDITION_VALID_SPAN(source_bytes, 1, false);
_az_PRECONDITION_NOT_NULL(out_written);

See examples on how to add tests for preconditions here:

#ifndef AZ_NO_PRECONDITION_CHECKING
ENABLE_PRECONDITION_CHECK_TESTS()
static void test_az_iot_hub_client_c2d_parse_received_topic_NULL_client_fail()
{
az_span received_topic = AZ_SPAN_FROM_STR(
"devices/useragent_c/messages/devicebound/$.mid=79eadb01-bd0d-472d-bd35-ccb76e70eab8&$.to=/"
"devices/useragent_c/messages/deviceBound&iothub-ack=full");
az_iot_hub_client_c2d_request out_request;
ASSERT_PRECONDITION_CHECKED(
az_iot_hub_client_c2d_parse_received_topic(NULL, received_topic, &out_request));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Azure.Coregood first issueThis issue tracks work that may be a good starting point for a first-time contributortest-enhancement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions