summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjvoisin2023-04-13 22:51:15 +0200
committerjvoisin2023-04-13 23:49:02 +0200
commit56d760c5cb1c07dfa409742d51f836792a09d824 (patch)
tree946bba5bff2744e8532f2f570b09d5e4a8d14e3b /tests
parentaceef734bdfe4f68e2227fc9ac636aae8235fa12 (diff)
Add tests for memset
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile4
-rw-r--r--tests/test_memset_dynamic_write.c16
-rw-r--r--tests/test_memset_static_write.c16
3 files changed, 35 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 1f80c32..25f6f66 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -8,7 +8,9 @@ TARGETS=test_memcpy_static_write \
8 test_memmove_static_write \ 8 test_memmove_static_write \
9 test_memmove_dynamic_write \ 9 test_memmove_dynamic_write \
10 test_memmove_static_read \ 10 test_memmove_static_read \
11 test_memmove_dynamic_read 11 test_memmove_dynamic_read \
12 test_memset_static_write \
13 test_memset_dynamic_write \
12 14
13.SILENT: 15.SILENT:
14 16
diff --git a/tests/test_memset_dynamic_write.c b/tests/test_memset_dynamic_write.c
new file mode 100644
index 0000000..5e1d8a3
--- /dev/null
+++ b/tests/test_memset_dynamic_write.c
@@ -0,0 +1,16 @@
1#include "common.h"
2
3#include <string.h>
4
5int main(int argc, char** argv) {
6 char buffer[8] = {0};
7 memset(buffer, 0, sizeof(buffer) - 1);
8 puts(buffer);
9
10 CHK_FAIL_START
11 memset(buffer, 0, argc);
12 CHK_FAIL_END
13
14 puts(buffer);
15 return ret;
16}
diff --git a/tests/test_memset_static_write.c b/tests/test_memset_static_write.c
new file mode 100644
index 0000000..dc30ed8
--- /dev/null
+++ b/tests/test_memset_static_write.c
@@ -0,0 +1,16 @@
1#include "common.h"
2
3#include <string.h>
4
5int main(int argc, char** argv) {
6 char buffer[8] = {0};
7 memset(buffer, 0, sizeof(buffer) - 1);
8 puts(buffer);
9
10 CHK_FAIL_START
11 memset(buffer, 0, sizeof(buffer) + 1);
12 CHK_FAIL_END
13
14 puts(buffer);
15 return ret;
16}