Tests: Improve invalid unpadded size check in test_lzma_index_append().
This check was extended to test the code added to fix a failing assert
in ae5c07b22a
.
This commit is contained in:
parent
2544274a8b
commit
74c3449d8b
|
@ -134,15 +134,35 @@ test_lzma_index_append(void)
|
||||||
|
|
||||||
lzma_index_end(idx, NULL);
|
lzma_index_end(idx, NULL);
|
||||||
|
|
||||||
// Test uncompressed .xz file size growing too large.
|
// Test compressed .xz file size growing too large. This also tests
|
||||||
|
// a failing assert fixed in ae5c07b22a6b3766b84f409f1b6b5c100469068a.
|
||||||
// Should result in LZMA_DATA_ERROR.
|
// Should result in LZMA_DATA_ERROR.
|
||||||
idx = lzma_index_init(NULL);
|
idx = lzma_index_init(NULL);
|
||||||
|
|
||||||
assert_lzma_ret(lzma_index_append(idx, NULL, UNPADDED_SIZE_MAX,
|
// The calculation for maximum unpadded size is to make room for the
|
||||||
1), LZMA_DATA_ERROR);
|
// second stream when lzma_index_cat() is called. The
|
||||||
|
// 4 * LZMA_STREAM_HEADER_SIZE is for the header and footer of
|
||||||
|
// both streams. The extra 24 bytes are for the size of the indexes
|
||||||
|
// for both streams. This allows us to maximize the unpadded sum
|
||||||
|
// during the lzma_index_append() call after the indexes have been
|
||||||
|
// concatenated.
|
||||||
|
assert_lzma_ret(lzma_index_append(idx, NULL, UNPADDED_SIZE_MAX
|
||||||
|
- ((4 * LZMA_STREAM_HEADER_SIZE) + 24), 1), LZMA_OK);
|
||||||
|
|
||||||
|
lzma_index *second = lzma_index_init(NULL);
|
||||||
|
assert_true(second != NULL);
|
||||||
|
|
||||||
|
assert_lzma_ret(lzma_index_cat(second, idx, NULL), LZMA_OK);
|
||||||
|
|
||||||
|
assert_lzma_ret(lzma_index_append(second, NULL, UNPADDED_SIZE_MAX, 1),
|
||||||
|
LZMA_DATA_ERROR);
|
||||||
|
|
||||||
|
lzma_index_end(second, NULL);
|
||||||
|
|
||||||
// Test uncompressed size growing too large.
|
// Test uncompressed size growing too large.
|
||||||
// Should result in LZMA_DATA_ERROR.
|
// Should result in LZMA_DATA_ERROR.
|
||||||
|
idx = lzma_index_init(NULL);
|
||||||
|
|
||||||
assert_lzma_ret(lzma_index_append(idx, NULL,
|
assert_lzma_ret(lzma_index_append(idx, NULL,
|
||||||
UNPADDED_SIZE_MIN, LZMA_VLI_MAX), LZMA_OK);
|
UNPADDED_SIZE_MIN, LZMA_VLI_MAX), LZMA_OK);
|
||||||
assert_lzma_ret(lzma_index_append(idx, NULL,
|
assert_lzma_ret(lzma_index_append(idx, NULL,
|
||||||
|
|
Loading…
Reference in New Issue