summaryrefslogtreecommitdiff
path: root/src/user/app/tests
diff options
context:
space:
mode:
authordzwdz2022-08-03 11:21:20 +0200
committerdzwdz2022-08-03 11:21:20 +0200
commit028cefb9b30240fa0bba6ff030076bd2158a66f4 (patch)
tree82e1b9ccc2146dd94a48796dfb978b66172d199c /src/user/app/tests
parenta2a1e4bbfcda8c1314b592c8c940e96e95cb68d4 (diff)
user/libc: isspace, strtol
Diffstat (limited to 'src/user/app/tests')
-rw-r--r--src/user/app/tests/tests.c21
1 files changed, 21 insertions, 0 deletions
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;
}