Browse Source

Don't use generics.

Could have saved myself days of issues if i'd just thought of this first.
js/color-alpha-handling
James Jackson-South 5 years ago
parent
commit
45f303d094
  1. 16
      tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs
  2. 16
      tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
  3. 20
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs
  4. 20
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  5. 14
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
  6. 14
      tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs

16
tests/ImageSharp.Tests/Formats/Bmp/BmpDecoderTests.cs

@ -52,26 +52,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
} }
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithFileCollection(nameof(MiscBmpFiles), PixelTypes.Rgba32)] [WithFileCollection(nameof(MiscBmpFiles), PixelTypes.Rgba32)]
public void BmpDecoder_CanDecode_MiscellaneousBitmaps_WithLimitedAllocatorBufferCapacity<TPixel>( public void BmpDecoder_CanDecode_MiscellaneousBitmaps_WithLimitedAllocatorBufferCapacity(
TestImageProvider<TPixel> provider) TestImageProvider<Rgba32> provider)
where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump, string nonContiguousBuffersStr) static void RunTest(string providerDump, string nonContiguousBuffersStr)
{ {
TestImageProvider<TPixel> provider = BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); TestImageProvider<Rgba32> provider = BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100); provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100);
using Image<TPixel> image = provider.GetImage(BmpDecoder); using Image<Rgba32> image = provider.GetImage(BmpDecoder);
image.DebugSave(provider, nonContiguousBuffersStr); image.DebugSave(provider, nonContiguousBuffersStr);
if (TestEnvironment.IsWindows) if (TestEnvironment.IsWindows)

16
tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

@ -195,26 +195,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
Assert.IsType<InvalidMemoryOperationException>(ex.InnerException); Assert.IsType<InvalidMemoryOperationException>(ex.InnerException);
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)]
[WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)] [WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)]
public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider) public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(
where TPixel : unmanaged, IPixel<TPixel> TestImageProvider<Rgba32> provider)
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump, string nonContiguousBuffersStr) static void RunTest(string providerDump, string nonContiguousBuffersStr)
{ {
TestImageProvider<TPixel> provider = BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); TestImageProvider<Rgba32> provider
= BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100); provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100);
using Image<TPixel> image = provider.GetImage(GifDecoder); using Image<Rgba32> image = provider.GetImage(GifDecoder);
image.DebugSave(provider, nonContiguousBuffersStr); image.DebugSave(provider, nonContiguousBuffersStr);
image.CompareToOriginal(provider); image.CompareToOriginal(provider);
} }

20
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Progressive.cs

@ -28,26 +28,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
appendPixelTypeToFileName: false); appendPixelTypeToFileName: false);
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)] [WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)]
public void DecodeProgressiveJpeg_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider) public void DecodeProgressiveJpeg_WithLimitedAllocatorBufferCapacity(TestImageProvider<Rgba32> provider)
where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump, string nonContiguousBuffersStr) static void RunTest(string providerDump, string nonContiguousBuffersStr)
{ {
TestImageProvider<TPixel> provider = TestImageProvider<Rgba32> provider =
BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
provider.LimitAllocatorBufferCapacity().InBytesSqrt(200); provider.LimitAllocatorBufferCapacity().InBytesSqrt(200);
using Image<TPixel> image = provider.GetImage(JpegDecoder); using Image<Rgba32> image = provider.GetImage(JpegDecoder);
image.DebugSave(provider, nonContiguousBuffersStr); image.DebugSave(provider, nonContiguousBuffersStr);
provider.Utility.TestName = DecodeProgressiveJpegOutputName; provider.Utility.TestName = DecodeProgressiveJpegOutputName;
@ -62,8 +54,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
RemoteExecutor.Invoke( RemoteExecutor.Invoke(
RunTest, RunTest,
providerDump, providerDump,
"Disco") "Disco")
.Dispose(); .Dispose();
} }
} }
} }

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

@ -396,37 +396,23 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
public void PngDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException<TPixel>(TestImageProvider<TPixel> provider) public void PngDecoder_DegenerateMemoryRequest_ShouldTranslateTo_ImageFormatException<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10); provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
InvalidImageContentException ex = Assert.Throws<InvalidImageContentException>(() => provider.GetImage(PngDecoder)); InvalidImageContentException ex = Assert.Throws<InvalidImageContentException>(() => provider.GetImage(PngDecoder));
Assert.IsType<InvalidMemoryOperationException>(ex.InnerException); Assert.IsType<InvalidMemoryOperationException>(ex.InnerException);
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)]
public void PngDecoder_CanDecode_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider) public void PngDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider<Rgba32> provider)
where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump, string nonContiguousBuffersStr) static void RunTest(string providerDump, string nonContiguousBuffersStr)
{ {
TestImageProvider<TPixel> provider = BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); TestImageProvider<Rgba32> provider = BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100); provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100);
using Image<TPixel> image = provider.GetImage(PngDecoder); using Image<Rgba32> image = provider.GetImage(PngDecoder);
image.DebugSave(provider, testOutputDetails: nonContiguousBuffersStr); image.DebugSave(provider, testOutputDetails: nonContiguousBuffersStr);
image.CompareToOriginal(provider); image.CompareToOriginal(provider);
} }

14
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -534,22 +534,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
} }
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32)] [WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
public void EncodeWorksWithoutSsse3Intrinsics<TPixel>(TestImageProvider<TPixel> provider) public void EncodeWorksWithoutSsse3Intrinsics(TestImageProvider<Rgba32> provider)
where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump) static void RunTest(string providerDump)
{ {
TestImageProvider<TPixel> provider = TestImageProvider<Rgba32> provider =
BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
#if SUPPORTS_RUNTIME_INTRINSICS #if SUPPORTS_RUNTIME_INTRINSICS
Assert.False(Ssse3.IsSupported); Assert.False(Ssse3.IsSupported);
#endif #endif

14
tests/ImageSharp.Tests/Formats/Tga/TgaDecoderTests.cs

@ -744,26 +744,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tga
Assert.IsType<InvalidMemoryOperationException>(ex.InnerException); Assert.IsType<InvalidMemoryOperationException>(ex.InnerException);
} }
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory] [Theory]
[WithFile(Bit24BottomLeft, PixelTypes.Rgba32)] [WithFile(Bit24BottomLeft, PixelTypes.Rgba32)]
[WithFile(Bit32BottomLeft, PixelTypes.Rgba32)] [WithFile(Bit32BottomLeft, PixelTypes.Rgba32)]
public void TgaDecoder_CanDecode_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider) public void TgaDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider<Rgba32> provider)
where TPixel : unmanaged, IPixel<TPixel>
{ {
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump, string nonContiguousBuffersStr) static void RunTest(string providerDump, string nonContiguousBuffersStr)
{ {
TestImageProvider<TPixel> provider = BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump); TestImageProvider<Rgba32> provider = BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100); provider.LimitAllocatorBufferCapacity().InPixelsSqrt(100);
using Image<TPixel> image = provider.GetImage(TgaDecoder); using Image<Rgba32> image = provider.GetImage(TgaDecoder);
image.DebugSave(provider, testOutputDetails: nonContiguousBuffersStr); image.DebugSave(provider, testOutputDetails: nonContiguousBuffersStr);
if (TestEnvironment.IsWindows) if (TestEnvironment.IsWindows)

Loading…
Cancel
Save