summaryrefslogtreecommitdiffstats
path: root/tests/bit.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-10-27 17:21:29 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-10-27 17:25:15 -0400
commit515cda3e3763484af448ad1bc599d583eeeadb18 (patch)
tree80e862e5d553fbf80e98b73700a6d851be98313b /tests/bit.c
parent1f9776901b86b97bbb9c16dd814aeab27eea0e25 (diff)
downloadbfs-515cda3e3763484af448ad1bc599d583eeeadb18.tar.xz
bit: Add bswap() overloads for every primitive type
Fixes: https://github.com/tavianator/bfs/issues/145
Diffstat (limited to 'tests/bit.c')
-rw-r--r--tests/bit.c7
1 files changed, 7 insertions, 0 deletions
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);