From 028cefb9b30240fa0bba6ff030076bd2158a66f4 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 3 Aug 2022 11:21:20 +0200 Subject: user/libc: isspace, strtol --- src/user/app/tests/tests.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/user/app/tests') diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c index f8abc49..d655ab9 100644 --- a/src/user/app/tests/tests.c +++ b/src/user/app/tests/tests.c @@ -237,6 +237,26 @@ static void test_execbuf(void) { test_fail(); } +static void test_strtol(void) { + char *end; + assert(1234 == strtol("1234", NULL, 10)); + assert(1234 == strtol("+1234", NULL, 10)); + assert(-1234 == strtol("-1234", NULL, 10)); + + assert(1234 == strtol("1234", &end, 10)); + assert(!strcmp("", end)); + assert(1234 == strtol(" 1234hello", &end, 10)); + assert(!strcmp("hello", end)); + + assert(1234 == strtol(" 1234hello", &end, 0)); + assert(!strcmp("hello", end)); + assert(0xCAF3 == strtol(" 0xCaF3hello", &end, 0)); + assert(!strcmp("hello", end)); + assert(01234 == strtol(" 01234hello", &end, 0)); + assert(!strcmp("hello", end)); + +} + static void test_misc(void) { assert(_syscall(~0, 0, 0, 0, 0, 0) < 0); /* try making an invalid syscall */ } @@ -255,6 +275,7 @@ int main(void) { run_forked(test_efault); run_forked(test_execbuf); run_forked(test_printf); + run_forked(test_strtol); run_forked(test_misc); return 1; } -- cgit v1.2.3