Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check for minimal distance and add test case generated by 7z as compatibility check #735

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/SharpCompress/Compressors/Filters/DeltaFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ public DeltaFilter(bool isEncoder, Stream baseStream, byte[] info)
_distance = info[0];
_history = new byte[DISTANCE_MAX];
_position = 0;

if (_distance < DISTANCE_MIN)
{
throw new NotSupportedException();
}
}

protected override int Transform(byte[] buffer, int offset, int count)
Expand Down
25 changes: 25 additions & 0 deletions tests/SharpCompress.Test/ArchiveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,29 @@ protected void ArchiveFileReadEx(string testArchive)
}
VerifyFilesEx();
}

protected void ArchiveDeltaDistanceRead(string testArchive)
{
testArchive = Path.Combine(TEST_ARCHIVES_PATH, testArchive);
using (var archive = Archives.ArchiveFactory.Open(testArchive, null))
using (var reader = archive.ExtractAllEntries())
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
var memory = new MemoryStream();
reader.WriteEntryTo(memory);

memory.Position = 0;

for (int y = 0; y < 9; y++)
for (int x = 0; x < 256; x++)
{
Assert.Equal(x, memory.ReadByte());
}

Assert.Equal((int)-1, memory.ReadByte());
}
}
}
}
6 changes: 5 additions & 1 deletion tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using SharpCompress.Common;
using SharpCompress.Readers;
using Xunit;
Expand Down Expand Up @@ -111,6 +112,9 @@ public class SevenZipArchiveTests : ArchiveTests
//"7Zip.BZip2.split.007"

[Fact]
public void SevenZipArchive_delta_FileRead() =>
public void SevenZipArchive_Delta_FileRead() =>
ArchiveFileRead("7Zip.delta.7z");

[Fact]
public void SevenZipArchive_Delta_Distance() => ArchiveDeltaDistanceRead("7Zip.delta.distance.7z");
}
Binary file not shown.