From 3c2f8bfe33c81fa1718c896d7585eabf37cb578e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Wed, 31 Aug 2022 20:04:34 +0200 Subject: [PATCH] Add test for #2217 --- .../Binarization/AdaptiveThresholdTests.cs | 16 ++++++++++++++++ tests/ImageSharp.Tests/TestImages.cs | 3 +++ .../Issue_2217_AdaptiveThresholdProcessor.png | 3 +++ 3 files changed, 22 insertions(+) create mode 100644 tests/Images/Input/Png/issues/Issue_2217_AdaptiveThresholdProcessor.png diff --git a/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs index 88ad03949..5c725dbf0 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Six Labors. // Licensed under the Six Labors Split License. +using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Processors.Binarization; @@ -125,5 +126,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization image.CompareToReferenceOutput(ImageComparer.Exact, provider); } } + + // https://github.com/SixLabors/ImageSharp/issues/2217 + [Theory] + [WithFile(TestImages.Png.Issue2217, PixelTypes.Rgba32)] + public void Issue_2217_AdaptiveThreshold_DoesNotThrowIndexOutOfRangeException( + TestImageProvider provider) + where TPixel : unmanaged, IPixel + { + Exception exception = Record.Exception(() => + { + using Image image = provider.GetImage(); + }); + + Assert.Null(exception); + } } } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index 306a28dae..082ba9e03 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -125,6 +125,9 @@ namespace SixLabors.ImageSharp.Tests // Discussion 1875: https://github.com/SixLabors/ImageSharp/discussions/1875 public const string Issue1875 = "Png/raw-profile-type-exif.png"; + // Issue 2217: https://github.com/SixLabors/ImageSharp/issues/2217 + public const string Issue2217 = "Png/issues/Issue_2217_AdaptiveThresholdProcessor.png"; + public static class Bad { public const string MissingDataChunk = "Png/xdtn0g01.png"; diff --git a/tests/Images/Input/Png/issues/Issue_2217_AdaptiveThresholdProcessor.png b/tests/Images/Input/Png/issues/Issue_2217_AdaptiveThresholdProcessor.png new file mode 100644 index 000000000..c8a364782 --- /dev/null +++ b/tests/Images/Input/Png/issues/Issue_2217_AdaptiveThresholdProcessor.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0516beb3860c464e9d7bb2e9da678f0ef9bdb5643eeb1675323d5693546c6646 +size 251