Skip to content

Commit f0530bf

Browse files
committed
Add test for GetConverter with ycck color space which uses FeatureTestRunner to disable specific hw features
1 parent ecb6c0f commit f0530bf

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,35 @@ static void RunTest(string arg)
166166
}
167167
}
168168

169+
[Fact]
170+
public void GetConverterReturnsCorrectConverterWithYcckColorSpace()
171+
{
172+
FeatureTestRunner.RunWithHwIntrinsicsFeature(
173+
RunTest,
174+
HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic);
175+
176+
static void RunTest(string arg)
177+
{
178+
// arrange
179+
Type expectedType = typeof(JpegColorConverterBase.YccKScalar);
180+
if (Avx.IsSupported)
181+
{
182+
expectedType = typeof(JpegColorConverterBase.YccKAvx);
183+
}
184+
else if (Sse2.IsSupported)
185+
{
186+
expectedType = typeof(JpegColorConverterBase.YccKVector);
187+
}
188+
189+
// act
190+
JpegColorConverterBase converter = JpegColorConverterBase.GetConverter(JpegColorSpace.Ycck, 8);
191+
Type actualType = converter.GetType();
192+
193+
// assert
194+
Assert.Equal(expectedType, actualType);
195+
}
196+
}
197+
169198
[Theory]
170199
[InlineData(JpegColorSpace.Grayscale, 1)]
171200
[InlineData(JpegColorSpace.Ycck, 4)]

0 commit comments

Comments
 (0)