Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for GetConverter with cmyk color space which uses FeatureTes…
…tRunner to disable specific hw features
  • Loading branch information
brianpopow committed Mar 27, 2023
commit f4727d1d3480d2b01d0619051ec5ada0959dbb71
35 changes: 34 additions & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal void GetConverterReturnsValidConverter(JpegColorSpace colorSpace, int p
}

[Fact]
public void GetConverterReturnsValidConverterWithRgbColorSpace()
public void GetConverterReturnsCorrectConverterWithRgbColorSpace()
{
FeatureTestRunner.RunWithHwIntrinsicsFeature(
RunTest,
Expand Down Expand Up @@ -104,6 +104,39 @@ static void RunTest(string arg)
}
}

[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)]
Expand Down