diff options
| author | Simon Glass <[email protected]> | 2022-04-24 23:30:55 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2022-04-25 10:00:03 -0400 |
| commit | 18436c74dce29a74e996d5932ba01e0cd3481326 (patch) | |
| tree | e20529fb59ac1e1013097b136de255ea1e9c790e /test | |
| parent | 2fa4756d03a377dd0a6e943d2a16f4e2c9c97342 (diff) | |
test: Add tests for trailing_strtol()
This function currently has no tests. Add some.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'test')
| -rw-r--r-- | test/str_ut.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/str_ut.c b/test/str_ut.c index 6c817f6f72f..9674a59f2a6 100644 --- a/test/str_ut.c +++ b/test/str_ut.c @@ -242,6 +242,25 @@ static int str_xtoa(struct unit_test_state *uts) } STR_TEST(str_xtoa, 0); +static int str_trailing(struct unit_test_state *uts) +{ + char str1[] = "abc123def"; + + ut_asserteq(-1, trailing_strtol("")); + ut_asserteq(-1, trailing_strtol("123")); + ut_asserteq(123, trailing_strtol("abc123")); + ut_asserteq(4, trailing_strtol("12c4")); + ut_asserteq(-1, trailing_strtol("abd")); + ut_asserteq(-1, trailing_strtol("abc123def")); + + ut_asserteq(-1, trailing_strtoln(str1, NULL)); + ut_asserteq(123, trailing_strtoln(str1, str1 + 6)); + ut_asserteq(-1, trailing_strtoln(str1, str1 + 9)); + + return 0; +} +STR_TEST(str_trailing, 0); + int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(str_test); |
