diff options
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/shell/parser.c | 4 | ||||
-rw-r--r-- | src/user/app/tests/tests.c | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/user/app/shell/parser.c b/src/user/app/shell/parser.c index 31c45d1..072c720 100644 --- a/src/user/app/shell/parser.c +++ b/src/user/app/shell/parser.c @@ -2,10 +2,6 @@ #include <stdbool.h> #include <string.h> -static bool isspace(char c) { - return c == ' ' || c == '\t' || c == '\n'; -} - static char skipspace(char **sp) { char *s = *sp; while (*s && isspace(*s)) s++; 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; } |