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]
[WithFileCollection(nameof(MiscBmpFiles), PixelTypes.Rgba32)]
public void BmpDecoder_CanDecode_MiscellaneousBitmaps_WithLimitedAllocatorBufferCapacity<TPixel>(
TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
public void BmpDecoder_CanDecode_MiscellaneousBitmaps_WithLimitedAllocatorBufferCapacity(
TestImageProvider<Rgba32> provider)
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
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);
using Image<TPixel> image = provider.GetImage(BmpDecoder);
using Image<Rgba32> image = provider.GetImage(BmpDecoder);
image.DebugSave(provider, nonContiguousBuffersStr);
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);
}
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory]
[WithFile(TestImages.Gif.Giphy, PixelTypes.Rgba32)]
[WithFile(TestImages.Gif.Kumin, PixelTypes.Rgba32)]
public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
public void GifDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(
TestImageProvider<Rgba32> provider)
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
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);
using Image<TPixel> image = provider.GetImage(GifDecoder);
using Image<Rgba32> image = provider.GetImage(GifDecoder);
image.DebugSave(provider, nonContiguousBuffersStr);
image.CompareToOriginal(provider);
}

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

@ -28,26 +28,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
appendPixelTypeToFileName: false);
}
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory]
[WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)]
public void DecodeProgressiveJpeg_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
public void DecodeProgressiveJpeg_WithLimitedAllocatorBufferCapacity(TestImageProvider<Rgba32> provider)
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
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().InBytesSqrt(200);
using Image<TPixel> image = provider.GetImage(JpegDecoder);
using Image<Rgba32> image = provider.GetImage(JpegDecoder);
image.DebugSave(provider, nonContiguousBuffersStr);
provider.Utility.TestName = DecodeProgressiveJpegOutputName;
@ -62,8 +54,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
RemoteExecutor.Invoke(
RunTest,
providerDump,
"Disco")
.Dispose();
"Disco")
.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)
where TPixel : unmanaged, IPixel<TPixel>
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
provider.LimitAllocatorBufferCapacity().InPixelsSqrt(10);
InvalidImageContentException ex = Assert.Throws<InvalidImageContentException>(() => provider.GetImage(PngDecoder));
Assert.IsType<InvalidMemoryOperationException>(ex.InnerException);
}
[ActiveIssue("https://github.com/dotnet/arcade/issues/6393", TargetFrameworkMonikers.NetFramework)]
[Theory]
[WithFile(TestImages.Png.Splash, PixelTypes.Rgba32)]
[WithFile(TestImages.Png.Bike, PixelTypes.Rgba32)]
public void PngDecoder_CanDecode_WithLimitedAllocatorBufferCapacity<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
public void PngDecoder_CanDecode_WithLimitedAllocatorBufferCapacity(TestImageProvider<Rgba32> provider)
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
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);
using Image<TPixel> image = provider.GetImage(PngDecoder);
using Image<Rgba32> image = provider.GetImage(PngDecoder);
image.DebugSave(provider, testOutputDetails: nonContiguousBuffersStr);
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]
[WithTestPatternImages(100, 100, PixelTypes.Rgba32)]
public void EncodeWorksWithoutSsse3Intrinsics<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
public void EncodeWorksWithoutSsse3Intrinsics(TestImageProvider<Rgba32> provider)
{
// dotnet xunit doesn't respect filter.
if (TestEnvironment.IsFramework)
{
return;
}
static void RunTest(string providerDump)
{
TestImageProvider<TPixel> provider =
BasicSerializer.Deserialize<TestImageProvider<TPixel>>(providerDump);
TestImageProvider<Rgba32> provider =
BasicSerializer.Deserialize<TestImageProvider<Rgba32>>(providerDump);
#if SUPPORTS_RUNTIME_INTRINSICS
Assert.False(Ssse3.IsSupported);
#endif

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

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

Loading…
Cancel
Save