]> git.draconx.ca Git - dxcommon.git/commitdiff
pack: Fix 64-bit tests on old HP cc.
authorNick Bowler <nbowler@draconx.ca>
Sat, 18 Nov 2023 20:45:20 +0000 (15:45 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 18 Nov 2023 21:39:56 +0000 (16:39 -0500)
At least some versions of the HP compiler appear to require "ll" suffix,
otherwise the decimal constants end up as a 32-bit type.

t/packtests.c
t/packtests64.c
t/packtestu.c
t/packtestu64.c

index b3a7a8bd2c7bafa1ed13c97d413781ad2c0ea33d..308acb32cf1a5e47ec01a48ed389f8b4255225d3 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright © 2015 Nick Bowler
+ *
+ * Test application to verify 16 and 32-bit signed unpacking functions.
+ *
+ * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+ * This is free software: you are free to do what the fuck you want to.
+ * There is NO WARRANTY, to the extent permitted by law.
+ */
+
 #include "pack.h"
 #include "tap.h"
 
index a8fefe995983d283620d9c6d20a5093aaded06ca..3a3f8e5473a77b7372a40d1e812d77c8a12d63e9 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright © 2015, 2023 Nick Bowler
+ *
+ * Test application to verify 64-bit signed unpacking functions.
+ *
+ * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+ * This is free software: you are free to do what the fuck you want to.
+ * There is NO WARRANTY, to the extent permitted by law.
+ */
+
 #include "pack.h"
 #include "tap.h"
 
@@ -17,8 +27,8 @@ static const unsigned char test_pattern[8] = {
 #define test(func, pattern, expected) do { \
        long long result__ = (func)(pattern); \
        if (!tap_result(result__ == (expected), "%s(%s)", #func, #expected)) { \
-               tap_diag("  expected: %ld", (long long)(expected)); \
-               tap_diag("  actual:   %ld", result__); \
+               tap_diag("  expected: %lld", (long long)(expected)); \
+               tap_diag("  actual:   %lld", result__); \
        } \
 } while (0)
 
@@ -29,13 +39,13 @@ int main(void)
 
        test(unpack_s64_be, zero,          0);
        test(unpack_s64_be, minus_one,    -1);
-       test(unpack_s64_be, test_pattern, -2401053088584709378);
-       test(unpack_s64_be, min,          -9223372036854775807-1);
+       test(unpack_s64_be, test_pattern, -2401053088584709378ll);
+       test(unpack_s64_be, min,          -9223372036854775807ll-1);
 
        test(unpack_s64_le, zero,          0);
        test(unpack_s64_le, minus_one,    -1);
-       test(unpack_s64_le, test_pattern, -87241914314740258);
-       test(unpack_s64_le, min+1,        -9223372036854775807-1);
+       test(unpack_s64_le, test_pattern, -87241914314740258ll);
+       test(unpack_s64_le, min+1,        -9223372036854775807ll-1);
 #else
        tap_skip_all("no 64-bit support");
 #endif
index 5ae3af9b244f7368e5f202e8555989ebfb91a03f..d2a2c44a18ec7221dad83a9bfe0d503e62618271 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright © 2015 Nick Bowler
+ *
+ * Test application to verify 16 and 32-bit unsigned unpacking functions.
+ *
+ * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+ * This is free software: you are free to do what the fuck you want to.
+ * There is NO WARRANTY, to the extent permitted by law.
+ */
+
 #include "pack.h"
 #include "tap.h"
 
index 217404f2a90916fe7d28e8a1b722e2de9b6ea611..5620f342ef689414d2b5b8d1f658821c7d4a29b9 100644 (file)
@@ -1,3 +1,13 @@
+/*
+ * Copyright © 2015, 2023 Nick Bowler
+ *
+ * Test application to verify 64-bit unsigned unpacking functions.
+ *
+ * License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+ * This is free software: you are free to do what the fuck you want to.
+ * There is NO WARRANTY, to the extent permitted by law.
+ */
+
 #include "pack.h"
 #include "tap.h"
 
@@ -24,11 +34,11 @@ int main(void)
        tap_plan(6);
 
        test(unpack_64_be, zero,         0);
-       test(unpack_64_be, minus_one,    0xffffffffffffffff);
-       test(unpack_64_be, test_pattern, 0xdeadbeeff00dcafe);
+       test(unpack_64_be, minus_one,    0xffffffffffffffffll);
+       test(unpack_64_be, test_pattern, 0xdeadbeeff00dcafell);
        test(unpack_64_le, zero,         0);
-       test(unpack_64_le, minus_one,    0xffffffffffffffff);
-       test(unpack_64_le, test_pattern, 0xfeca0df0efbeadde);
+       test(unpack_64_le, minus_one,    0xffffffffffffffffll);
+       test(unpack_64_le, test_pattern, 0xfeca0df0efbeaddell);
 #else
        tap_skip_all("no 64-bit support");
 #endif