From 515cda3e3763484af448ad1bc599d583eeeadb18 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 27 Oct 2024 17:21:29 -0400 Subject: bit: Add bswap() overloads for every primitive type Fixes: https://github.com/tavianator/bfs/issues/145 --- tests/bit.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/bit.c b/tests/bit.c index cc95785..5a3871d 100644 --- a/tests/bit.c +++ b/tests/bit.c @@ -81,6 +81,13 @@ void check_bit(void) { check_eq(bswap((uint32_t)0x12345678), 0x78563412); check_eq(bswap((uint64_t)0x1234567812345678), 0x7856341278563412); + // Make sure we can bswap() every unsigned type + (void)bswap((unsigned char)0); + (void)bswap((unsigned short)0); + (void)bswap(0U); + (void)bswap(0UL); + (void)bswap(0ULL); + check_eq(count_ones(0x0U), 0); check_eq(count_ones(0x1U), 1); check_eq(count_ones(0x2U), 1); -- cgit v1.2.3