📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

113 lines
2.9 KiB

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
// <auto-generated />
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
using Xunit.Abstractions;
<#+
private static readonly string[] UnassociatedAlphaPixelTypes =
{
"A8",
"Argb32",
"Abgr32",
"Bgra32",
"Bgra4444",
"Bgra5551",
"Byte4",
"HalfVector4",
"La16",
"La32",
"NormalizedByte4",
"NormalizedShort4",
"Rgba1010102",
"Rgba32",
"Rgba64",
"RgbaVector",
"Short4"
};
private static readonly string[] AssociatedAlphaPixelTypes = Array.Empty<string>();
private static readonly string[] CommonPixelTypes =
{
"A8",
"Argb32",
"Abgr32",
"Bgr24",
"Bgr565",
"Bgra32",
"Bgra4444",
"Bgra5551",
"Byte4",
"HalfSingle",
"HalfVector2",
"HalfVector4",
"L16",
"L8",
"La16",
"La32",
"NormalizedByte2",
"NormalizedByte4",
"NormalizedShort2",
"NormalizedShort4",
"Rg32",
"Rgb24",
"Rgb48",
"Rgba1010102",
"Rgba32",
"Rgba64",
"RgbaVector",
"Short2",
"Short4",
};
void GenerateSpecializedClass(string pixelType, string alpha)
{#>
public partial class <#=pixelType#>_OperationsTests : PixelOperationsTests<<#=pixelType#>>
{
public <#=pixelType#>_OperationsTests(ITestOutputHelper output)
: base(output)
{
}
protected override PixelOperations<<#=pixelType#>> Operations => <#=pixelType#>.PixelOperations.Instance;
[Fact]
public void IsSpecialImplementation() => Assert.IsType<<#=pixelType#>.PixelOperations>(PixelOperations<<#=pixelType#>>.Instance);
[Fact]
public void PixelTypeInfoHasCorrectAlphaRepresentation()
{
var alphaRepresentation = this.Operations.GetPixelTypeInfo().AlphaRepresentation;
Assert.Equal(<#=alpha#>, alphaRepresentation);
}
}
<#+
}
void GenerateAllSpecializedClasses()
{
foreach (string pixelType in CommonPixelTypes)
{
string alpha = "PixelAlphaRepresentation.None";
if (AssociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Associated";
}
else if (UnassociatedAlphaPixelTypes.Contains(pixelType))
{
alpha = "PixelAlphaRepresentation.Unassociated";
}
GenerateSpecializedClass(pixelType, alpha);
}
}
#>