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 rgb color space which uses FeatureTest…
…Runner to disable specific hw features
  • Loading branch information
brianpopow committed Mar 26, 2023
commit 09b4dd751d9383156ea7e7671e90ab59c3ea618f
35 changes: 35 additions & 0 deletions tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion;
using SixLabors.ImageSharp.Formats.Jpeg.Components;
Expand Down Expand Up @@ -69,6 +71,39 @@ internal void GetConverterReturnsValidConverter(JpegColorSpace colorSpace, int p
Assert.Equal(precision, converter.Precision);
}

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

static void RunTest(string arg)
{
// arrange
Type expectedType = typeof(JpegColorConverterBase.RgbScalar);
if (Avx.IsSupported)
{
expectedType = typeof(JpegColorConverterBase.RgbAvx);
}
else if (Sse2.IsSupported)
{
expectedType = typeof(JpegColorConverterBase.RgbVector);
}
else if (AdvSimd.IsSupported)
{
expectedType = typeof(JpegColorConverterBase.RgbArm);
}

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

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

[Theory]
[InlineData(JpegColorSpace.Grayscale, 1)]
[InlineData(JpegColorSpace.Ycck, 4)]
Expand Down