From 8c6d9140040190a3ecba630f35eefbd1fda8dafa Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Wed, 26 Nov 2025 15:11:03 +0000 Subject: [PATCH] reader tests don't pass or make sense --- .../Zip/SOZipReaderTests.cs | 45 ++++++++++++++++++ .../{SOZipTests.cs => SoZipWriterTests.cs} | 2 +- tests/TestArchives/Archives/foo.zip | Bin 0 -> 204 bytes 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/SharpCompress.Test/Zip/SOZipReaderTests.cs rename tests/SharpCompress.Test/Zip/{SOZipTests.cs => SoZipWriterTests.cs} (99%) create mode 100644 tests/TestArchives/Archives/foo.zip diff --git a/tests/SharpCompress.Test/Zip/SOZipReaderTests.cs b/tests/SharpCompress.Test/Zip/SOZipReaderTests.cs new file mode 100644 index 00000000..9c6fa089 --- /dev/null +++ b/tests/SharpCompress.Test/Zip/SOZipReaderTests.cs @@ -0,0 +1,45 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using SharpCompress.Archives.Zip; +using SharpCompress.Common.Zip.SOZip; +using SharpCompress.Readers; +using SharpCompress.Readers.Zip; +using SharpCompress.Test.Mocks; +using Xunit; + +namespace SharpCompress.Test.Zip; + +public class SoZipReaderTests : TestBase +{ + [Fact] + public async Task SOZip_Reader() + { + var path = Path.Combine(TEST_ARCHIVES_PATH, "foo.zip"); + using Stream stream = new ForwardOnlyStream(File.OpenRead(path)); + using var reader = ZipReader.Open(stream); + while (await reader.MoveToNextEntryAsync()) + { + Assert.True(reader.Entry.IsSozip, $"Entry {reader.Entry.Key} is not SOZip"); + if (!reader.Entry.IsDirectory) + { + await reader.WriteEntryToAsync(Stream.Null); + } + } + } + + [Fact] + public void SOZip_Archive() + { + var path = Path.Combine(TEST_ARCHIVES_PATH, "foo.zip"); + using Stream stream = File.OpenRead(path); + using var archive = ZipArchive.Open(stream); + foreach (var entry in archive.Entries) + { + if (entry.IsSozip) + Console.WriteLine($"{entry.Key} has SOZip random access support"); + if (entry.IsSozipIndexFile) + Console.WriteLine($"{entry.Key} is a SOZip index file"); + } + } +} diff --git a/tests/SharpCompress.Test/Zip/SOZipTests.cs b/tests/SharpCompress.Test/Zip/SoZipWriterTests.cs similarity index 99% rename from tests/SharpCompress.Test/Zip/SOZipTests.cs rename to tests/SharpCompress.Test/Zip/SoZipWriterTests.cs index 33b71dc2..dde04a92 100644 --- a/tests/SharpCompress.Test/Zip/SOZipTests.cs +++ b/tests/SharpCompress.Test/Zip/SoZipWriterTests.cs @@ -11,7 +11,7 @@ using Xunit; namespace SharpCompress.Test.Zip; -public class SOZipTests : TestBase +public class SoZipWriterTests : TestBase { [Fact] public void SOZipIndex_RoundTrip() diff --git a/tests/TestArchives/Archives/foo.zip b/tests/TestArchives/Archives/foo.zip new file mode 100644 index 0000000000000000000000000000000000000000..fb80a9225027dde15df2cfec6b050d29b55f31e0 GIT binary patch literal 204 zcmWIWW@Zs#U|`^2SW&AQrkGmXBf!AGzzoG{`T1U_*%=rZ{{IIPr`Z``8W_MDa!&jU z(_mm=0AW4`1_r&f{CvIQ{Hn|Xz08yfMg|CA0$Ttv79;|)0z~tI2nGg*0B=Sn1_s>D dfGUGhY5Dm9-mGjO9wP%IgCPS0Lo0~G0014%9Bu#r literal 0 HcmV?d00001