Browse Source

Add tests for missing palette chunk

pull/2020/head
Brian Popow 4 years ago
parent
commit
d98171fa54
  1. 16
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  2. 2
      tests/ImageSharp.Tests/TestImages.cs
  3. 3
      tests/Images/Input/Png/missing_plte.png
  4. 3
      tests/Images/Input/Png/missing_plte_2.png

16
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -265,6 +265,22 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
Assert.Contains("PNG Image does not contain a data chunk", ex.Message);
}
[Theory]
[WithFile(TestImages.Png.Bad.MissingPaletteChunk1, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.Bad.MissingPaletteChunk2, PixelTypes.Rgba32)]
public void Decode_MissingPaletteChunk_ThrowsException<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
Exception ex = Record.Exception(
() =>
{
using Image<TPixel> image = provider.GetImage(PngDecoder);
image.DebugSave(provider);
});
Assert.NotNull(ex);
Assert.Contains("PNG Image does not contain palette chunk", ex.Message);
}
[Theory]
[WithFile(TestImages.Png.Bad.BitDepthZero, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.Bad.BitDepthThree, PixelTypes.Rgba32)]

2
tests/ImageSharp.Tests/TestImages.cs

@ -127,6 +127,8 @@ namespace SixLabors.ImageSharp.Tests
public const string MissingDataChunk = "Png/xdtn0g01.png";
public const string WrongCrcDataChunk = "Png/xcsn0g01.png";
public const string CorruptedChunk = "Png/big-corrupted-chunk.png";
public const string MissingPaletteChunk1 = "Png/missing_plte.png";
public const string MissingPaletteChunk2 = "Png/missing_plte_2.png";
// Zlib errors.
public const string ZlibOverflow = "Png/zlib-overflow.png";

3
tests/Images/Input/Png/missing_plte.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:73fd17a394f8258f4767986bc427c0160277819349c937f18cb29044e7549bc8
size 506

3
tests/Images/Input/Png/missing_plte_2.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:797844db61a937c6f31ecb392c8416fbf106017413ba55c6576e0b1fcfc1cf9c
size 597
Loading…
Cancel
Save