summaryrefslogtreecommitdiffstats
path: root/tests/int.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-05-16 10:48:50 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-05-16 11:29:48 -0400
commitfe472f30e1b82f762993cbc5376ff9b25c605aa9 (patch)
treecd39f359cfc2f146d58ca06f196e6c76a9c90e30 /tests/int.c
parent9ee1ca387d59a2d1281c310915a9853a57b11a1e (diff)
downloadbfs-fe472f30e1b82f762993cbc5376ff9b25c605aa9.tar.xz
int: Backport C23's endian utilities
Diffstat (limited to 'tests/int.c')
-rw-r--r--tests/int.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/int.c b/tests/int.c
index db59e90..0039862 100644
--- a/tests/int.c
+++ b/tests/int.c
@@ -1,10 +1,14 @@
// Copyright © Tavian Barnes <tavianator@tavianator.com>
// SPDX-License-Identifier: 0BSD
+#undef NDEBUG
+
#include "../src/int.h"
#include "../src/diag.h"
+#include <assert.h>
#include <limits.h>
#include <stdint.h>
+#include <stdlib.h>
bfs_static_assert(UMAX_WIDTH(0x1) == 1);
bfs_static_assert(UMAX_WIDTH(0x3) == 2);
@@ -51,4 +55,10 @@ bfs_static_assert(INTMAX_MIN == IWIDTH_MIN(INTMAX_WIDTH));
bfs_static_assert(INTMAX_MAX == IWIDTH_MAX(INTMAX_WIDTH));
int main(void) {
+ assert(bswap((uint8_t)0x12) == 0x12);
+ assert(bswap((uint16_t)0x1234) == 0x3412);
+ assert(bswap((uint32_t)0x12345678) == 0x78563412);
+ assert(bswap((uint64_t)0x1234567812345678) == 0x7856341278563412);
+
+ return EXIT_SUCCESS;
}