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/endian/test_endian_little.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/endian/test_endian_little.cc')
-rw-r--r-- | lib/libk/endian/test_endian_little.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/libk/endian/test_endian_little.cc b/lib/libk/endian/test_endian_little.cc new file mode 100644 index 0000000..97ee286 --- /dev/null +++ b/lib/libk/endian/test_endian_little.cc @@ -0,0 +1,38 @@ +#include <endian.h> +#include <gtest/gtest.h> + +namespace libk { +#include "little.c" +} // namespace libk + +TEST(endian_little, htole16) +{ + EXPECT_EQ(static_cast<uint16_t>(0xabcd), libk::htole16(0xabcd)); + EXPECT_EQ(libk::htole16(0xabcd), htole16(0xabcd)); +} +TEST(endian_little, htole32) +{ + EXPECT_EQ(static_cast<uint32_t>(0xabcd0123), libk::htole32(0xabcd0123)); + EXPECT_EQ(libk::htole32(0xabcd0123), htole32(0xabcd0123)); +} +TEST(endian_little, htole64) +{ + EXPECT_EQ(static_cast<uint64_t>(0x0123456789abcdef), libk::htole64(0x0123456789abcdef)); + EXPECT_EQ(libk::htole64(0xabcdef0123456789), htole64(0xabcdef0123456789)); +} + +TEST(endian_little, htobe16) +{ + EXPECT_EQ(static_cast<uint16_t>(0xabcd), libk::htobe16(0xcdab)); + EXPECT_EQ(libk::htobe16(0xabcd), htobe16(0xabcd)); +} +TEST(endian_little, htobe32) +{ + EXPECT_EQ(static_cast<uint32_t>(0xabcd0123), libk::htobe32(0x2301cdab)); + EXPECT_EQ(libk::htobe32(0xabcd0123), htobe32(0xabcd0123)); +} +TEST(endian_little, htobe64) +{ + EXPECT_EQ(static_cast<uint64_t>(0x0123456789abcdef), libk::htobe64(0xefcdab8967452301)); + EXPECT_EQ(libk::htobe64(0xabcdef0123456789), htobe64(0xabcdef0123456789)); +} |