aboutsummaryrefslogtreecommitdiff
path: root/test/checker.cc
diff options
context:
space:
mode:
authorjohannst <johannes.stoelp@gmail.com>2021-04-20 22:05:13 +0200
committerjohannst <johannes.stoelp@gmail.com>2021-04-20 22:05:13 +0200
commit1df4dfdcdbbaef7e5b32c5c0bfadec02b3ccd6f0 (patch)
tree467a166384174cf4877aa9492f31e194f3ab82e8 /test/checker.cc
parent3155439c1a96f1964aaee799b008331d0b362db3 (diff)
downloaddynld-1df4dfdcdbbaef7e5b32c5c0bfadec02b3ccd6f0.tar.gz
dynld-1df4dfdcdbbaef7e5b32c5c0bfadec02b3ccd6f0.zip
added memcpy + tests for memcpy/memset
Diffstat (limited to 'test/checker.cc')
-rw-r--r--test/checker.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/checker.cc b/test/checker.cc
index d687b72..3d425bf 100644
--- a/test/checker.cc
+++ b/test/checker.cc
@@ -3,7 +3,8 @@
#include "test_helper.h"
extern "C" {
- #include <fmt.h>
+#include <common.h>
+#include <fmt.h>
}
void check_dec() {
@@ -84,6 +85,27 @@ void check_exceed_len() {
ASSERT_EQ('\0', have[7]);
}
+void check_memset() {
+ unsigned char d[7] = {0};
+ void* ret = memset(d, '\x42', sizeof(d));
+
+ ASSERT_EQ(ret, d);
+ for (unsigned i = 0; i < sizeof(d); ++i) {
+ ASSERT_EQ(0x42, d[i]);
+ }
+}
+
+void check_memcpy() {
+ unsigned char s[5] = {5, 4, 3, 2, 1};
+ unsigned char d[5] = {0};
+ void* ret = memcpy(d, s, sizeof(d));
+
+ ASSERT_EQ(ret, d);
+ for (unsigned i = 0; i < sizeof(d); ++i) {
+ ASSERT_EQ(5-i, d[i]);
+ }
+}
+
int main() {
TEST_INIT;
TEST_ADD(check_dec);
@@ -95,5 +117,7 @@ int main() {
TEST_ADD(check_null);
TEST_ADD(check_exact_len);
TEST_ADD(check_exceed_len);
+ TEST_ADD(check_memset);
+ TEST_ADD(check_memcpy);
return TEST_RUN;
}