4 static const unsigned char zero[8];
5 static const unsigned char minus_one[8] = {
6 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
9 static const unsigned char test_pattern[8] = {
10 0xde, 0xad, 0xbe, 0xef, 0xf0, 0x0d, 0xca, 0xfe
13 #define test(func, pattern, expected) do { \
14 unsigned long result__ = (func)(pattern); \
15 if (!tap_result(result__ == (expected), "%s(%s)", #func, #expected)) { \
16 tap_diag(" expected: %lu", (unsigned long)(expected)); \
17 tap_diag(" actual: %lu", result__); \
25 test(unpack_16_be, zero, 0);
26 test(unpack_16_be, minus_one, 0xffff);
27 test(unpack_16_be, test_pattern, 0xdead);
28 test(unpack_32_be, zero, 0);
29 test(unpack_32_be, minus_one, 0xffffffff);
30 test(unpack_32_be, test_pattern, 0xdeadbeef);
32 test(unpack_16_le, zero, 0);
33 test(unpack_16_le, minus_one, 0xffff);
34 test(unpack_16_le, test_pattern, 0xadde);
35 test(unpack_32_le, zero, 0);
36 test(unpack_32_le, minus_one, 0xffffffff);
37 test(unpack_32_le, test_pattern, 0xefbeadde);