18 CHECK(byteswap16(0x1122) == 0x2211);
19 CHECK(byteswap32(0x11223344) == 0x44332211);
20 CHECK(byteswap64(0x1122334455667788) == 0x8877665544332211);
22 CHECK(byteswap(uint16_t(0x1234)) == 0x3412);
23 CHECK(byteswap(uint32_t(0x12345678)) == 0x78563412);
24 CHECK(byteswap(uint64_t(0x123456789abcdef0)) == 0xf0debc9a78563412);
27 CHECK(swapper(uint16_t(0xaabb)) == 0xbbaa);
28 CHECK(swapper(uint32_t(0xaabbccdd)) == 0xddccbbaa);
29 CHECK(swapper(uint64_t(0xaabbccddeeff0011)) == 0x1100ffeeddccbbaa);
36 REQUIRE(
sizeof(
t) == 2);
66 REQUIRE(
sizeof(
t) == 4);
98uint16_t testSwap16(uint16_t x) {
return byteswap16(x); }
99uint16_t testSwap16() {
return byteswap16(0x1234); }
100uint32_t testSwap32(uint32_t x) {
return byteswap32(x); }
101uint32_t testSwap32() {
return byteswap32(0x12345678); }
103void test1(
T16&
t, uint16_t x) {
t.le = x; }
104void test2(
T16&
t, uint16_t x) {
t.be = x; }
105uint16_t test3(
T16&
t) {
return t.le; }
106uint16_t test4(
T16&
t) {
return t.be; }
108void testA(uint16_t& s, uint16_t x) {
write_UA_L16(&s, x); }
109void testB(uint16_t& s, uint16_t x) {
write_UA_B16(&s, x); }
110uint16_t testC(uint16_t& s) {
return read_UA_L16(&s); }
111uint16_t testD(uint16_t& s) {
return read_UA_B16(&s); }
114void test1(
T32&
t, uint32_t x) {
t.le = x; }
115void test2(
T32&
t, uint32_t x) {
t.be = x; }
116uint32_t test3(
T32&
t) {
return t.le; }
117uint32_t test4(
T32&
t) {
return t.be; }
119void testA(uint32_t& s, uint32_t x) {
write_UA_L32(&s, x); }
120void testB(uint32_t& s, uint32_t x) {
write_UA_B32(&s, x); }
121uint32_t testC(uint32_t& s) {
return read_UA_L32(&s); }
122uint32_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)