diff options
| author | Martin Matuska <mm@FreeBSD.org> | 2026-07-07 10:36:51 +0000 |
|---|---|---|
| committer | Martin Matuska <mm@FreeBSD.org> | 2026-07-07 10:58:25 +0000 |
| commit | 77a6696abb6946edaa8cef0fcd9f666d3c69514b (patch) | |
| tree | 2c0504c3841abc432fc302151ef6df3e670681eb /libarchive/test/test_sparse_basic.c | |
| parent | f2cd95a372000681bafe284df6ba857d5c2541c2 (diff) | |
Diffstat (limited to 'libarchive/test/test_sparse_basic.c')
| -rw-r--r-- | libarchive/test/test_sparse_basic.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libarchive/test/test_sparse_basic.c b/libarchive/test/test_sparse_basic.c index 93710cb64033..d4405ddae48e 100644 --- a/libarchive/test/test_sparse_basic.c +++ b/libarchive/test/test_sparse_basic.c @@ -695,3 +695,29 @@ DEFINE_TEST(test_fully_sparse_files) assertEqualInt(ARCHIVE_OK, archive_read_free(a)); free(cwd); } + +DEFINE_TEST(test_sparse_iterator) +{ + struct archive_entry *entry; + int64_t offset, length; + int count; + + entry = archive_entry_new(); + archive_entry_set_pathname(entry, "testfile"); + archive_entry_set_mode(entry, 0100644); + archive_entry_set_size(entry, 1024); + + /* Add one sparse block covering the entire file */ + archive_entry_sparse_add_entry(entry, 0, 1024); + + /* Should remove the only block covering the entire file */ + archive_entry_sparse_reset(entry); + + count = 0; + while (archive_entry_sparse_next(entry, &offset, &length) == ARCHIVE_OK) + count++; + assertEqualInt(0, count); + assertEqualInt(0, archive_entry_sparse_count(entry)); + + archive_entry_free(entry); +} |
