mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
more clean up
This commit is contained in:
@@ -13,7 +13,7 @@ namespace SharpCompress.Test.Filters;
|
||||
public class BranchExecTests
|
||||
{
|
||||
private static byte[] X86ResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x12,
|
||||
0x00,
|
||||
0x00,
|
||||
@@ -91,11 +91,11 @@ public class BranchExecTests
|
||||
0x00,
|
||||
0x00,
|
||||
0x1C,
|
||||
0x00,
|
||||
};
|
||||
0x00
|
||||
];
|
||||
|
||||
private static byte[] X86Data { get; } =
|
||||
{
|
||||
[
|
||||
0x12,
|
||||
0x00,
|
||||
0x00,
|
||||
@@ -173,11 +173,11 @@ public class BranchExecTests
|
||||
0x00,
|
||||
0x00,
|
||||
0x1C,
|
||||
0x00,
|
||||
};
|
||||
0x00
|
||||
];
|
||||
|
||||
private static byte[] PpcResultData { get; } =
|
||||
{
|
||||
[
|
||||
0xF8,
|
||||
0x6B,
|
||||
0x2E,
|
||||
@@ -274,10 +274,10 @@ public class BranchExecTests
|
||||
0xB2,
|
||||
0xD4,
|
||||
0xED
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] PpcData { get; } =
|
||||
{
|
||||
[
|
||||
0xF8,
|
||||
0x6B,
|
||||
0x2E,
|
||||
@@ -374,10 +374,10 @@ public class BranchExecTests
|
||||
0xB2,
|
||||
0xD4,
|
||||
0xED
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] ArmResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x7C,
|
||||
0xFC,
|
||||
0x0A,
|
||||
@@ -474,10 +474,10 @@ public class BranchExecTests
|
||||
0xC6,
|
||||
0x8F,
|
||||
0xE2
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] ArmData { get; } =
|
||||
{
|
||||
[
|
||||
0x7C,
|
||||
0xFC,
|
||||
0x0A,
|
||||
@@ -574,10 +574,10 @@ public class BranchExecTests
|
||||
0xC6,
|
||||
0x8F,
|
||||
0xE2
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] ArmtResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x95,
|
||||
0x23,
|
||||
0xB6,
|
||||
@@ -690,10 +690,10 @@ public class BranchExecTests
|
||||
0xED,
|
||||
0x11,
|
||||
0x0F
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] ArmtData { get; } =
|
||||
{
|
||||
[
|
||||
0x95,
|
||||
0x23,
|
||||
0xB6,
|
||||
@@ -806,10 +806,10 @@ public class BranchExecTests
|
||||
0xED,
|
||||
0x11,
|
||||
0x0F
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] Ia64ResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x4D,
|
||||
0xF8,
|
||||
0xF2,
|
||||
@@ -906,10 +906,10 @@ public class BranchExecTests
|
||||
0x72,
|
||||
0xD5,
|
||||
0x0D
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] Ia64Data { get; } =
|
||||
{
|
||||
[
|
||||
0x4D,
|
||||
0xF8,
|
||||
0xF2,
|
||||
@@ -1006,10 +1006,10 @@ public class BranchExecTests
|
||||
0x72,
|
||||
0xD5,
|
||||
0x0D
|
||||
};
|
||||
];
|
||||
|
||||
private static byte[] SparcResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x78,
|
||||
0x2E,
|
||||
0x73,
|
||||
@@ -1087,11 +1087,11 @@ public class BranchExecTests
|
||||
0x91,
|
||||
0x00,
|
||||
0x10,
|
||||
0x00,
|
||||
};
|
||||
0x00
|
||||
];
|
||||
|
||||
private static byte[] SparcData { get; } =
|
||||
{
|
||||
[
|
||||
0x78,
|
||||
0x2E,
|
||||
0x73,
|
||||
@@ -1169,8 +1169,8 @@ public class BranchExecTests
|
||||
0x91,
|
||||
0x00,
|
||||
0x10,
|
||||
0x00,
|
||||
};
|
||||
0x00
|
||||
];
|
||||
|
||||
private void CompareBuffer(byte[] testBuffer, byte[] targetBuffer) =>
|
||||
Assert.Equal(testBuffer, targetBuffer);
|
||||
|
||||
@@ -7,30 +7,26 @@ namespace SharpCompress.Test.Mocks;
|
||||
// CryptoStream doesn't always trigger the Flush, so this class is used instead
|
||||
// See https://referencesource.microsoft.com/#mscorlib/system/security/cryptography/cryptostream.cs,141
|
||||
|
||||
public class FlushOnDisposeStream : Stream, IDisposable
|
||||
public class FlushOnDisposeStream(Stream innerStream) : Stream
|
||||
{
|
||||
private Stream _inner;
|
||||
|
||||
public FlushOnDisposeStream(Stream innerStream) => _inner = innerStream;
|
||||
|
||||
public override bool CanRead => _inner.CanRead;
|
||||
public override bool CanRead => innerStream.CanRead;
|
||||
|
||||
public override bool CanSeek => false;
|
||||
|
||||
public override bool CanWrite => false;
|
||||
|
||||
public override long Length => _inner.Length;
|
||||
public override long Length => innerStream.Length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get => _inner.Position;
|
||||
set => _inner.Position = value;
|
||||
get => innerStream.Position;
|
||||
set => innerStream.Position = value;
|
||||
}
|
||||
|
||||
public override void Flush() { }
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count) =>
|
||||
_inner.Read(buffer, offset, count);
|
||||
innerStream.Read(buffer, offset, count);
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) =>
|
||||
throw new NotImplementedException();
|
||||
@@ -44,8 +40,8 @@ public class FlushOnDisposeStream : Stream, IDisposable
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_inner.Flush();
|
||||
_inner.Close();
|
||||
innerStream.Flush();
|
||||
innerStream.Close();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
|
||||
@@ -3,21 +3,17 @@ using System.IO;
|
||||
|
||||
namespace SharpCompress.Test.Mocks;
|
||||
|
||||
public class ForwardOnlyStream : Stream
|
||||
public class ForwardOnlyStream(Stream stream) : Stream
|
||||
{
|
||||
private readonly Stream _stream;
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public ForwardOnlyStream(Stream stream) => _stream = stream;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_stream.Dispose();
|
||||
stream.Dispose();
|
||||
IsDisposed = true;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
@@ -40,7 +36,7 @@ public class ForwardOnlyStream : Stream
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count) =>
|
||||
_stream.Read(buffer, offset, count);
|
||||
stream.Read(buffer, offset, count);
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
|
||||
|
||||
|
||||
@@ -2,53 +2,43 @@
|
||||
|
||||
namespace SharpCompress.Test.Mocks;
|
||||
|
||||
public class TestStream : Stream
|
||||
public class TestStream(Stream stream, bool read, bool write, bool seek) : Stream
|
||||
{
|
||||
private readonly Stream _stream;
|
||||
|
||||
public TestStream(Stream stream)
|
||||
: this(stream, stream.CanRead, stream.CanWrite, stream.CanSeek) { }
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public TestStream(Stream stream, bool read, bool write, bool seek)
|
||||
{
|
||||
_stream = stream;
|
||||
CanRead = read;
|
||||
CanWrite = write;
|
||||
CanSeek = seek;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
_stream.Dispose();
|
||||
stream.Dispose();
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
public override bool CanRead { get; }
|
||||
public override bool CanRead { get; } = read;
|
||||
|
||||
public override bool CanSeek { get; }
|
||||
public override bool CanSeek { get; } = seek;
|
||||
|
||||
public override bool CanWrite { get; }
|
||||
public override bool CanWrite { get; } = write;
|
||||
|
||||
public override void Flush() => _stream.Flush();
|
||||
public override void Flush() => stream.Flush();
|
||||
|
||||
public override long Length => _stream.Length;
|
||||
public override long Length => stream.Length;
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get => _stream.Position;
|
||||
set => _stream.Position = value;
|
||||
get => stream.Position;
|
||||
set => stream.Position = value;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count) =>
|
||||
_stream.Read(buffer, offset, count);
|
||||
stream.Read(buffer, offset, count);
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) => _stream.Seek(offset, origin);
|
||||
public override long Seek(long offset, SeekOrigin origin) => stream.Seek(offset, origin);
|
||||
|
||||
public override void SetLength(long value) => _stream.SetLength(value);
|
||||
public override void SetLength(long value) => stream.SetLength(value);
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count) =>
|
||||
_stream.Write(buffer, offset, count);
|
||||
stream.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
@@ -229,30 +229,28 @@ public class RarArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Rar_Multi_ArchiveStreamRead() =>
|
||||
DoRar_Multi_ArchiveStreamRead(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar.multi.part01.rar",
|
||||
"Rar.multi.part02.rar",
|
||||
"Rar.multi.part03.rar",
|
||||
"Rar.multi.part04.rar",
|
||||
"Rar.multi.part05.rar",
|
||||
"Rar.multi.part06.rar"
|
||||
},
|
||||
],
|
||||
false
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar5_Multi_ArchiveStreamRead() =>
|
||||
DoRar_Multi_ArchiveStreamRead(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar5.multi.part01.rar",
|
||||
"Rar5.multi.part02.rar",
|
||||
"Rar5.multi.part03.rar",
|
||||
"Rar5.multi.part04.rar",
|
||||
"Rar5.multi.part05.rar",
|
||||
"Rar5.multi.part06.rar"
|
||||
},
|
||||
],
|
||||
false
|
||||
);
|
||||
|
||||
@@ -274,15 +272,14 @@ public class RarArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Rar5_MultiSolid_ArchiveStreamRead() =>
|
||||
DoRar_Multi_ArchiveStreamRead(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar.multi.solid.part01.rar",
|
||||
"Rar.multi.solid.part02.rar",
|
||||
"Rar.multi.solid.part03.rar",
|
||||
"Rar.multi.solid.part04.rar",
|
||||
"Rar.multi.solid.part05.rar",
|
||||
"Rar.multi.solid.part06.rar"
|
||||
},
|
||||
],
|
||||
true
|
||||
);
|
||||
|
||||
@@ -344,8 +341,7 @@ public class RarArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Rar2_Multi_ArchiveStreamRead() =>
|
||||
DoRar_Multi_ArchiveStreamRead(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar2.multi.rar",
|
||||
"Rar2.multi.r00",
|
||||
"Rar2.multi.r01",
|
||||
@@ -353,7 +349,7 @@ public class RarArchiveTests : ArchiveTests
|
||||
"Rar2.multi.r03",
|
||||
"Rar2.multi.r04",
|
||||
"Rar2.multi.r05"
|
||||
},
|
||||
],
|
||||
false
|
||||
);
|
||||
|
||||
@@ -467,8 +463,7 @@ public class RarArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Rar4_Multi_ArchiveStreamRead() =>
|
||||
DoRar_Multi_ArchiveStreamRead(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar4.multi.part01.rar",
|
||||
"Rar4.multi.part02.rar",
|
||||
"Rar4.multi.part03.rar",
|
||||
@@ -476,7 +471,7 @@ public class RarArchiveTests : ArchiveTests
|
||||
"Rar4.multi.part05.rar",
|
||||
"Rar4.multi.part06.rar",
|
||||
"Rar4.multi.part07.rar"
|
||||
},
|
||||
],
|
||||
false
|
||||
);
|
||||
|
||||
@@ -485,15 +480,14 @@ public class RarArchiveTests : ArchiveTests
|
||||
public void Rar4_Split_ArchiveStreamRead() =>
|
||||
ArchiveStreamMultiRead(
|
||||
null,
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar4.split.001",
|
||||
"Rar4.split.002",
|
||||
"Rar4.split.003",
|
||||
"Rar4.split.004",
|
||||
"Rar4.split.005",
|
||||
"Rar4.split.006"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
//will detect and load other files
|
||||
@@ -520,15 +514,14 @@ public class RarArchiveTests : ArchiveTests
|
||||
public void Rar4_Split_ArchiveStreamFirstFileRead() =>
|
||||
ArchiveStreamMultiRead(
|
||||
null,
|
||||
new[]
|
||||
{
|
||||
"Rar4.split.001",
|
||||
[
|
||||
"Rar4.split.001"
|
||||
//"Rar4.split.002",
|
||||
//"Rar4.split.003",
|
||||
//"Rar4.split.004",
|
||||
//"Rar4.split.005",
|
||||
//"Rar4.split.006"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
//open with ArchiveFactory.Open and stream
|
||||
@@ -561,12 +554,11 @@ public class RarArchiveTests : ArchiveTests
|
||||
[Fact]
|
||||
public void Rar4_Multi_ArchiveOpenEntryVolumeIndexTest() =>
|
||||
ArchiveOpenEntryVolumeIndexTest(
|
||||
new[]
|
||||
{
|
||||
new[] { 0, 1 }, //exe - Rar4.multi.part01.rar to Rar4.multi.part02.rar
|
||||
new[] { 1, 5 }, //jpg - Rar4.multi.part02.rar to Rar4.multi.part06.rar
|
||||
new[] { 5, 6 } //txt - Rar4.multi.part06.rar to Rar4.multi.part07.rar
|
||||
},
|
||||
[
|
||||
[0, 1], //exe - Rar4.multi.part01.rar to Rar4.multi.part02.rar
|
||||
[1, 5], //jpg - Rar4.multi.part02.rar to Rar4.multi.part06.rar
|
||||
[5, 6] //txt - Rar4.multi.part06.rar to Rar4.multi.part07.rar
|
||||
],
|
||||
null,
|
||||
"Rar4.multi.part01.rar",
|
||||
"Rar4.multi.part02.rar",
|
||||
|
||||
@@ -13,29 +13,27 @@ public class RarReaderTests : ReaderTests
|
||||
[Fact]
|
||||
public void Rar_Multi_Reader() =>
|
||||
DoRar_Multi_Reader(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar.multi.part01.rar",
|
||||
"Rar.multi.part02.rar",
|
||||
"Rar.multi.part03.rar",
|
||||
"Rar.multi.part04.rar",
|
||||
"Rar.multi.part05.rar",
|
||||
"Rar.multi.part06.rar"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar5_Multi_Reader() =>
|
||||
DoRar_Multi_Reader(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar5.multi.part01.rar",
|
||||
"Rar5.multi.part02.rar",
|
||||
"Rar5.multi.part03.rar",
|
||||
"Rar5.multi.part04.rar",
|
||||
"Rar5.multi.part05.rar",
|
||||
"Rar5.multi.part06.rar"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
private void DoRar_Multi_Reader(string[] archives)
|
||||
@@ -62,15 +60,14 @@ public class RarReaderTests : ReaderTests
|
||||
[Fact]
|
||||
public void Rar_Multi_Reader_Encrypted() =>
|
||||
DoRar_Multi_Reader_Encrypted(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar.EncryptedParts.part01.rar",
|
||||
"Rar.EncryptedParts.part02.rar",
|
||||
"Rar.EncryptedParts.part03.rar",
|
||||
"Rar.EncryptedParts.part04.rar",
|
||||
"Rar.EncryptedParts.part05.rar",
|
||||
"Rar.EncryptedParts.part06.rar"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
private void DoRar_Multi_Reader_Encrypted(string[] archives) =>
|
||||
@@ -99,29 +96,27 @@ public class RarReaderTests : ReaderTests
|
||||
[Fact]
|
||||
public void Rar_Multi_Reader_Delete_Files() =>
|
||||
DoRar_Multi_Reader_Delete_Files(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar.multi.part01.rar",
|
||||
"Rar.multi.part02.rar",
|
||||
"Rar.multi.part03.rar",
|
||||
"Rar.multi.part04.rar",
|
||||
"Rar.multi.part05.rar",
|
||||
"Rar.multi.part06.rar"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
[Fact]
|
||||
public void Rar5_Multi_Reader_Delete_Files() =>
|
||||
DoRar_Multi_Reader_Delete_Files(
|
||||
new[]
|
||||
{
|
||||
[
|
||||
"Rar5.multi.part01.rar",
|
||||
"Rar5.multi.part02.rar",
|
||||
"Rar5.multi.part03.rar",
|
||||
"Rar5.multi.part04.rar",
|
||||
"Rar5.multi.part05.rar",
|
||||
"Rar5.multi.part06.rar"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
private void DoRar_Multi_Reader_Delete_Files(string[] archives)
|
||||
|
||||
@@ -20,7 +20,7 @@ public class LzmaStreamTests
|
||||
}
|
||||
|
||||
private static byte[] LzmaData { get; } =
|
||||
{
|
||||
[
|
||||
0x5D,
|
||||
0x00,
|
||||
0x20,
|
||||
@@ -175,13 +175,13 @@ public class LzmaStreamTests
|
||||
0x76,
|
||||
0x03,
|
||||
0x90
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// The decoded data for <see cref="LzmaData"/>.
|
||||
/// </summary>
|
||||
private static byte[] LzmaResultData { get; } =
|
||||
{
|
||||
[
|
||||
0x01,
|
||||
0x00,
|
||||
0xFD,
|
||||
@@ -510,7 +510,7 @@ public class LzmaStreamTests
|
||||
0x00,
|
||||
0x00,
|
||||
0x00
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void TestLzmaBuffer()
|
||||
|
||||
@@ -10,15 +10,15 @@ namespace SharpCompress.Test;
|
||||
|
||||
public class TestBase : IDisposable
|
||||
{
|
||||
private string SOLUTION_BASE_PATH;
|
||||
protected string TEST_ARCHIVES_PATH;
|
||||
protected string ORIGINAL_FILES_PATH;
|
||||
protected string MISC_TEST_FILES_PATH;
|
||||
private string SCRATCH_BASE_PATH;
|
||||
public string SCRATCH_FILES_PATH;
|
||||
protected string SCRATCH2_FILES_PATH;
|
||||
private readonly string SOLUTION_BASE_PATH;
|
||||
protected readonly string TEST_ARCHIVES_PATH;
|
||||
protected readonly string ORIGINAL_FILES_PATH;
|
||||
protected readonly string MISC_TEST_FILES_PATH;
|
||||
private readonly string SCRATCH_BASE_PATH;
|
||||
protected readonly string SCRATCH_FILES_PATH;
|
||||
protected readonly string SCRATCH2_FILES_PATH;
|
||||
|
||||
public TestBase()
|
||||
protected TestBase()
|
||||
{
|
||||
var index = AppDomain.CurrentDomain.BaseDirectory.IndexOf(
|
||||
"SharpCompress.Test",
|
||||
@@ -110,14 +110,14 @@ public class TestBase : IDisposable
|
||||
Assert.True(extracted.Contains(orig.Key));
|
||||
|
||||
CompareFilesByPath(orig.Single(), extracted[orig.Key].Single());
|
||||
CompareFilesByTimeAndAttribut(orig.Single(), extracted[orig.Key].Single());
|
||||
CompareFilesByTimeAndAttribute(orig.Single(), extracted[orig.Key].Single());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies the files by extension also check modified time and attributes.
|
||||
/// </summary>
|
||||
protected void VerifyFilesByExtensionEx()
|
||||
private void VerifyFilesByExtensionEx()
|
||||
{
|
||||
var extracted = Directory
|
||||
.EnumerateFiles(SCRATCH_FILES_PATH, "*.*", SearchOption.AllDirectories)
|
||||
@@ -133,7 +133,7 @@ public class TestBase : IDisposable
|
||||
Assert.True(extracted.Contains(orig.Key));
|
||||
|
||||
CompareFilesByPath(orig.Single(), extracted[orig.Key].Single());
|
||||
CompareFilesByTimeAndAttribut(orig.Single(), extracted[orig.Key].Single());
|
||||
CompareFilesByTimeAndAttribute(orig.Single(), extracted[orig.Key].Single());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class TestBase : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
protected void CompareFilesByTimeAndAttribut(string file1, string file2)
|
||||
private void CompareFilesByTimeAndAttribute(string file1, string file2)
|
||||
{
|
||||
var fi1 = new FileInfo(file1);
|
||||
var fi2 = new FileInfo(file2);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Lzma2Tests : XzTestsBase
|
||||
[InlineData(40, (uint)(1024 * 1024 * 1024 - 1) * 4 + 3)]
|
||||
public void CalculatesDictionarySize(byte inByte, uint dicSize)
|
||||
{
|
||||
_filter.Init(new[] { inByte });
|
||||
_filter.Init([inByte]);
|
||||
Assert.Equal(_filter.DictionarySize, dicSize);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Lzma2Tests : XzTestsBase
|
||||
public void CalculatesDictionarySizeError()
|
||||
{
|
||||
uint temp;
|
||||
_filter.Init(new byte[] { 41 });
|
||||
_filter.Init([41]);
|
||||
var ex = Assert.Throws<OverflowException>(() =>
|
||||
{
|
||||
temp = _filter.DictionarySize;
|
||||
@@ -59,7 +59,7 @@ public class Lzma2Tests : XzTestsBase
|
||||
[Fact]
|
||||
public void ReservedBytesThrow()
|
||||
{
|
||||
var ex = Assert.Throws<InvalidDataException>(() => _filter.Init(new byte[] { 0xC0 }));
|
||||
var ex = Assert.Throws<InvalidDataException>(() => _filter.Init([0xC0]));
|
||||
Assert.Equal("Reserved bits used in LZMA properties", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class XzHeaderTests : XzTestsBase
|
||||
public void BadVersionIfCrcOkButStreamFlagUnknown()
|
||||
{
|
||||
var bytes = (byte[])Compressed.Clone();
|
||||
byte[] streamFlags = { 0x00, 0xF4 };
|
||||
byte[] streamFlags = [0x00, 0xF4];
|
||||
var crc = Crc32.Compute(streamFlags).ToLittleEndianBytes();
|
||||
streamFlags.CopyTo(bytes, 6);
|
||||
crc.CopyTo(bytes, 8);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class XzIndexTests : XzTestsBase
|
||||
[Fact]
|
||||
public void RecordsStreamStartOnInit()
|
||||
{
|
||||
using Stream badStream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
|
||||
using Stream badStream = new MemoryStream([1, 2, 3, 4, 5]);
|
||||
var br = new BinaryReader(badStream);
|
||||
var index = new XZIndex(br, false);
|
||||
Assert.Equal(0, index.StreamStartPosition);
|
||||
@@ -24,7 +24,7 @@ public class XzIndexTests : XzTestsBase
|
||||
[Fact]
|
||||
public void ThrowsIfHasNoIndexMarker()
|
||||
{
|
||||
using Stream badStream = new MemoryStream(new byte[] { 1, 2, 3, 4, 5 });
|
||||
using Stream badStream = new MemoryStream([1, 2, 3, 4, 5]);
|
||||
var br = new BinaryReader(badStream);
|
||||
var index = new XZIndex(br, false);
|
||||
Assert.Throws<InvalidDataException>(() => index.Process());
|
||||
@@ -71,22 +71,7 @@ public class XzIndexTests : XzTestsBase
|
||||
{
|
||||
// Index with 3-byte padding.
|
||||
using Stream badStream = new MemoryStream(
|
||||
new byte[]
|
||||
{
|
||||
0x00,
|
||||
0x01,
|
||||
0x10,
|
||||
0x80,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xB1,
|
||||
0x01,
|
||||
0xD9,
|
||||
0xC9,
|
||||
0xFF
|
||||
}
|
||||
[0x00, 0x01, 0x10, 0x80, 0x01, 0x00, 0x00, 0x00, 0xB1, 0x01, 0xD9, 0xC9, 0xFF]
|
||||
);
|
||||
var br = new BinaryReader(badStream);
|
||||
var index = new XZIndex(br, false);
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
protected Stream CompressedEmptyStream { get; } = new MemoryStream(CompressedEmpty);
|
||||
|
||||
protected static byte[] CompressedEmpty { get; } =
|
||||
{
|
||||
[
|
||||
0xfd,
|
||||
0x37,
|
||||
0x7a,
|
||||
@@ -62,7 +62,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
0x01,
|
||||
0x59,
|
||||
0x5a
|
||||
};
|
||||
];
|
||||
|
||||
protected static byte[] OriginalEmptyBytes => Encoding.ASCII.GetBytes(OriginalEmpty);
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
protected Stream CompressedStream { get; } = new MemoryStream(Compressed);
|
||||
|
||||
protected static byte[] Compressed { get; } =
|
||||
{
|
||||
[
|
||||
0xfd,
|
||||
0x37,
|
||||
0x7a,
|
||||
@@ -452,7 +452,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
0x04,
|
||||
0x59,
|
||||
0x5a
|
||||
};
|
||||
];
|
||||
protected static byte[] OriginalBytes => Encoding.ASCII.GetBytes(Original);
|
||||
|
||||
protected static string Original { get; } =
|
||||
@@ -479,7 +479,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
protected Stream CompressedIndexedStream { get; } = new MemoryStream(CompressedIndexed);
|
||||
|
||||
protected static byte[] CompressedIndexed { get; } =
|
||||
{
|
||||
[
|
||||
0xfd,
|
||||
0x37,
|
||||
0x7a,
|
||||
@@ -1120,7 +1120,7 @@ public abstract class XzTestsBase : IDisposable
|
||||
0x01,
|
||||
0x59,
|
||||
0x5a
|
||||
};
|
||||
];
|
||||
|
||||
protected static byte[] OriginalIndexedBytes => Encoding.ASCII.GetBytes(OriginalIndexed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user