Commit Graph

7 Commits

Author SHA1 Message Date
Nicolas Pitre 313e9f2110 tests/unit/cbprintf: another float conversion edge case
It is really bad when you start having doubts about those edge cases
in your sleep. Better have it validated here instead.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2020-12-10 06:46:16 -06:00
Nicolas Pitre cf6fb4dea2 lib: cbprintf: float conversion optimization and documentation
While documenting the float conversion code, I found there was room
for some optimization. In doing so I added test cases to cover edge
cases e.g. making sure proper rounding is applied and that no loss
of precision was introduced. Compiled code should be smaller and
faster.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2020-12-08 14:09:15 -05:00
Nicolas Pitre e4e5e01101 tests/unit/cbprintf: test %p with NULL and justification
Make sure the "(nil)" string is properly aligned.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2020-11-19 12:37:42 +01:00
Nicolas Pitre 0e9a37161e tests/unit/cbprintf: rationalize the code a bit
Factor out the CONFIG_CBPRINTF_LIBC_SUBSTS exception.
Remove redundant lines and obsolete comment.
Make some code pattern more consistent.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2020-11-19 12:37:42 +01:00
Peter Bigot a9e2b10a86 lib: cbprintf: ignore l length modifier on float values
%lf is specified to be the same as %f, and should not be marked as
 invalid.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-17 17:49:22 -05:00
Peter Bigot 607b390ba4 lib: cbprintf: fix pointer justification and padding
Although flags with pointers are not defined behavior, there is a
desire to have them work, so add a test and fix the complete
implementation so it passes.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-17 11:34:25 +01:00
Peter Bigot f80c7bed5c tests: unit: coverage testing for cbprintf
Tests for most paths through the conversion infrastructure.  Expected
output can be validated with the host libc by setting USE_LIBC within
the source.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-11-13 06:38:01 -05:00