diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-02-13 15:26:40 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-02-13 15:26:40 -0500 |
commit | 690a06a5cef8ef506e52d274965e376d6ea865be (patch) | |
tree | c98d8e055fcb213b94a0d081178d38136ba505c1 /tests/bit.c | |
parent | d34d25c9546ce406afef2c561663db422045f05a (diff) | |
download | bfs-690a06a5cef8ef506e52d274965e376d6ea865be.tar.xz |
bit: Add the load8_[bl]euN() utilities
Diffstat (limited to 'tests/bit.c')
-rw-r--r-- | tests/bit.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/bit.c b/tests/bit.c index 5a3871d..09d470b 100644 --- a/tests/bit.c +++ b/tests/bit.c @@ -64,7 +64,7 @@ static_assert(INTMAX_MAX == IWIDTH_MAX(INTMAX_WIDTH)); bfs_check((a) == (b), "(0x%jX) %s != %s (0x%jX)", (uintmax_t)(a), #a, #b, (uintmax_t)(b)) void check_bit(void) { - const char *str = "\x1\x2\x3\x4"; + const char *str = "\x1\x2\x3\x4\x5\x6\x7\x8"; uint32_t word; memcpy(&word, str, sizeof(word)); @@ -88,6 +88,15 @@ void check_bit(void) { (void)bswap(0UL); (void)bswap(0ULL); + check_eq(load8_beu8(str), 0x01); + check_eq(load8_leu8(str), 0x01); + check_eq(load8_beu16(str), 0x0102); + check_eq(load8_leu16(str), 0x0201); + check_eq(load8_beu32(str), 0x01020304); + check_eq(load8_leu32(str), 0x04030201); + check_eq(load8_beu64(str), 0x0102030405060708ULL); + check_eq(load8_leu64(str), 0x0807060504030201ULL); + check_eq(count_ones(0x0U), 0); check_eq(count_ones(0x1U), 1); check_eq(count_ones(0x2U), 1); |