mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-07-17 14:35:23 +00:00
Merge pull request #1028 from TwanVanDongen/master
Buffer boundary tests
This commit is contained in:
@@ -27,5 +27,13 @@ namespace SharpCompress.Test.Arc
|
||||
|
||||
[Fact]
|
||||
public void Arc_Crunched_Read() => Read("Arc.crunched.arc");
|
||||
|
||||
[Theory]
|
||||
[InlineData("Arc.uncompressed.largefile.arc", CompressionType.None)]
|
||||
[InlineData("Arc.squeezed.largefile.arc", CompressionType.Squeezed)]
|
||||
public void Arc_LargeFileTest_Read(string fileName, CompressionType compressionType)
|
||||
{
|
||||
ReadForBufferBoundaryCheck(fileName, compressionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace SharpCompress.Test.Arj
|
||||
public void Arj_LargeFile_ShouldThrow(string fileName, CompressionType compressionType)
|
||||
{
|
||||
var exception = Assert.Throws<NotSupportedException>(() =>
|
||||
Arj_LargeFileTest_Read(fileName, compressionType)
|
||||
ReadForBufferBoundaryCheck(fileName, compressionType)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -74,24 +74,7 @@ namespace SharpCompress.Test.Arj
|
||||
[InlineData("Arj.method4.largefile.arj", CompressionType.ArjLZ77)]
|
||||
public void Arj_LargeFileTest_Read(string fileName, CompressionType compressionType)
|
||||
{
|
||||
using (var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, fileName)))
|
||||
using (
|
||||
var reader = ReaderFactory.Open(stream, new ReaderOptions { LookForHeader = true })
|
||||
)
|
||||
{
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
Assert.Equal(compressionType, reader.Entry.CompressionType);
|
||||
reader.WriteEntryToDirectory(
|
||||
SCRATCH_FILES_PATH,
|
||||
new ExtractionOptions { ExtractFullPath = true, Overwrite = true }
|
||||
);
|
||||
}
|
||||
}
|
||||
CompareFilesByPath(
|
||||
Path.Combine(SCRATCH_FILES_PATH, "news.txt"),
|
||||
Path.Combine(MISC_TEST_FILES_PATH, "news.txt")
|
||||
);
|
||||
ReadForBufferBoundaryCheck(fileName, compressionType);
|
||||
}
|
||||
|
||||
private void DoArj_Multi_Reader(string[] archives)
|
||||
|
||||
@@ -176,6 +176,27 @@ public abstract class ReaderTests : TestBase
|
||||
}
|
||||
}
|
||||
|
||||
protected void ReadForBufferBoundaryCheck(string fileName, CompressionType compressionType)
|
||||
{
|
||||
using var stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, fileName));
|
||||
using var reader = ReaderFactory.Open(stream, new ReaderOptions { LookForHeader = true });
|
||||
|
||||
while (reader.MoveToNextEntry())
|
||||
{
|
||||
Assert.Equal(compressionType, reader.Entry.CompressionType);
|
||||
|
||||
reader.WriteEntryToDirectory(
|
||||
SCRATCH_FILES_PATH,
|
||||
new ExtractionOptions { ExtractFullPath = true, Overwrite = true }
|
||||
);
|
||||
}
|
||||
|
||||
CompareFilesByPath(
|
||||
Path.Combine(SCRATCH_FILES_PATH, "news.txt"),
|
||||
Path.Combine(MISC_TEST_FILES_PATH, "news.txt")
|
||||
);
|
||||
}
|
||||
|
||||
protected void Iterate(
|
||||
string testArchive,
|
||||
string fileOrder,
|
||||
|
||||
BIN
tests/TestArchives/Archives/Arc.squeezed.largefile.arc
Normal file
BIN
tests/TestArchives/Archives/Arc.squeezed.largefile.arc
Normal file
Binary file not shown.
BIN
tests/TestArchives/Archives/Arc.uncompressed.largefile.arc
Normal file
BIN
tests/TestArchives/Archives/Arc.uncompressed.largefile.arc
Normal file
Binary file not shown.
Reference in New Issue
Block a user