Skip to content

Commit 4efb121

Browse files
Create CieLuvAndCieXyyConversionTests.cs
1 parent ec14dc2 commit 4efb121

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
using SixLabors.ImageSharp.ColorProfiles;
5+
6+
namespace SixLabors.ImageSharp.Tests.ColorProfiles;
7+
8+
/// <summary>
9+
/// Tests <see cref="CieLuv"/>-<see cref="CieXyy"/> conversions.
10+
/// </summary>
11+
public class CieLuvAndCieXyyConversionTests
12+
{
13+
private static readonly ApproximateColorProfileComparer Comparer = new(.0002F);
14+
15+
[Theory]
16+
[InlineData(0, 0, 0, 0, 0, 0)]
17+
[InlineData(36.0555, 103.6901, 10.01514, 0.5646762, 0.2932749, 0.09037033)]
18+
public void Convert_CieLuv_to_CieXyy(float l, float u, float v, float x, float y, float yl)
19+
{
20+
// Arrange
21+
CieLuv input = new(l, u, v);
22+
CieXyy expected = new(x, y, yl);
23+
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 };
24+
ColorProfileConverter converter = new(options);
25+
26+
Span<CieLuv> inputSpan = new CieLuv[5];
27+
inputSpan.Fill(input);
28+
29+
Span<CieXyy> actualSpan = new CieXyy[5];
30+
31+
// Act
32+
CieXyy actual = converter.Convert<CieLuv, CieXyy>(input);
33+
converter.Convert<CieLuv, CieXyy>(inputSpan, actualSpan);
34+
35+
// Assert
36+
Assert.Equal(expected, actual, Comparer);
37+
38+
for (int i = 0; i < actualSpan.Length; i++)
39+
{
40+
Assert.Equal(expected, actualSpan[i], Comparer);
41+
}
42+
}
43+
44+
[Theory]
45+
[InlineData(0, 0, 0, 0, 0, 0)]
46+
[InlineData(0.5646762, 0.2932749, 0.09037033, 36.0555, 103.6901, 10.01514)]
47+
public void Convert_CieXyy_to_CieLuv(float x, float y, float yl, float l, float u, float v)
48+
{
49+
// Arrange
50+
CieXyy input = new(x, y, yl);
51+
CieLuv expected = new(l, u, v);
52+
ColorConversionOptions options = new() { WhitePoint = Illuminants.D65, TargetWhitePoint = Illuminants.D65 };
53+
ColorProfileConverter converter = new(options);
54+
55+
Span<CieXyy> inputSpan = new CieXyy[5];
56+
inputSpan.Fill(input);
57+
58+
Span<CieLuv> actualSpan = new CieLuv[5];
59+
60+
// Act
61+
CieLuv actual = converter.Convert<CieXyy, CieLuv>(input);
62+
converter.Convert<CieXyy, CieLuv>(inputSpan, actualSpan);
63+
64+
// Assert
65+
Assert.Equal(expected, actual, Comparer);
66+
67+
for (int i = 0; i < actualSpan.Length; i++)
68+
{
69+
Assert.Equal(expected, actualSpan[i], Comparer);
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)