From bfc3a0a8ac16de90049c1b1ba1445a7626d0230c Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Thu, 12 Jan 2023 04:14:18 +0200 Subject: 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. --- tests/test_block_header.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_block_header.c') diff --git a/tests/test_block_header.c b/tests/test_block_header.c index 747925b3..43c7df43 100644 --- a/tests/test_block_header.c +++ b/tests/test_block_header.c @@ -189,7 +189,7 @@ test_lzma_block_header_size(void) // Use an invalid block option. The check type isn't stored in // the Block Header and so _header_size ignores it. - block.check = 0x1000; + block.check = INVALID_LZMA_CHECK_ID; block.ignore_check = false; assert_lzma_ret(lzma_block_header_size(&block), LZMA_OK); @@ -270,7 +270,7 @@ test_lzma_block_header_encode(void) block.uncompressed_size = LZMA_VLI_UNKNOWN; // Test invalid block check - block.check = 0x1000; + block.check = INVALID_LZMA_CHECK_ID; block.ignore_check = false; assert_lzma_ret(lzma_block_header_encode(&block, out), LZMA_PROG_ERROR); @@ -466,7 +466,7 @@ test_lzma_block_header_decode(void) assert_uint_eq(decoded_block.version, 1); // Test bad check type - decoded_block.check = LZMA_CHECK_ID_MAX + 1; + decoded_block.check = INVALID_LZMA_CHECK_ID; assert_lzma_ret(lzma_block_header_decode(&decoded_block, NULL, out), LZMA_PROG_ERROR); decoded_block.check = LZMA_CHECK_CRC32; -- cgit v1.2.3