Tests: test_index: Replace if-statements with tuktest assertions

(cherry picked from commit cd88423e76)
This commit is contained in:
Lasse Collin 2024-04-27 14:59:55 +03:00
parent 91e3ea8735
commit 20cac20f63
1 changed files with 9 additions and 13 deletions

View File

@ -1489,21 +1489,19 @@ generate_index_decode_buffer(void)
{ {
#ifdef HAVE_ENCODERS #ifdef HAVE_ENCODERS
decode_test_index = lzma_index_init(NULL); decode_test_index = lzma_index_init(NULL);
if (decode_test_index == NULL) assert_true(decode_test_index != NULL);
return;
// Add 4 Blocks // Add 4 Blocks
for (uint32_t i = 1; i < 5; i++) for (uint32_t i = 1; i < 5; i++)
if (lzma_index_append(decode_test_index, NULL, assert_lzma_ret(lzma_index_append(decode_test_index, NULL,
0x1000 * i, 0x100 * i) != LZMA_OK) 0x1000 * i, 0x100 * i), LZMA_OK);
return;
size_t size = lzma_index_size(decode_test_index); const size_t size = (size_t)lzma_index_size(decode_test_index);
decode_buffer = tuktest_malloc(size); decode_buffer = tuktest_malloc(size);
if (lzma_index_buffer_encode(decode_test_index, assert_lzma_ret(lzma_index_buffer_encode(decode_test_index,
decode_buffer, &decode_buffer_size, size) != LZMA_OK) decode_buffer, &decode_buffer_size, size), LZMA_OK);
decode_buffer_size = 0; assert_true(decode_buffer_size != 0);
#endif #endif
} }
@ -1526,8 +1524,7 @@ test_lzma_index_decoder(void)
#ifndef HAVE_DECODERS #ifndef HAVE_DECODERS
assert_skip("Decoder support disabled"); assert_skip("Decoder support disabled");
#else #else
if (decode_buffer_size == 0) assert_true(decode_buffer_size != 0);
assert_skip("Could not initialize decode test buffer");
lzma_stream strm = LZMA_STREAM_INIT; lzma_stream strm = LZMA_STREAM_INIT;
@ -1653,8 +1650,7 @@ test_lzma_index_buffer_decode(void)
#ifndef HAVE_DECODERS #ifndef HAVE_DECODERS
assert_skip("Decoder support disabled"); assert_skip("Decoder support disabled");
#else #else
if (decode_buffer_size == 0) assert_true(decode_buffer_size != 0);
assert_skip("Could not initialize decode test buffer");
// Simple test since test_lzma_index_decoder() covers most of the // Simple test since test_lzma_index_decoder() covers most of the
// lzma_index_buffer_decode() code anyway. // lzma_index_buffer_decode() code anyway.