diff options
author | Simon Glass <sjg@chromium.org> | 2021-10-14 12:48:06 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-11-11 19:02:32 -0500 |
commit | 3bfb0f719a196558f909ca568f3803f86a190509 (patch) | |
tree | 27b04d170f53130ec20a7d5087f0e075ac52b8e3 /test | |
parent | 74b7a2b8815cf953ea0b72800bd9db7f0d6a119a (diff) | |
download | u-boot-3bfb0f719a196558f909ca568f3803f86a190509.tar.gz |
lib: Add tests for simple_itoa()
Add test and a comment for this function.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/print_ut.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/print_ut.c b/test/print_ut.c index 11d8580e55..4fbb15b6d3 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -10,6 +10,7 @@ #include <log.h> #include <mapmem.h> #include <version_string.h> +#include <vsprintf.h> #include <test/suites.h> #include <test/test.h> #include <test/ut.h> @@ -328,6 +329,22 @@ static int print_do_hex_dump(struct unit_test_state *uts) } PRINT_TEST(print_do_hex_dump, UT_TESTF_CONSOLE_REC); +static int print_itoa(struct unit_test_state *uts) +{ + ut_asserteq_str("123", simple_itoa(123)); + ut_asserteq_str("0", simple_itoa(0)); + ut_asserteq_str("2147483647", simple_itoa(0x7fffffff)); + ut_asserteq_str("4294967295", simple_itoa(0xffffffff)); + if (sizeof(ulong) == 8) { + ut_asserteq_str("9223372036854775807", + simple_itoa((1UL << 63) - 1)); + ut_asserteq_str("18446744073709551615", simple_itoa(-1)); + } + + return 0; +} +PRINT_TEST(print_itoa, 0); + int do_ut_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(print_test); |