gen-options.awk: Avoid translation context for help strings.
[dxcommon.git] / t / packtestu64.c
blob5620f342ef689414d2b5b8d1f658821c7d4a29b9
1 /*
2 * Copyright © 2015, 2023 Nick Bowler
4 * Test application to verify 64-bit unsigned unpacking functions.
6 * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
7 * This is free software: you are free to do what the fuck you want to.
8 * There is NO WARRANTY, to the extent permitted by law.
9 */
11 #include "pack.h"
12 #include "tap.h"
14 static const unsigned char zero[8];
15 static const unsigned char minus_one[8] = {
16 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
19 static const unsigned char test_pattern[8] = {
20 0xde, 0xad, 0xbe, 0xef, 0xf0, 0x0d, 0xca, 0xfe
23 #define test(func, pattern, expected) do { \
24 unsigned long long result__ = (func)(pattern); \
25 if (!tap_result(result__ == (expected), "%s(%s)", #func, #expected)) { \
26 tap_diag(" expected: %llu", (unsigned long long)(expected)); \
27 tap_diag(" actual: %llu", result__); \
28 } \
29 } while (0)
31 int main(void)
33 #if PACK_HAVE_64BIT
34 tap_plan(6);
36 test(unpack_64_be, zero, 0);
37 test(unpack_64_be, minus_one, 0xffffffffffffffffll);
38 test(unpack_64_be, test_pattern, 0xdeadbeeff00dcafell);
39 test(unpack_64_le, zero, 0);
40 test(unpack_64_le, minus_one, 0xffffffffffffffffll);
41 test(unpack_64_le, test_pattern, 0xfeca0df0efbeaddell);
42 #else
43 tap_skip_all("no 64-bit support");
44 #endif
46 tap_done();