More buffer boundary tests
This commit is contained in:
parent
e0186eadc0
commit
7dd46fe5ed
4 changed files with 30 additions and 19 deletions
|
|
@ -27,5 +27,12 @@ namespace SharpCompress.Test.Arc
|
|||
|
||||
[Fact]
|
||||
public void Arc_Crunched_Read() => Read("Arc.crunched.arc");
|
||||
|
||||
[Theory]
|
||||
[InlineData("Arc.uncompressed.largefile.arc", CompressionType.None)]
|
||||
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.uncompressed.largefile.arc
Normal file
BIN
tests/TestArchives/Archives/Arc.uncompressed.largefile.arc
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue