diff options
author | Simon Glass <sjg@chromium.org> | 2021-07-24 09:03:34 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-08-02 13:32:14 -0400 |
commit | ab833ef60a13b60bfa8e236ca774e91b22255a5a (patch) | |
tree | a600a129038aba8a7e3018c86f9efc3433b2c431 | |
parent | 4d3177d367e89619d22017a96addcfcb498e69a3 (diff) | |
download | u-boot-ab833ef60a13b60bfa8e236ca774e91b22255a5a.tar.gz |
lib: Add octal tests for simple_strtoul/l()
This function support decoding octal but no tests are included yet.
Add some.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | test/str_ut.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/str_ut.c b/test/str_ut.c index 880cc928ec..0d1bf39809 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -17,6 +17,8 @@ static const char str2[] = "1099abNo, don't bother apologising."; static const char str3[] = "0xbI'm sorry you're alive."; 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"; /* Declare a new str test */ #define STR_TEST(_name, _flags) UNIT_TEST(_name, _flags, str_test) @@ -89,6 +91,10 @@ static int str_simple_strtoul(struct unit_test_state *uts) ut_assertok(run_strtoul(uts, str3, 16, 0xb, 3, upper)); ut_assertok(run_strtoul(uts, str3, 10, 0, 1, upper)); + /* Octal */ + ut_assertok(run_strtoul(uts, str6, 0, 63, 3, upper)); + ut_assertok(run_strtoul(uts, str7, 8, 0x1c7, 3, upper)); + /* Invalid string */ ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper)); @@ -140,6 +146,10 @@ static int str_simple_strtoull(struct unit_test_state *uts) ut_assertok(run_strtoull(uts, str3, 16, 0xb, 3, upper)); ut_assertok(run_strtoull(uts, str3, 10, 0, 1, upper)); + /* Octal */ + ut_assertok(run_strtoull(uts, str6, 0, 63, 3, upper)); + ut_assertok(run_strtoull(uts, str7, 8, 0x1c7, 3, upper)); + /* Large values */ ut_assertok(run_strtoull(uts, str4, 10, 1234567890123, 13, upper)); |