tests: Slightly increase coverage of fmt unittests#20198
Merged
benpicco merged 1 commit intoRIOT-OS:masterfrom Jan 2, 2024
Merged
tests: Slightly increase coverage of fmt unittests#20198benpicco merged 1 commit intoRIOT-OS:masterfrom
benpicco merged 1 commit intoRIOT-OS:masterfrom
Conversation
Teufelchen1
commented
Dec 19, 2023
| byte = fmt_hex_byte("00"); | ||
| TEST_ASSERT_EQUAL_INT(0x00, byte); | ||
|
|
||
| memcpy(hex, "12", 2); |
Contributor
Author
There was a problem hiding this comment.
I wasn't sure about the purpose of these memcpy, can someone enlighten me?
benpicco
approved these changes
Jan 2, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-fmtunit 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 aNULLpointer 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.hwas clarified and a missing statement was added.Thanks, 🐮
Testing procedure
make -C tests/unittests/ tests-fmt testIssues/PRs references
Most tests touched were introduced in #8343