From f4727d1d3480d2b01d0619051ec5ada0959dbb71 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Mon, 27 Mar 2023 18:13:52 +0200 Subject: [PATCH] Add test for GetConverter with cmyk color space which uses FeatureTestRunner to disable specific hw features --- .../Formats/Jpg/JpegColorConverterTests.cs | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index 93c246e7c..bb6a67403 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -72,7 +72,7 @@ public class JpegColorConverterTests } [Fact] - public void GetConverterReturnsValidConverterWithRgbColorSpace() + public void GetConverterReturnsCorrectConverterWithRgbColorSpace() { FeatureTestRunner.RunWithHwIntrinsicsFeature( RunTest, @@ -104,6 +104,39 @@ public class JpegColorConverterTests } } + [Fact] + public void GetConverterReturnsCorrectConverterWithCmykColorSpace() + { + FeatureTestRunner.RunWithHwIntrinsicsFeature( + RunTest, + HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic); + + static void RunTest(string arg) + { + // arrange + Type expectedType = typeof(JpegColorConverterBase.CmykScalar); + if (Avx.IsSupported) + { + expectedType = typeof(JpegColorConverterBase.CmykAvx); + } + else if (Sse2.IsSupported) + { + expectedType = typeof(JpegColorConverterBase.CmykVector); + } + else if (AdvSimd.IsSupported) + { + expectedType = typeof(JpegColorConverterBase.CmykArm64); + } + + // act + JpegColorConverterBase converter = JpegColorConverterBase.GetConverter(JpegColorSpace.Cmyk, 8); + Type actualType = converter.GetType(); + + // assert + Assert.Equal(expectedType, actualType); + } + } + [Theory] [InlineData(JpegColorSpace.Grayscale, 1)] [InlineData(JpegColorSpace.Ycck, 4)]