From e9dd413de61ff8f77615318bea4b814ad3327c7e Mon Sep 17 00:00:00 2001
From: Nanook <188841+Nanook@users.noreply.github.com>
Date: Thu, 24 Jul 2025 00:46:09 +0100
Subject: [PATCH] CSharpier formatting.
---
src/SharpCompress/Writers/WriterOptions.cs | 2 +-
src/SharpCompress/Writers/Zip/ZipWriter.cs | 11 +-
.../Writers/Zip/ZipWriterEntryOptions.cs | 13 +-
.../Writers/Zip/ZipWriterOptions.cs | 14 +-
tests/SharpCompress.Test/ArchiveTests.cs | 70 +++++++---
.../Zip/TestPseudoTextStream.cs | 6 +-
.../Zip/ZipMemoryArchiveWithCrcTests.cs | 131 ++++++++++++------
7 files changed, 174 insertions(+), 73 deletions(-)
diff --git a/src/SharpCompress/Writers/WriterOptions.cs b/src/SharpCompress/Writers/WriterOptions.cs
index 972cc83b..361dfb55 100644
--- a/src/SharpCompress/Writers/WriterOptions.cs
+++ b/src/SharpCompress/Writers/WriterOptions.cs
@@ -14,7 +14,7 @@ public class WriterOptions : OptionsBase
CompressionType.Deflate => (int)D.CompressionLevel.Default,
CompressionType.Deflate64 => (int)D.CompressionLevel.Default,
CompressionType.GZip => (int)D.CompressionLevel.Default,
- _ => 0
+ _ => 0,
};
}
diff --git a/src/SharpCompress/Writers/Zip/ZipWriter.cs b/src/SharpCompress/Writers/Zip/ZipWriter.cs
index b03f72e1..097e8fd0 100644
--- a/src/SharpCompress/Writers/Zip/ZipWriter.cs
+++ b/src/SharpCompress/Writers/Zip/ZipWriter.cs
@@ -364,7 +364,11 @@ public class ZipWriter : AbstractWriter
}
case ZipCompressionMethod.Deflate:
{
- return new DeflateStream(counting, CompressionMode.Compress, (CompressionLevel)compressionLevel);
+ return new DeflateStream(
+ counting,
+ CompressionMode.Compress,
+ (CompressionLevel)compressionLevel
+ );
}
case ZipCompressionMethod.BZip2:
{
@@ -392,7 +396,10 @@ public class ZipWriter : AbstractWriter
}
case ZipCompressionMethod.ZStandard:
{
- return new ZstdSharp.CompressionStream(counting, (int)writer.WriterOptions.CompressionLevel);
+ return new ZstdSharp.CompressionStream(
+ counting,
+ (int)writer.WriterOptions.CompressionLevel
+ );
}
default:
{
diff --git a/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs b/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs
index c40306b7..dcadb21c 100644
--- a/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs
+++ b/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs
@@ -26,10 +26,15 @@ public class ZipWriterEntryOptions
///
/// This property is deprecated. Use instead.
///
- [Obsolete("Use CompressionLevel property instead. This property will be removed in a future version.")]
- public CompressionLevel? DeflateCompressionLevel
- {
- get => CompressionLevel.HasValue ? (CompressionLevel)Math.Min(CompressionLevel.Value, 9) : null;
+ [Obsolete(
+ "Use CompressionLevel property instead. This property will be removed in a future version."
+ )]
+ public CompressionLevel? DeflateCompressionLevel
+ {
+ get =>
+ CompressionLevel.HasValue
+ ? (CompressionLevel)Math.Min(CompressionLevel.Value, 9)
+ : null;
set => CompressionLevel = value.HasValue ? (int)value.Value : null;
}
diff --git a/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs b/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs
index a2516d21..9aa80dd1 100644
--- a/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs
+++ b/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs
@@ -7,7 +7,10 @@ namespace SharpCompress.Writers.Zip;
public class ZipWriterOptions : WriterOptions
{
- public ZipWriterOptions(CompressionType compressionType, CompressionLevel compressionLevel = D.CompressionLevel.Default)
+ public ZipWriterOptions(
+ CompressionType compressionType,
+ CompressionLevel compressionLevel = D.CompressionLevel.Default
+ )
: base(compressionType, (int)compressionLevel) { }
internal ZipWriterOptions(WriterOptions options)
@@ -43,7 +46,10 @@ public class ZipWriterOptions : WriterOptions
public void SetZStandardCompressionLevel(int level)
{
if (level < 1 || level > 22)
- throw new ArgumentOutOfRangeException(nameof(level), "ZStandard compression level must be between 1 and 22");
+ throw new ArgumentOutOfRangeException(
+ nameof(level),
+ "ZStandard compression level must be between 1 and 22"
+ );
CompressionLevel = level;
}
@@ -55,7 +61,9 @@ public class ZipWriterOptions : WriterOptions
///
/// This property is deprecated. Use or instead.
///
- [Obsolete("Use CompressionLevel property or SetDeflateCompressionLevel method instead. This property will be removed in a future version.")]
+ [Obsolete(
+ "Use CompressionLevel property or SetDeflateCompressionLevel method instead. This property will be removed in a future version."
+ )]
public CompressionLevel DeflateCompressionLevel
{
get => (CompressionLevel)Math.Min(CompressionLevel, 9);
diff --git a/tests/SharpCompress.Test/ArchiveTests.cs b/tests/SharpCompress.Test/ArchiveTests.cs
index 6796c914..121d8dea 100644
--- a/tests/SharpCompress.Test/ArchiveTests.cs
+++ b/tests/SharpCompress.Test/ArchiveTests.cs
@@ -352,7 +352,11 @@ public class ArchiveTests : ReaderTests
///
/// Creates a writer with the specified compression type and level
///
- protected static IWriter CreateWriterWithLevel(Stream stream, CompressionType compressionType, int? compressionLevel = null)
+ protected static IWriter CreateWriterWithLevel(
+ Stream stream,
+ CompressionType compressionType,
+ int? compressionLevel = null
+ )
{
var writerOptions = new ZipWriterOptions(compressionType);
if (compressionLevel.HasValue)
@@ -365,7 +369,10 @@ public class ArchiveTests : ReaderTests
///
/// Verifies archive content against expected files with CRC32 validation
///
- protected void VerifyArchiveContent(MemoryStream zipStream, Dictionary expectedFiles)
+ protected void VerifyArchiveContent(
+ MemoryStream zipStream,
+ Dictionary expectedFiles
+ )
{
zipStream.Position = 0;
using var archive = ArchiveFactory.Open(zipStream);
@@ -378,14 +385,17 @@ public class ArchiveTests : ReaderTests
entryStream.CopyTo(extractedStream);
var extractedData = extractedStream.ToArray();
- Assert.True(expectedFiles.ContainsKey(entry.Key.NotNull()), $"Unexpected entry: {entry.Key}");
+ Assert.True(
+ expectedFiles.ContainsKey(entry.Key.NotNull()),
+ $"Unexpected entry: {entry.Key}"
+ );
var (expectedData, expectedCrc) = expectedFiles[entry.Key.NotNull()];
var actualCrc = CalculateCrc32(extractedData);
Assert.Equal(expectedCrc, actualCrc);
Assert.Equal(expectedData.Length, extractedData.Length);
-
+
// For large files, spot check rather than full comparison for performance
if (expectedData.Length > 1024 * 1024)
{
@@ -407,23 +417,37 @@ public class ArchiveTests : ReaderTests
Assert.Equal(expected.Take(1024), actual.Take(1024));
var mid = expected.Length / 2;
Assert.Equal(expected.Skip(mid).Take(1024), actual.Skip(mid).Take(1024));
- Assert.Equal(expected.Skip(Math.Max(0, expected.Length - 1024)), actual.Skip(Math.Max(0, actual.Length - 1024)));
+ Assert.Equal(
+ expected.Skip(Math.Max(0, expected.Length - 1024)),
+ actual.Skip(Math.Max(0, actual.Length - 1024))
+ );
}
///
/// Verifies compression ratio meets expectations
///
- protected void VerifyCompressionRatio(long originalSize, long compressedSize, double maxRatio, string context)
+ protected void VerifyCompressionRatio(
+ long originalSize,
+ long compressedSize,
+ double maxRatio,
+ string context
+ )
{
var compressionRatio = (double)compressedSize / originalSize;
- Assert.True(compressionRatio < maxRatio,
- $"Expected better compression for {context}. Original: {originalSize}, Compressed: {compressedSize}, Ratio: {compressionRatio:P}");
+ Assert.True(
+ compressionRatio < maxRatio,
+ $"Expected better compression for {context}. Original: {originalSize}, Compressed: {compressedSize}, Ratio: {compressionRatio:P}"
+ );
}
///
/// Creates a memory-based archive with specified files and compression
///
- protected MemoryStream CreateMemoryArchive(Dictionary files, CompressionType compressionType, int? compressionLevel = null)
+ protected MemoryStream CreateMemoryArchive(
+ Dictionary files,
+ CompressionType compressionType,
+ int? compressionLevel = null
+ )
{
var zipStream = new MemoryStream();
using (var writer = CreateWriterWithLevel(zipStream, compressionType, compressionLevel))
@@ -465,7 +489,8 @@ public class ArchiveTests : ReaderTests
Dictionary testFiles,
CompressionType compressionType,
int? compressionLevel = null,
- double maxCompressionRatio = 0.8)
+ double maxCompressionRatio = 0.8
+ )
{
// Calculate expected CRCs
var expectedFiles = testFiles.ToDictionary(
@@ -480,7 +505,12 @@ public class ArchiveTests : ReaderTests
if (compressionType != CompressionType.None)
{
var originalSize = testFiles.Values.Sum(data => (long)data.Length);
- VerifyCompressionRatio(originalSize, zipStream.Length, maxCompressionRatio, compressionType.ToString());
+ VerifyCompressionRatio(
+ originalSize,
+ zipStream.Length,
+ maxCompressionRatio,
+ compressionType.ToString()
+ );
}
// Verify content
@@ -490,11 +520,14 @@ public class ArchiveTests : ReaderTests
///
/// Verifies archive entries have correct compression type
///
- protected void VerifyCompressionType(MemoryStream zipStream, CompressionType expectedCompressionType)
+ protected void VerifyCompressionType(
+ MemoryStream zipStream,
+ CompressionType expectedCompressionType
+ )
{
zipStream.Position = 0;
using var archive = ArchiveFactory.Open(zipStream);
-
+
foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
{
Assert.Equal(expectedCompressionType, entry.CompressionType);
@@ -504,21 +537,24 @@ public class ArchiveTests : ReaderTests
///
/// Extracts and verifies a single entry from archive
///
- protected (byte[] data, uint crc) ExtractAndVerifyEntry(MemoryStream zipStream, string entryName)
+ protected (byte[] data, uint crc) ExtractAndVerifyEntry(
+ MemoryStream zipStream,
+ string entryName
+ )
{
zipStream.Position = 0;
using var archive = ArchiveFactory.Open(zipStream);
-
+
var entry = archive.Entries.FirstOrDefault(e => e.Key == entryName && !e.IsDirectory);
Assert.NotNull(entry);
using var entryStream = entry.OpenEntryStream();
using var extractedStream = new MemoryStream();
entryStream.CopyTo(extractedStream);
-
+
var extractedData = extractedStream.ToArray();
var crc = CalculateCrc32(extractedData);
-
+
return (extractedData, crc);
}
}
diff --git a/tests/SharpCompress.Test/Zip/TestPseudoTextStream.cs b/tests/SharpCompress.Test/Zip/TestPseudoTextStream.cs
index b9687a5c..7c6f8b02 100644
--- a/tests/SharpCompress.Test/Zip/TestPseudoTextStream.cs
+++ b/tests/SharpCompress.Test/Zip/TestPseudoTextStream.cs
@@ -6,6 +6,7 @@ using System.Text;
using System.Threading.Tasks;
namespace SharpCompress.Test.Zip;
+
///
/// Generates pseudo English-style text for testing - Nanook
///
@@ -92,6 +93,9 @@ internal class TestPseudoTextStream : Stream
}
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
+
public override void SetLength(long value) => throw new NotSupportedException();
- public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
+
+ public override void Write(byte[] buffer, int offset, int count) =>
+ throw new NotSupportedException();
}
diff --git a/tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcTests.cs b/tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcTests.cs
index 36869dea..0e66edc2 100644
--- a/tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcTests.cs
+++ b/tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcTests.cs
@@ -19,23 +19,28 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
public ZipTypesLevelsWithCrcRatioTests() => UseExtensionInsteadOfNameToVerify = true;
[Theory]
- [InlineData(CompressionType.Deflate, 1, 1, 0.11f)] // was 0.8f, actual 0.104
- [InlineData(CompressionType.Deflate, 3, 1, 0.08f)] // was 0.8f, actual 0.078
- [InlineData(CompressionType.Deflate, 6, 1, 0.05f)] // was 0.8f, actual ~0.042
- [InlineData(CompressionType.Deflate, 9, 1, 0.04f)] // was 0.7f, actual 0.038
- [InlineData(CompressionType.ZStandard, 1, 1, 0.025f)] // was 0.8f, actual 0.023
- [InlineData(CompressionType.ZStandard, 3, 1, 0.015f)] // was 0.7f, actual 0.013
- [InlineData(CompressionType.ZStandard, 9, 1, 0.006f)] // was 0.7f, actual 0.005
+ [InlineData(CompressionType.Deflate, 1, 1, 0.11f)] // was 0.8f, actual 0.104
+ [InlineData(CompressionType.Deflate, 3, 1, 0.08f)] // was 0.8f, actual 0.078
+ [InlineData(CompressionType.Deflate, 6, 1, 0.05f)] // was 0.8f, actual ~0.042
+ [InlineData(CompressionType.Deflate, 9, 1, 0.04f)] // was 0.7f, actual 0.038
+ [InlineData(CompressionType.ZStandard, 1, 1, 0.025f)] // was 0.8f, actual 0.023
+ [InlineData(CompressionType.ZStandard, 3, 1, 0.015f)] // was 0.7f, actual 0.013
+ [InlineData(CompressionType.ZStandard, 9, 1, 0.006f)] // was 0.7f, actual 0.005
[InlineData(CompressionType.ZStandard, 22, 1, 0.005f)] // was 0.7f, actual 0.004
- [InlineData(CompressionType.BZip2, 0, 1, 0.035f)] // was 0.8f, actual 0.033
- [InlineData(CompressionType.LZMA, 0, 1, 0.005f)] // was 0.8f, actual 0.004
- [InlineData(CompressionType.None, 0, 1, 1.001f)] // was 1.1f, actual 1.000
- [InlineData(CompressionType.Deflate, 6, 2, 0.045f)] // was 0.8f, actual 0.042
- [InlineData(CompressionType.ZStandard, 3, 2, 0.012f)] // was 0.7f, actual 0.010
- [InlineData(CompressionType.BZip2, 0, 2, 0.035f)] // was 0.8f, actual 0.032
- [InlineData(CompressionType.Deflate, 9, 3, 0.04f)] // was 0.7f, actual 0.038
- [InlineData(CompressionType.ZStandard, 9, 3, 0.003f)] // was 0.7f, actual 0.002
- public void Zip_Create_Archive_With_3_Files_Crc32_Test(CompressionType compressionType, int compressionLevel, int sizeMb, float expectedRatio)
+ [InlineData(CompressionType.BZip2, 0, 1, 0.035f)] // was 0.8f, actual 0.033
+ [InlineData(CompressionType.LZMA, 0, 1, 0.005f)] // was 0.8f, actual 0.004
+ [InlineData(CompressionType.None, 0, 1, 1.001f)] // was 1.1f, actual 1.000
+ [InlineData(CompressionType.Deflate, 6, 2, 0.045f)] // was 0.8f, actual 0.042
+ [InlineData(CompressionType.ZStandard, 3, 2, 0.012f)] // was 0.7f, actual 0.010
+ [InlineData(CompressionType.BZip2, 0, 2, 0.035f)] // was 0.8f, actual 0.032
+ [InlineData(CompressionType.Deflate, 9, 3, 0.04f)] // was 0.7f, actual 0.038
+ [InlineData(CompressionType.ZStandard, 9, 3, 0.003f)] // was 0.7f, actual 0.002
+ public void Zip_Create_Archive_With_3_Files_Crc32_Test(
+ CompressionType compressionType,
+ int compressionLevel,
+ int sizeMb,
+ float expectedRatio
+ )
{
const int OneMiB = 1024 * 1024;
var baseSize = sizeMb * OneMiB;
@@ -49,7 +54,7 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
{
[$"file1_{sizeMb}MiB.txt"] = (file1Data, CalculateCrc32(file1Data)),
[$"data/file2_{sizeMb * 2}MiB.txt"] = (file2Data, CalculateCrc32(file2Data)),
- [$"deep/nested/file3_{sizeMb * 3}MiB.txt"] = (file3Data, CalculateCrc32(file3Data))
+ [$"deep/nested/file3_{sizeMb * 3}MiB.txt"] = (file3Data, CalculateCrc32(file3Data)),
};
// Create zip archive in memory
@@ -69,11 +74,19 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
// Verify compression occurred (except for None compression type)
if (compressionType != CompressionType.None)
{
- Assert.True(zipStream.Length < originalSize, $"Compression failed: compressed={zipStream.Length}, original={originalSize}");
+ Assert.True(
+ zipStream.Length < originalSize,
+ $"Compression failed: compressed={zipStream.Length}, original={originalSize}"
+ );
}
// Verify compression ratio
- VerifyCompressionRatio(originalSize, zipStream.Length, expectedRatio, $"{compressionType} level {compressionLevel}");
+ VerifyCompressionRatio(
+ originalSize,
+ zipStream.Length,
+ expectedRatio,
+ $"{compressionType} level {compressionLevel}"
+ );
// Verify archive content and CRC32
VerifyArchiveContent(zipStream, expectedFiles);
@@ -83,17 +96,22 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
}
[Theory]
- [InlineData(CompressionType.Deflate, 1, 4, 0.11f)] // was 0.8, actual 0.105
- [InlineData(CompressionType.Deflate, 3, 4, 0.08f)] // was 0.8, actual 0.077
- [InlineData(CompressionType.Deflate, 6, 4, 0.045f)] // was 0.8, actual 0.042
- [InlineData(CompressionType.Deflate, 9, 4, 0.04f)] // was 0.8, actual 0.037
- [InlineData(CompressionType.ZStandard, 1, 4, 0.025f)] // was 0.8, actual 0.022
- [InlineData(CompressionType.ZStandard, 3, 4, 0.012f)] // was 0.8, actual 0.010
- [InlineData(CompressionType.ZStandard, 9, 4, 0.003f)] // was 0.8, actual 0.002
+ [InlineData(CompressionType.Deflate, 1, 4, 0.11f)] // was 0.8, actual 0.105
+ [InlineData(CompressionType.Deflate, 3, 4, 0.08f)] // was 0.8, actual 0.077
+ [InlineData(CompressionType.Deflate, 6, 4, 0.045f)] // was 0.8, actual 0.042
+ [InlineData(CompressionType.Deflate, 9, 4, 0.04f)] // was 0.8, actual 0.037
+ [InlineData(CompressionType.ZStandard, 1, 4, 0.025f)] // was 0.8, actual 0.022
+ [InlineData(CompressionType.ZStandard, 3, 4, 0.012f)] // was 0.8, actual 0.010
+ [InlineData(CompressionType.ZStandard, 9, 4, 0.003f)] // was 0.8, actual 0.002
[InlineData(CompressionType.ZStandard, 22, 4, 0.003f)] // was 0.8, actual 0.002
- [InlineData(CompressionType.BZip2, 0, 4, 0.035f)] // was 0.8, actual 0.032
- [InlineData(CompressionType.LZMA, 0, 4, 0.003f)] // was 0.8, actual 0.002
- public void Zip_WriterFactory_Crc32_Test(CompressionType compressionType, int compressionLevel, int sizeMb, float expectedRatio)
+ [InlineData(CompressionType.BZip2, 0, 4, 0.035f)] // was 0.8, actual 0.032
+ [InlineData(CompressionType.LZMA, 0, 4, 0.003f)] // was 0.8, actual 0.002
+ public void Zip_WriterFactory_Crc32_Test(
+ CompressionType compressionType,
+ int compressionLevel,
+ int sizeMb,
+ float expectedRatio
+ )
{
var fileSize = sizeMb * 1024 * 1024;
@@ -102,18 +120,29 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
// Create archive with specified compression level
using var zipStream = new MemoryStream();
- var writerOptions = new ZipWriterOptions(compressionType) { CompressionLevel = compressionLevel };
+ var writerOptions = new ZipWriterOptions(compressionType)
+ {
+ CompressionLevel = compressionLevel,
+ };
using (var writer = WriterFactory.Open(zipStream, ArchiveType.Zip, writerOptions))
{
- writer.Write($"{compressionType}_level_{compressionLevel}_{sizeMb}MiB.txt", new MemoryStream(testData));
+ writer.Write(
+ $"{compressionType}_level_{compressionLevel}_{sizeMb}MiB.txt",
+ new MemoryStream(testData)
+ );
}
// Calculate and output actual compression ratio
var actualRatio = (double)zipStream.Length / testData.Length;
//Debug.WriteLine($"Zip_WriterFactory_Crc32_Test: {compressionType} Level={compressionLevel} Size={sizeMb}MB Expected={expectedRatio:F3} Actual={actualRatio:F3}");
- VerifyCompressionRatio(testData.Length, zipStream.Length, expectedRatio, $"{compressionType} level {compressionLevel}");
+ VerifyCompressionRatio(
+ testData.Length,
+ zipStream.Length,
+ expectedRatio,
+ $"{compressionType} level {compressionLevel}"
+ );
// Verify the archive
zipStream.Position = 0;
@@ -134,17 +163,22 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
}
[Theory]
- [InlineData(CompressionType.Deflate, 1, 2, 0.11f)] // was 0.8, actual 0.104
- [InlineData(CompressionType.Deflate, 3, 2, 0.08f)] // was 0.8, actual 0.077
- [InlineData(CompressionType.Deflate, 6, 2, 0.045f)] // was 0.8, actual 0.042
- [InlineData(CompressionType.Deflate, 9, 2, 0.04f)] // was 0.7, actual 0.038
- [InlineData(CompressionType.ZStandard, 1, 2, 0.025f)] // was 0.8, actual 0.023
- [InlineData(CompressionType.ZStandard, 3, 2, 0.015f)] // was 0.7, actual 0.012
- [InlineData(CompressionType.ZStandard, 9, 2, 0.006f)] // was 0.7, actual 0.005
+ [InlineData(CompressionType.Deflate, 1, 2, 0.11f)] // was 0.8, actual 0.104
+ [InlineData(CompressionType.Deflate, 3, 2, 0.08f)] // was 0.8, actual 0.077
+ [InlineData(CompressionType.Deflate, 6, 2, 0.045f)] // was 0.8, actual 0.042
+ [InlineData(CompressionType.Deflate, 9, 2, 0.04f)] // was 0.7, actual 0.038
+ [InlineData(CompressionType.ZStandard, 1, 2, 0.025f)] // was 0.8, actual 0.023
+ [InlineData(CompressionType.ZStandard, 3, 2, 0.015f)] // was 0.7, actual 0.012
+ [InlineData(CompressionType.ZStandard, 9, 2, 0.006f)] // was 0.7, actual 0.005
[InlineData(CompressionType.ZStandard, 22, 2, 0.005f)] // was 0.7, actual 0.004
- [InlineData(CompressionType.BZip2, 0, 2, 0.035f)] // was 0.8, actual 0.032
- [InlineData(CompressionType.LZMA, 0, 2, 0.005f)] // was 0.8, actual 0.004
- public void Zip_ZipArchiveOpen_Crc32_Test(CompressionType compressionType, int compressionLevel, int sizeMb, float expectedRatio)
+ [InlineData(CompressionType.BZip2, 0, 2, 0.035f)] // was 0.8, actual 0.032
+ [InlineData(CompressionType.LZMA, 0, 2, 0.005f)] // was 0.8, actual 0.004
+ public void Zip_ZipArchiveOpen_Crc32_Test(
+ CompressionType compressionType,
+ int compressionLevel,
+ int sizeMb,
+ float expectedRatio
+ )
{
var fileSize = sizeMb * 1024 * 1024;
@@ -155,7 +189,10 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
using var zipStream = new MemoryStream();
using (var writer = CreateWriterWithLevel(zipStream, compressionType, compressionLevel))
{
- writer.Write($"{compressionType}_{compressionLevel}_{sizeMb}MiB.txt", new MemoryStream(testData));
+ writer.Write(
+ $"{compressionType}_{compressionLevel}_{sizeMb}MiB.txt",
+ new MemoryStream(testData)
+ );
}
// Calculate and output actual compression ratio
@@ -188,7 +225,11 @@ public class ZipTypesLevelsWithCrcRatioTests : ArchiveTests
VerifyDataSpotCheck(testData, extractedData);
}
- VerifyCompressionRatio(testData.Length, zipStream.Length, expectedRatio, $"{compressionType} Level {compressionLevel}");
+ VerifyCompressionRatio(
+ testData.Length,
+ zipStream.Length,
+ expectedRatio,
+ $"{compressionType} Level {compressionLevel}"
+ );
}
-
}