[PATCH 1/1] test: unit test for hextoull()

Provide a unit test for the hextoull() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- test/str_ut.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/test/str_ut.c b/test/str_ut.c index 96e048975d8..1110971d995 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -18,6 +18,8 @@ static const char str4[] = "1234567890123 I lost closer friends"; static const char str5[] = "0x9876543210the last time I was deloused"; static const char str6[] = "0778octal is seldom used"; static const char str7[] = "707it is a piece of computing history"; +static const char str8[] = "0x887e2561352d80fa"; +static const char str9[] = "614FF7EAA63009DA";
/* Declare a new str test */ #define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) @@ -189,6 +191,22 @@ static int str_hextoul(struct unit_test_state *uts) } STR_TEST(str_hextoul, 0);
+static int str_hextoull(struct unit_test_state *uts) +{ + char *endp; + + /* Just a simple test, since we know this uses simple_strtoull() */ + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, &endp)); + ut_asserteq_64(0x12, endp - str8); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, &endp)); + ut_asserteq_64(0x10, endp - str9); + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, NULL)); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, NULL)); + + return 0; +} +STR_TEST(str_hextoull, 0); + static int str_dectoul(struct unit_test_state *uts) { char *endp;

On Wed, 13 Nov 2024 at 14:15, Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Provide a unit test for the hextoull() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
test/str_ut.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
Thanks

On Wed, Nov 13, 2024 at 10:15:12PM +0100, Heinrich Schuchardt wrote:
Provide a unit test for the hextoull() function.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Heinrich Schuchardt
-
Simon Glass
-
Tom Rini