Browse Source

Return input value on empty

pull/1574/head
James Jackson-South 6 years ago
parent
commit
b98442ee20
  1. 2
      src/ImageSharp/Formats/Png/Zlib/Adler32.cs
  2. 2
      src/ImageSharp/Formats/Png/Zlib/Crc32.cs
  3. 9
      tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs
  4. 9
      tests/ImageSharp.Tests/Formats/Png/Crc32Tests.cs

2
src/ImageSharp/Formats/Png/Zlib/Adler32.cs

@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
{ {
if (buffer.IsEmpty) if (buffer.IsEmpty)
{ {
return SeedValue; return adler;
} }
#if SUPPORTS_RUNTIME_INTRINSICS #if SUPPORTS_RUNTIME_INTRINSICS

2
src/ImageSharp/Formats/Png/Zlib/Crc32.cs

@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Formats.Png.Zlib
{ {
if (buffer.IsEmpty) if (buffer.IsEmpty)
{ {
return SeedValue; return crc;
} }
#if SUPPORTS_RUNTIME_INTRINSICS #if SUPPORTS_RUNTIME_INTRINSICS

9
tests/ImageSharp.Tests/Formats/Png/Adler32Tests.cs

@ -10,6 +10,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
{ {
public class Adler32Tests public class Adler32Tests
{ {
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
public void ReturnsCorrectWhenEmpty(uint input)
{
Assert.Equal(input, Adler32.Calculate(input, default));
}
[Theory] [Theory]
[InlineData(0)] [InlineData(0)]
[InlineData(8)] [InlineData(8)]

9
tests/ImageSharp.Tests/Formats/Png/Crc32Tests.cs

@ -10,6 +10,15 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
{ {
public class Crc32Tests public class Crc32Tests
{ {
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
public void ReturnsCorrectWhenEmpty(uint input)
{
Assert.Equal(input, Crc32.Calculate(input, default));
}
[Theory] [Theory]
[InlineData(0)] [InlineData(0)]
[InlineData(8)] [InlineData(8)]

Loading…
Cancel
Save