Skip to content

Commit

Permalink
Add test for GetConverter with grayscale color space which uses Featu…
Browse files Browse the repository at this point in the history
…reTestRunner to disable specific hw features
  • Loading branch information
brianpopow committed Mar 27, 2023
1 parent f0530bf commit 42918ed
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,35 @@ static void RunTest(string arg)
}
}

[Fact]
public void GetConverterReturnsCorrectConverterWithGrayScaleColorSpace()
{
FeatureTestRunner.RunWithHwIntrinsicsFeature(
RunTest,
HwIntrinsics.AllowAll | HwIntrinsics.DisableAVX2 | HwIntrinsics.DisableSSE2 | HwIntrinsics.DisableHWIntrinsic);

static void RunTest(string arg)
{
// arrange
Type expectedType = typeof(JpegColorConverterBase.GrayscaleScalar);
if (Avx.IsSupported)
{
expectedType = typeof(JpegColorConverterBase.GrayscaleAvx);
}
else if (Sse2.IsSupported)
{
expectedType = typeof(JpegColorConverterBase.GrayScaleVector);
}

// act
JpegColorConverterBase converter = JpegColorConverterBase.GetConverter(JpegColorSpace.Grayscale, 8);
Type actualType = converter.GetType();

// assert
Assert.Equal(expectedType, actualType);
}
}

[Fact]
public void GetConverterReturnsCorrectConverterWithCmykColorSpace()
{
Expand Down

0 comments on commit 42918ed

Please sign in to comment.