summaryrefslogtreecommitdiff
path: root/src/user/app/tests/libc/string.c
diff options
context:
space:
mode:
authordzwdz2022-08-04 21:43:38 +0200
committerdzwdz2022-08-04 21:43:38 +0200
commit26dc784103914b9d6ba36e0a96fa4b3af977626f (patch)
treed1c9938bac9426d4f6709344315d845b45b20865 /src/user/app/tests/libc/string.c
parent81a58004d51547d074b4218f906b0b95f2b2c5dc (diff)
user/tests: split the tests by parts of codebase
Diffstat (limited to 'src/user/app/tests/libc/string.c')
-rw-r--r--src/user/app/tests/libc/string.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/user/app/tests/libc/string.c b/src/user/app/tests/libc/string.c
new file mode 100644
index 0000000..8f889dc
--- /dev/null
+++ b/src/user/app/tests/libc/string.c
@@ -0,0 +1,25 @@
+#include "../tests.h"
+#include <string.h>
+
+static void test_strtol(void) {
+ char *end;
+ test(1234 == strtol("1234", NULL, 10));
+ test(1234 == strtol("+1234", NULL, 10));
+ test(-1234 == strtol("-1234", NULL, 10));
+
+ test(1234 == strtol("1234", &end, 10));
+ test(!strcmp("", end));
+ test(1234 == strtol(" 1234hello", &end, 10));
+ test(!strcmp("hello", end));
+
+ test(1234 == strtol(" 1234hello", &end, 0));
+ test(!strcmp("hello", end));
+ test(0xCAF3 == strtol(" 0xCaF3hello", &end, 0));
+ test(!strcmp("hello", end));
+ test(01234 == strtol(" 01234hello", &end, 0));
+ test(!strcmp("hello", end));
+}
+
+void r_libc_string(void) {
+ run_test(test_strtol);
+}