aboutsummaryrefslogtreecommitdiff
path: root/tests/test_memset_s.c
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
committeraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
commit7aa261f8d57cb53cc334f6bf1920a6f8517ff054 (patch)
treef23a96feda17de737c71b45dc94e7e044410ad35 /tests/test_memset_s.c
parent27bb394bc0bf2ca66d06931bf1e73a3e20d5741a (diff)
downloadextlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.gz
extlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.bz2
Rework test suite to be more modular
Diffstat (limited to 'tests/test_memset_s.c')
-rw-r--r--tests/test_memset_s.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_memset_s.c b/tests/test_memset_s.c
new file mode 100644
index 0000000..7716341
--- /dev/null
+++ b/tests/test_memset_s.c
@@ -0,0 +1,30 @@
+#include <string.h>
+#define USE_MEM_SECURE
+#define __STDC_WANT_LIB_EXT1__ 1
+#include "../src/extlib.h"
+
+int
+test_memset_s ()
+{
+ int errno = 0;
+ char *buf = malloc (100);
+
+ if (memset_s (buf, 100, 'a', 100) != 0)
+ errno = 1;
+
+ if (memvcmp (buf, 'a', 100) != 0)
+ errno = 2;
+
+ free_secure ((void **) &buf, 100);
+ return errno;
+}
+
+struct test_t*
+test_memset_s_t ()
+{
+ struct test_t* test = malloc (sizeof (struct test_t));
+ test->test_func = test_memset_s;
+ test->test_name = "test_memset_s";
+ test->test_desc = "memset_s";
+ return test;
+}