commit 56d760c5cb1c07dfa409742d51f836792a09d824
parent aceef734bdfe4f68e2227fc9ac636aae8235fa12
Author: jvoisin <julien.voisin@dustri.org>
Date: Thu, 13 Apr 2023 22:51:15 +0200
Add tests for memset
Diffstat:
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/tests/Makefile b/tests/Makefile
@@ -8,7 +8,9 @@ TARGETS=test_memcpy_static_write \
test_memmove_static_write \
test_memmove_dynamic_write \
test_memmove_static_read \
- test_memmove_dynamic_read
+ test_memmove_dynamic_read \
+ test_memset_static_write \
+ test_memset_dynamic_write \
.SILENT:
diff --git a/tests/test_memset_dynamic_write.c b/tests/test_memset_dynamic_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ memset(buffer, 0, sizeof(buffer) - 1);
+ puts(buffer);
+
+ CHK_FAIL_START
+ memset(buffer, 0, argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_memset_static_write.c b/tests/test_memset_static_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ memset(buffer, 0, sizeof(buffer) - 1);
+ puts(buffer);
+
+ CHK_FAIL_START
+ memset(buffer, 0, sizeof(buffer) + 1);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}