10 CHECK(byteswap16(0x1122) == 0x2211);
11 CHECK(byteswap32(0x11223344) == 0x44332211);
12 CHECK(byteswap64(0x1122334455667788) == 0x8877665544332211);
14 CHECK(byteswap(uint16_t(0x1234)) == 0x3412);
15 CHECK(byteswap(uint32_t(0x12345678)) == 0x78563412);
16 CHECK(byteswap(uint64_t(0x123456789abcdef0)) == 0xf0debc9a78563412);
19 CHECK(swapper(uint16_t(0xaabb)) == 0xbbaa);
20 CHECK(swapper(uint32_t(0xaabbccdd)) == 0xddccbbaa);
21 CHECK(swapper(uint64_t(0xaabbccddeeff0011)) == 0x1100ffeeddccbbaa);
27 REQUIRE(
sizeof(
B16) == 2);
28 REQUIRE(
sizeof(
L16) == 2);
38 std::array<uint8_t, 2> buf;
50 REQUIRE(
sizeof(
B32) == 4);
51 REQUIRE(
sizeof(
L32) == 4);
61 std::array<uint8_t, 4> buf;
76uint16_t testSwap16(uint16_t x) {
return byteswap16(x); }
77uint16_t testSwap16() {
return byteswap16(0x1234); }
78uint32_t testSwap32(uint32_t x) {
return byteswap32(x); }
79uint32_t testSwap32() {
return byteswap32(0x12345678); }
81void testA(uint16_t& s, uint16_t x) {
write_UA_L16(&s, x); }
82void testB(uint16_t& s, uint16_t x) {
write_UA_B16(&s, x); }
83uint16_t testC(uint16_t& s) {
return read_UA_L16(&s); }
84uint16_t testD(uint16_t& s) {
return read_UA_B16(&s); }
86void testA(uint32_t& s, uint32_t x) {
write_UA_L32(&s, x); }
87void testB(uint32_t& s, uint32_t x) {
write_UA_B32(&s, x); }
88uint32_t testC(uint32_t& s) {
return read_UA_L32(&s); }
89uint32_t testD(uint32_t& s) {
return read_UA_B32(&s); }
TEST_CASE("endian: byteswap")
ALWAYS_INLINE uint16_t read_UA_B16(const void *p)
ALWAYS_INLINE void write_UA_B32(void *p, uint32_t x)
ALWAYS_INLINE void write_UA_B16(void *p, uint16_t x)
ALWAYS_INLINE uint32_t read_UA_B32(const void *p)
ALWAYS_INLINE uint16_t read_UA_L16(const void *p)
ALWAYS_INLINE void write_UA_L32(void *p, uint32_t x)
ALWAYS_INLINE void write_UA_L16(void *p, uint16_t x)
ALWAYS_INLINE uint32_t read_UA_L32(const void *p)