diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-05-16 10:48:50 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-05-16 11:29:48 -0400 |
commit | fe472f30e1b82f762993cbc5376ff9b25c605aa9 (patch) | |
tree | cd39f359cfc2f146d58ca06f196e6c76a9c90e30 /tests | |
parent | 9ee1ca387d59a2d1281c310915a9853a57b11a1e (diff) | |
download | bfs-fe472f30e1b82f762993cbc5376ff9b25c605aa9.tar.xz |
int: Backport C23's endian utilities
Diffstat (limited to 'tests')
-rw-r--r-- | tests/int.c | 10 |
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; } |