Tests for strnlen, checks alignments from up to 16 and buffer sizes up to 64, also checks that passing SIZE_MAX as maxlen, because it can cause a wraparound error if strnlen is incorrect.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
This test looks reasonable.
It might make sense to split SIZE_MAX tests into a separate main test case as it tests a special case of the function.
lib/libc/tests/string/strnlen_test.c | ||
---|---|---|
31 | You should be able to do the memset only once outside of the loop. Note that initialising with ... = { '/' } only sets the first element of the buffer to '/', the others are set to zero. So memset is indeed needed. | |
33 | maxlen should be of type size_t. Use %zu to print a variable of type size_t. | |
96–97 | ||
105–106 | same change here |