tests: Slightly increase coverage of fmt unittests #20198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
Hello 🦙
this adds a few new test cases to the
tests-fmt
unit tests.The changes only apply to these functions:
fmt_is_digit()
fmt_is_upper()
fmt_is_number()
fmt_byte_hex()
fmt_bytes_hex()
fmt_bytes_hex_reverse()
fmt_hex_byte()
fmt_hex_bytes()
I found the behavior of
fmt_bytes_hex_reverse()
to be not conform with the API description. In this case, a null-pointer de-reference could be triggered while complying with the API, by passing aNULL
pointer as the output buffer. A search through the code base returned only few usage of this function and none of it was affected. I applied a fix and also moved the function closer to its relativefmt_bytes_hex()
, thereby mimicking the order present infmt.h
. As an extra, I refactored the function to look even more similar to its relative.In addition, one statement in the API of
fmt_hex_byte()
infmt.h
was clarified and a missing statement was added.Thanks, 🐮
Testing procedure
make -C tests/unittests/ tests-fmt test
Issues/PRs references
Most tests touched were introduced in #8343