1
0
mirror of https://github.com/FreeRTOS/coreMQTT synced 2025-06-22 19:24:20 +08:00
Dakshit Babbar d7b04a1300
Update unit tests to work with asserts enabled (#322)
Description
-----------
This PR solves the Issue #321. 

**Learning:** Unit tests are supposed to be built with asserts enabled
during the development process. But when these are built for coverage
analysis these should be built with asserts disabled. This is because
the lcov tool would consider all the branches in the asserts as
uncovered.

This PR:
1. Update the unit tests to work with asserts enabled
2. Update the code to have 100% branch coverage. To achieve this, one
branch which was logically unreachable, was excluded from the coverage
analysis.
3. Updates the CI checks to build the code with asserts to check if all
the unit tests are working as expected. Along with this it will also
build the code without asserts to check coverage.
4. Updates the command in the README.md that users should use to build
the unit tests. This command has asserts disabled, as asserts are only
required during the development process of the unit tests.

Test Steps
-----------
The unit tests are building and running successfully with asserts. They
also give 100% coverage without asserts.

Checklist:
----------
<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [x] I have tested my changes. No regression in existing tests.
- [x] I have modified and/or added unit-tests to cover the code changes
in this Pull Request.

Related Issue
-----------
#321
<!-- If any, please provide issue ID. -->
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
2025-06-11 14:52:14 +05:30
..