Skip to content

Commit 00162b6

Browse files
Create CieLchAndCieXyyConversionTests.cs
1 parent f37ac8e commit 00162b6

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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="CieLch"/>-<see cref="CieXyy"/> conversions.
10+
/// </summary>
11+
public class CieLchAndCieXyyConversionTests
12+
{
13+
private static readonly ApproximateColorProfileComparer Comparer = new(.0003f);
14+
15+
[Theory]
16+
[InlineData(0, 0, 0, 0, 0, 0)]
17+
[InlineData(36.0555, 103.6901, 10.01514, 0.67641, 0.22770, 0.09037)]
18+
public void Convert_CieLch_to_CieXyy(float l, float c, float h, float x, float y, float yl)
19+
{
20+
// Arrange
21+
CieLch input = new(l, c, h);
22+
CieXyy expected = new(x, y, yl);
23+
ColorProfileConverter converter = new();
24+
25+
Span<CieLch> inputSpan = new CieLch[5];
26+
inputSpan.Fill(input);
27+
28+
Span<CieXyy> actualSpan = new CieXyy[5];
29+
30+
// Act
31+
CieXyy actual = converter.Convert<CieLch, CieXyy>(input);
32+
converter.Convert<CieLch, CieXyy>(inputSpan, actualSpan);
33+
34+
// Assert
35+
Assert.Equal(expected, actual, Comparer);
36+
37+
for (int i = 0; i < actualSpan.Length; i++)
38+
{
39+
Assert.Equal(expected, actualSpan[i], Comparer);
40+
}
41+
}
42+
43+
[Theory]
44+
[InlineData(0, 0, 0, 0, 0, 0)]
45+
[InlineData(0.67641, 0.22770, 0.09037, 36.05544, 103.691315, 10.012783)]
46+
public void Convert_CieXyy_to_CieLch(float x, float y, float yl, float l, float c, float h)
47+
{
48+
// Arrange
49+
CieXyy input = new(x, y, yl);
50+
CieLch expected = new(l, c, h);
51+
ColorProfileConverter converter = new();
52+
53+
Span<CieXyy> inputSpan = new CieXyy[5];
54+
inputSpan.Fill(input);
55+
56+
Span<CieLch> actualSpan = new CieLch[5];
57+
58+
// Act
59+
CieLch actual = converter.Convert<CieXyy, CieLch>(input);
60+
converter.Convert<CieXyy, CieLch>(inputSpan, actualSpan);
61+
62+
// Assert
63+
Assert.Equal(expected, actual, Comparer);
64+
65+
for (int i = 0; i < actualSpan.Length; i++)
66+
{
67+
Assert.Equal(expected, actualSpan[i], Comparer);
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)