diff options
author | aqua <aqua@iserlohn-fortress.net> | 2023-03-05 14:38:54 +0200 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2023-03-05 14:38:54 +0200 |
commit | 787c1a6016dd2fdb51f20fcb5ca0ac5e461892d6 (patch) | |
tree | 7db9f5102adc3d50ca85a8175ce67465256b8908 /lib/libk/stdlib/test_mem.cc | |
parent | Add TARGETBIN and TARGETLIB rules (diff) | |
download | kernel-787c1a6016dd2fdb51f20fcb5ca0ac5e461892d6.tar.xz |
Move all tests next to the code they're testing
Diffstat (limited to 'lib/libk/stdlib/test_mem.cc')
-rw-r--r-- | lib/libk/stdlib/test_mem.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/libk/stdlib/test_mem.cc b/lib/libk/stdlib/test_mem.cc new file mode 100644 index 0000000..f8a5e18 --- /dev/null +++ b/lib/libk/stdlib/test_mem.cc @@ -0,0 +1,29 @@ +#include <gtest/gtest.h> + +#define restrict __restrict__ + +namespace libk { +#include "memcpy.c" +#include "memset.c" +} // namespace libk + +TEST(mem, memset) +{ + auto *buffer = new unsigned char[2048]; + + libk::memset(buffer, 0xae, sizeof(buffer)); + for (unsigned i = 0; i < sizeof(buffer); ++i) EXPECT_EQ(buffer[i], 0xae); + + delete[] buffer; +} + +TEST(mem, memcpy) +{ + const unsigned char data[] = {0xde, 0xca, 0xfa, 0xde}; + auto *buffer = new unsigned char[sizeof(data)]; + + memcpy(buffer, data, sizeof(data)); + for (unsigned i = 0; i < sizeof(data); ++i) EXPECT_EQ(buffer[i], data[i]); + + delete[] buffer; +} |