aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.h
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2022-06-02 20:27:00 +0300
committerLasse Collin <lasse.collin@tukaani.org>2022-06-02 20:27:00 +0300
commit96da21470f9570cd08286906a050a7c22631775b (patch)
tree87d77355019d6764cf6bd722a435baea7e2ee80b /tests/tests.h
parentTests: Add tuktest.h mini-test-framework. (diff)
downloadxz-96da21470f9570cd08286906a050a7c22631775b.tar.xz
Tests: Include tuktest.h in tests.h.
This breaks -Werror because none of the tests so far use tuktest.h and thus there are warnings about unused variables and functions.
Diffstat (limited to '')
-rw-r--r--tests/tests.h47
1 files changed, 23 insertions, 24 deletions
diff --git a/tests/tests.h b/tests/tests.h
index 2fd42373..73875dd5 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -16,11 +16,13 @@
#include "sysdefs.h"
#include "tuklib_integer.h"
#include "lzma.h"
+#include "tuktest.h"
-#include <stdio.h>
#define memcrap(buf, size) memset(buf, 0xFD, size)
+
+// TODO: Remove these three macros once all tests have been converted.
#define expect(test) ((test) ? 0 : (fprintf(stderr, "%s:%d: %s\n", \
__FILE__, __LINE__, #test), abort(), 0))
@@ -29,29 +31,26 @@
#define fail(test) expect(test)
-static inline const char *
-lzma_ret_sym(lzma_ret ret)
-{
- if ((unsigned int)(ret) > LZMA_PROG_ERROR)
- return "UNKNOWN_ERROR";
-
- static const char *msgs[] = {
- "LZMA_OK",
- "LZMA_STREAM_END",
- "LZMA_NO_CHECK",
- "LZMA_UNSUPPORTED_CHECK",
- "LZMA_GET_CHECK",
- "LZMA_MEM_ERROR",
- "LZMA_MEMLIMIT_ERROR",
- "LZMA_FORMAT_ERROR",
- "LZMA_OPTIONS_ERROR",
- "LZMA_DATA_ERROR",
- "LZMA_BUF_ERROR",
- "LZMA_PROG_ERROR"
- };
-
- return msgs[ret];
-}
+// This table and macro allow getting more readable error messages when
+// comparing the lzma_ret enumeration values.
+static const char *enum_strings_lzma_ret[] = {
+ "LZMA_OK",
+ "LZMA_STREAM_END",
+ "LZMA_NO_CHECK",
+ "LZMA_UNSUPPORTED_CHECK",
+ "LZMA_GET_CHECK",
+ "LZMA_MEM_ERROR",
+ "LZMA_MEMLIMIT_ERROR",
+ "LZMA_FORMAT_ERROR",
+ "LZMA_OPTIONS_ERROR",
+ "LZMA_DATA_ERROR",
+ "LZMA_BUF_ERROR",
+ "LZMA_PROG_ERROR",
+ "LZMA_SEEK_NEEDED",
+};
+
+#define assert_lzma_ret(test_expr, ref_val) \
+ assert_enum_eq(test_expr, ref_val, enum_strings_lzma_ret)
static inline bool