summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjvoisin2023-08-20 17:59:13 +0200
committerjvoisin2023-08-20 17:59:13 +0200
commitf0305fb85796cc4dcc537123d6b9b3152cf0c4be (patch)
tree3539188b667f82577fa227e22f1f34095c44581e /tests
parentfea08b7aef9cd235d6ae384c1fd6e9578dc952c4 (diff)
Add two tests for memchr
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile2
-rw-r--r--tests/test_memchr_dynamic_read.c16
-rw-r--r--tests/test_memchr_static_read.c17
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
index b6183ce..d5f0a09 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -32,6 +32,8 @@ TARGETS= \
32 test_getlogin_r_dynamic \ 32 test_getlogin_r_dynamic \
33 test_getlogin_r_static \ 33 test_getlogin_r_static \
34 test_malloc \ 34 test_malloc \
35 test_memchr_dynamic_read \
36 test_memchr_static_read \
35 test_memcpy_dynamic_read \ 37 test_memcpy_dynamic_read \
36 test_memcpy_dynamic_write \ 38 test_memcpy_dynamic_write \
37 test_memcpy_overwrite_over \ 39 test_memcpy_overwrite_over \
diff --git a/tests/test_memchr_dynamic_read.c b/tests/test_memchr_dynamic_read.c
new file mode 100644
index 0000000..2f8d214
--- /dev/null
+++ b/tests/test_memchr_dynamic_read.c
@@ -0,0 +1,16 @@
1#include "common.h"
2
3#include <string.h>
4
5int main(int argc, char** argv) {
6 const char* buffer = "12345";
7 memchr(buffer, (int)'4', strlen(buffer) - 1);
8 puts(buffer);
9
10 CHK_FAIL_START
11 memchr(buffer, (int)'A', argc);
12 CHK_FAIL_END
13
14 puts(buffer);
15 return ret;
16}
diff --git a/tests/test_memchr_static_read.c b/tests/test_memchr_static_read.c
new file mode 100644
index 0000000..ccf46af
--- /dev/null
+++ b/tests/test_memchr_static_read.c
@@ -0,0 +1,17 @@
1#include "common.h"
2
3#include <string.h>
4
5int main(int argc, char** argv) {
6 const char* buffer = "12345";
7 const char* padding = "ABCDEFGHIJKLMN";
8 memchr(buffer, (int)'4', strlen(buffer) - 1);
9 puts(buffer);
10
11 CHK_FAIL_START
12 memchr(buffer, (int)'A', strlen(buffer) + 4);
13 CHK_FAIL_END
14
15 puts(buffer);
16 return ret;
17}