diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs
index 5b1abb749..9d6ec8960 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs
@@ -3,7 +3,6 @@
//
-using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
@@ -23,20 +22,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => A8.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = A8.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = A8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -50,20 +44,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Argb32.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Argb32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Argb32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -77,20 +66,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Bgr24.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Bgr24.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Bgr24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -104,20 +88,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Bgr565.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Bgr565.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Bgr565.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -131,20 +110,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Bgra32.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Bgra32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Bgra32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -158,20 +132,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Bgra4444.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Bgra4444.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Bgra4444.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -185,20 +154,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Bgra5551.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Bgra5551.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Bgra5551.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -212,20 +176,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Byte4.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Byte4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Byte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -239,20 +198,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => HalfSingle.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = HalfSingle.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = HalfSingle.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -266,20 +220,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => HalfVector2.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = HalfVector2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = HalfVector2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -293,20 +242,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => HalfVector4.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = HalfVector4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = HalfVector4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -320,20 +264,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => L16.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = L16.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = L16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -347,20 +286,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => L8.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = L8.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = L8.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -374,20 +308,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => La16.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = La16.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = La16.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -401,20 +330,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => La32.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = La32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = La32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -428,20 +352,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => NormalizedByte2.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = NormalizedByte2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = NormalizedByte2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -455,20 +374,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => NormalizedByte4.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = NormalizedByte4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = NormalizedByte4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -482,20 +396,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => NormalizedShort2.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = NormalizedShort2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = NormalizedShort2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -509,20 +418,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => NormalizedShort4.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = NormalizedShort4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = NormalizedShort4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -536,20 +440,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rg32.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rg32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rg32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -563,20 +462,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rgb24.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rgb24.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rgb24.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -590,20 +484,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rgb48.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rgb48.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rgb48.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -617,20 +506,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rgba1010102.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rgba1010102.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rgba1010102.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -644,20 +528,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rgba32.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rgba32.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rgba32.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -671,20 +550,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Rgba64.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Rgba64.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Rgba64.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -698,20 +572,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => RgbaVector.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = RgbaVector.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = RgbaVector.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
@@ -725,20 +594,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Short2.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Short2.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Short2.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.None, alphaRepresentation);
}
}
@@ -752,20 +616,15 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
+ protected override PixelOperations Operations => Short4.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = Short4.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType(PixelOperations.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = Short4.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(PixelAlphaRepresentation.Unassociated, alphaRepresentation);
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude
index bc093be85..50026b3f8 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude
@@ -8,7 +8,6 @@
//
-using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
@@ -79,20 +78,15 @@ using Xunit.Abstractions;
this.HasUnassociatedAlpha = alphaRepresentation == PixelAlphaRepresentation.Unassociated;
}
- [Fact]
- public void IsSpecialImplementation() => Assert.IsType<<#=pixelType#>.PixelOperations>(PixelOperations<<#=pixelType#>>.Instance);
+ protected override PixelOperations<<#=pixelType#>> Operations => <#=pixelType#>.PixelOperations.Instance;
[Fact]
- public void PixelTypeInfoHasCorrectBitsPerPixel()
- {
- var bits = <#=pixelType#>.PixelOperations.Instance.GetPixelTypeInfo().BitsPerPixel;
- Assert.Equal(Unsafe.SizeOf<<#=pixelType#>>() * 8, bits);
- }
+ public void IsSpecialImplementation() => Assert.IsType<<#=pixelType#>.PixelOperations>(PixelOperations<<#=pixelType#>>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
- var alphaRepresentation = <#=pixelType#>.PixelOperations.Instance.GetPixelTypeInfo().AlphaRepresentation;
+ var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(<#=alpha#>, alphaRepresentation);
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
index d18c3c860..543184e34 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
@@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
protected Configuration Configuration => Configuration.Default;
- internal static PixelOperations Operations => PixelOperations.Instance;
+ protected virtual PixelOperations Operations => PixelOperations.Instance;
internal static TPixel[] CreateExpectedPixelData(Vector4[] source, RefAction vectorModifier = null)
{
@@ -105,6 +105,33 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
return expected;
}
+ [Fact]
+ public void PixelTypeInfoHasCorrectBitsPerPixel()
+ {
+ var bits = this.Operations.GetPixelTypeInfo().BitsPerPixel;
+ Assert.Equal(Unsafe.SizeOf() * 8, bits);
+ }
+
+ [Fact]
+ public void PixelAlphaRepresentation_DefinesPresenceOfAlphaChannel()
+ {
+ // We use 0 - 255 as we have pixel formats that store
+ // the alpha component in less than 8 bits.
+ const byte Alpha = byte.MinValue;
+ const byte NoAlpha = byte.MaxValue;
+
+ TPixel pixel = default;
+ pixel.FromRgba32(new Rgba32(0, 0, 0, Alpha));
+
+ Rgba32 dest = default;
+ pixel.ToRgba32(ref dest);
+
+ bool hasAlpha = this.Operations.GetPixelTypeInfo().AlphaRepresentation != PixelAlphaRepresentation.None;
+
+ byte expectedAlpha = hasAlpha ? Alpha : NoAlpha;
+ Assert.Equal(expectedAlpha, dest.A);
+ }
+
[Theory]
[MemberData(nameof(ArraySizesData))]
public void FromVector4(int count)
@@ -115,7 +142,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
TestOperation(
source,
expected,
- (s, d) => Operations.FromVector4Destructive(this.Configuration, s, d.GetSpan()));
+ (s, d) => this.Operations.FromVector4Destructive(this.Configuration, s, d.GetSpan()));
}
[Theory]
@@ -131,7 +158,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
(s, d) =>
{
Span destPixels = d.GetSpan();
- Operations.FromVector4Destructive(this.Configuration, (Span)s, destPixels, PixelConversionModifiers.Scale);
+ this.Operations.FromVector4Destructive(this.Configuration, (Span)s, destPixels, PixelConversionModifiers.Scale);
});
}
@@ -155,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
TestOperation(
source,
expected,
- (s, d) => Operations.FromVector4Destructive(
+ (s, d) => this.Operations.FromVector4Destructive(
this.Configuration,
s,
d.GetSpan(),
@@ -194,7 +221,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
? PixelConversionModifiers.Premultiply
: PixelConversionModifiers.None;
- Operations.FromVector4Destructive(this.Configuration, s, d.GetSpan(), modifiers);
+ this.Operations.FromVector4Destructive(this.Configuration, s, d.GetSpan(), modifiers);
});
}
@@ -230,7 +257,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
? PixelConversionModifiers.Premultiply
: PixelConversionModifiers.None;
- Operations.FromVector4Destructive(
+ this.Operations.FromVector4Destructive(
this.Configuration,
s,
d.GetSpan(),
@@ -274,7 +301,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
? PixelConversionModifiers.Premultiply
: PixelConversionModifiers.None;
- Operations.FromVector4Destructive(
+ this.Operations.FromVector4Destructive(
this.Configuration,
s,
d.GetSpan(),
@@ -292,7 +319,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations
TestOperation(
source,
expected,
- (s, d) => Operations.ToVector4(this.Configuration, s, d.GetSpan()));
+ (s, d) => this.Operations.ToVector4(this.Configuration, s, d.GetSpan()));
}
public static readonly TheoryData