aboutsummaryrefslogtreecommitdiff
path: root/libc/test
diff options
context:
space:
mode:
Diffstat (limited to 'libc/test')
-rw-r--r--libc/test/run-memops-test.c16
-rw-r--r--libc/test/run-memops.c17
2 files changed, 33 insertions, 0 deletions
diff --git a/libc/test/run-memops-test.c b/libc/test/run-memops-test.c
index 0979994..429cfdc 100644
--- a/libc/test/run-memops-test.c
+++ b/libc/test/run-memops-test.c
@@ -41,3 +41,19 @@
#include "../string/strncpy.c"
#include "../string/strstr.c"
#include "../string/strtok.c"
+#include <stdlib.h>
+
+int test_memset(char* buf, int c, size_t s);
+
+int test_memset(char* buf, int c, size_t s)
+{
+ int i;
+ int r= 0;
+
+ memset(buf, c, s);
+ for(i=0; i<s; i++)
+ if (buf[i] != c)
+ r = -1;
+
+ return r;
+}
diff --git a/libc/test/run-memops.c b/libc/test/run-memops.c
index 15ec9bd..80822df 100644
--- a/libc/test/run-memops.c
+++ b/libc/test/run-memops.c
@@ -21,7 +21,24 @@
#include <string.h>
#include <stdio.h>
+int test_memset(char* buf, int c, size_t s);
+
int main(void)
{
+ char* buf;
+
+ buf = malloc(100);
+ assert(test_memset(buf, 0x42, 100) == 0);
+ free(buf);
+
+ buf = malloc(128);
+ assert(test_memset(buf, 0, 128) == 0);
+ assert(test_memset(buf+1, 0, 127) == 0);
+ free(buf);
+
+ buf = malloc(1024);
+ assert(test_memset(buf, 0, 1024) == 0);
+ free(buf);
+
return 0;
}