summaryrefslogtreecommitdiff
path: root/src/user/app/tests/libc
diff options
context:
space:
mode:
authordzwdz2022-08-04 23:23:50 +0200
committerdzwdz2022-08-04 23:23:50 +0200
commit749a150e37fbfdaf33a8d6738e95306e6d95e8b5 (patch)
tree73e6191443113be4ec613c30281ce9c56ee7b20a /src/user/app/tests/libc
parentce00d1677d7a419b427e7f11963eee982a55a231 (diff)
move the kernel util tests to userland
Diffstat (limited to 'src/user/app/tests/libc')
-rw-r--r--src/user/app/tests/libc/string.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/user/app/tests/libc/string.c b/src/user/app/tests/libc/string.c
index 8f889dc..82aff98 100644
--- a/src/user/app/tests/libc/string.c
+++ b/src/user/app/tests/libc/string.c
@@ -1,6 +1,32 @@
#include "../tests.h"
#include <string.h>
+static void test_memcmp(void) {
+ test(0 == memcmp("some", "thing", 0));
+ test(0 != memcmp("some", "thing", 1));
+ test(0 != memcmp("some", "thing", 4));
+
+ test(0 == memcmp("test", "tennis", 0));
+ test(0 == memcmp("test", "tennis", 1));
+ test(0 == memcmp("test", "tennis", 2));
+ test(0 != memcmp("test", "tennis", 3));
+ test(0 != memcmp("test", "tennis", 4));
+ test(0 != memcmp("test", "tennis", 5));
+
+ test(0 > memcmp("foo", "moo", 4));
+ test(0 < memcmp("moo", "foo", 4));
+ test(0 > memcmp("555", "654", 3));
+ test(0 < memcmp("654", "555", 3));
+}
+
+static void test_strcmp(void) {
+ test(0 == strcmp("string", "string"));
+ test(0 > strcmp("str", "string"));
+ test(0 < strcmp("string", "str"));
+
+ test(0 != strcmp("stress", "string"));
+}
+
static void test_strtol(void) {
char *end;
test(1234 == strtol("1234", NULL, 10));
@@ -21,5 +47,7 @@ static void test_strtol(void) {
}
void r_libc_string(void) {
+ run_test(test_memcmp);
+ run_test(test_strcmp);
run_test(test_strtol);
}