Skip to content

Commit 42918ed

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

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
@@ -104,6 +104,35 @@ static void RunTest(string arg)
104104
}
105105
}
106106

107+
[Fact]
108+
public void GetConverterReturnsCorrectConverterWithGrayScaleColorSpace()
109+
{
110+
FeatureTestRunner.RunWithHwIntrinsicsFeature(
111+
RunTest,
112+
HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic);
113+
114+
static void RunTest(string arg)
115+
{
116+
// arrange
117+
Type expectedType = typeof(JpegColorConverterBase.GrayscaleScalar);
118+
if (Avx.IsSupported)
119+
{
120+
expectedType = typeof(JpegColorConverterBase.GrayscaleAvx);
121+
}
122+
else if (Sse2.IsSupported)
123+
{
124+
expectedType = typeof(JpegColorConverterBase.GrayScaleVector);
125+
}
126+
127+
// act
128+
JpegColorConverterBase converter = JpegColorConverterBase.GetConverter(JpegColorSpace.Grayscale, 8);
129+
Type actualType = converter.GetType();
130+
131+
// assert
132+
Assert.Equal(expectedType, actualType);
133+
}
134+
}
135+
107136
[Fact]
108137
public void GetConverterReturnsCorrectConverterWithCmykColorSpace()
109138
{

0 commit comments

Comments
 (0)