aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-01-12 04:14:18 +0200
committerLasse Collin <lasse.collin@tukaani.org>2023-01-12 04:14:18 +0200
commitbfc3a0a8ac16de90049c1b1ba1445a7626d0230c (patch)
treea4c3da8e29a856f3ec78866184ac4d089cb16fe7 /tests/tests.h
parentTests: Silence warnings from -Wsign-conversion. (diff)
downloadxz-bfc3a0a8ac16de90049c1b1ba1445a7626d0230c.tar.xz
Tests: Fix warnings from clang --Wassign-enum.
Explicitly casting the integer to lzma_check silences the warning. Since such an invalid value is needed in multiple tests, a constant INVALID_LZMA_CHECK_ID was added to tests.h. The use of 0x1000 for lzma_block.check wasn't optimal as if the underlying type is a char then 0x1000 will be truncated to 0. However, in these test cases the value is ignored, thus even with such truncation the test would have passed.
Diffstat (limited to 'tests/tests.h')
-rw-r--r--tests/tests.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/tests.h b/tests/tests.h
index 4d6169b0..8d53e9de 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -19,6 +19,15 @@
#include "tuktest.h"
+// Invalid value for the lzma_check enumeration. This must be positive
+// but small enough to fit into signed char since the underlying type might
+// one some platform be a signed char.
+//
+// Don't put LZMA_ at the beginning of the name so that it is obvious that
+// this constant doesn't come from the API headers.
+#define INVALID_LZMA_CHECK_ID ((lzma_check)(LZMA_CHECK_ID_MAX + 1))
+
+
#define memcrap(buf, size) memset(buf, 0xFD, size)