summaryrefslogtreecommitdiff
path: root/test/lib/str.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/str.c')
-rw-r--r--test/lib/str.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/lib/str.c b/test/lib/str.c
index 3cc9dfea6aa..48351abc756 100644
--- a/test/lib/str.c
+++ b/test/lib/str.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";
static int str_upper(struct unit_test_state *uts)
{
@@ -186,6 +188,22 @@ static int str_hextoul(struct unit_test_state *uts)
}
LIB_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;
+}
+LIB_TEST(str_hextoull, 0);
+
static int str_dectoul(struct unit_test_state *uts)
{
char *endp;
@@ -206,13 +224,13 @@ static int str_itoa(struct unit_test_state *uts)
ut_asserteq_str("4294967295", simple_itoa(0xffffffff));
/* Use #ifdef here to avoid a compiler warning on 32-bit machines */
-#ifdef CONFIG_PHYS_64BIT
+#ifdef CONFIG_64BIT
if (sizeof(ulong) == 8) {
ut_asserteq_str("9223372036854775807",
simple_itoa((1UL << 63) - 1));
ut_asserteq_str("18446744073709551615", simple_itoa(-1));
}
-#endif /* CONFIG_PHYS_64BIT */
+#endif /* CONFIG_64BIT */
return 0;
}
@@ -226,13 +244,13 @@ static int str_xtoa(struct unit_test_state *uts)
ut_asserteq_str("ffffffff", simple_xtoa(0xffffffff));
/* Use #ifdef here to avoid a compiler warning on 32-bit machines */
-#ifdef CONFIG_PHYS_64BIT
+#ifdef CONFIG_64BIT
if (sizeof(ulong) == 8) {
ut_asserteq_str("7fffffffffffffff",
simple_xtoa((1UL << 63) - 1));
ut_asserteq_str("ffffffffffffffff", simple_xtoa(-1));
}
-#endif /* CONFIG_PHYS_64BIT */
+#endif /* CONFIG_64BIT */
return 0;
}