Skip to content

Commit 51c3094

Browse files
More LAB tests
1 parent 55de3cc commit 51c3094

3 files changed

Lines changed: 74 additions & 4 deletions

File tree

tests/ImageSharp.Tests/ColorProfiles/CieLabAndCieLchuvConversionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CieLabAndCieLchuvConversionTests
1919
[Theory]
2020
[InlineData(0, 0, 0, 0, 0, 0)]
2121
[InlineData(30.66194, 200, 352.7564, 31.95653, 116.8745, 2.388602)]
22-
public void Convert_Lchuv_to_Lab(float l, float c, float h, float l2, float a, float b)
22+
public void Convert_Lchuv_To_Lab(float l, float c, float h, float l2, float a, float b)
2323
{
2424
// Arrange
2525
CieLchuv input = new(l, c, h);
@@ -48,7 +48,7 @@ public void Convert_Lchuv_to_Lab(float l, float c, float h, float l2, float a, f
4848
[Theory]
4949
[InlineData(0, 0, 0, 0, 0, 0)]
5050
[InlineData(36.0555, 303.6901, 10.01514, 29.4713573, 200, 352.6346)]
51-
public void Convert_Lab_to_Lchuv(float l, float a, float b, float l2, float c, float h)
51+
public void Convert_Lab_To_Lchuv(float l, float a, float b, float l2, float c, float h)
5252
{
5353
// Arrange
5454
CieLab input = new(l, a, b);

tests/ImageSharp.Tests/ColorProfiles/CieLabAndCieLuvConversionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CieLabAndCieLuvConversionTests
1919
[Theory]
2020
[InlineData(0, 0, 0, 0, 0, 0)]
2121
[InlineData(10, 36.0555, 303.6901, 10.6006718, -17.24077, 82.8835)]
22-
public void Convert_CieLuv_to_CieLab(float l, float u, float v, float l2, float a, float b)
22+
public void Convert_CieLuv_To_CieLab(float l, float u, float v, float l2, float a, float b)
2323
{
2424
// Arrange
2525
CieLuv input = new(l, u, v);
@@ -48,7 +48,7 @@ public void Convert_CieLuv_to_CieLab(float l, float u, float v, float l2, float
4848
[Theory]
4949
[InlineData(0, 0, 0, 0, 0, 0)]
5050
[InlineData(10.0151367, -23.9644356, 17.0226, 10.0000038, -12.830183, 15.1829338)]
51-
public void Convert_CieLab_to_CieLuv(float l, float a, float b, float l2, float u, float v)
51+
public void Convert_CieLab_To_CieLuv(float l, float a, float b, float l2, float u, float v)
5252
{
5353
// Arrange
5454
CieLab input = new(l, a, b);
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.Conversion;
7+
8+
/// <summary>
9+
/// Tests <see cref="CieLab"/>-<see cref="CieXyy"/> conversions.
10+
/// </summary>
11+
public class CieLabAndCieXyyConversionTests
12+
{
13+
private static readonly ApproximateColorProfileComparer Comparer = new(.0002F);
14+
15+
[Theory]
16+
[InlineData(0, 0, 0, 0, 0, 0)]
17+
[InlineData(0.8644734, 0.06098868, 0.06509002, 30.6619, 291.5721, -11.2526)]
18+
public void Convert_CieXyy_To_CieLab(float x, float y, float yl, float l, float a, float b)
19+
{
20+
// Arrange
21+
CieXyy input = new(x, y, yl);
22+
CieLab expected = new(l, a, b);
23+
ColorProfileConverter converter = new();
24+
25+
Span<CieXyy> inputSpan = new CieXyy[5];
26+
inputSpan.Fill(input);
27+
28+
Span<CieLab> actualSpan = new CieLab[5];
29+
30+
// Act
31+
CieLab actual = converter.Convert<CieXyy, CieLab>(input);
32+
converter.Convert<CieXyy, CieLab>(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(30.6619, 291.5721, -11.2526, 0.8644734, 0.06098868, 0.06509002)]
46+
public void Convert_CieLab_To_CieXyy(float l, float a, float b, float x, float y, float yl)
47+
{
48+
// Arrange
49+
CieLab input = new(l, a, b);
50+
CieXyy expected = new(x, y, yl);
51+
ColorProfileConverter converter = new();
52+
53+
Span<CieLab> inputSpan = new CieLab[5];
54+
inputSpan.Fill(input);
55+
56+
Span<CieXyy> actualSpan = new CieXyy[5];
57+
58+
// Act
59+
CieXyy actual = converter.Convert<CieLab, CieXyy>(input);
60+
converter.Convert<CieLab, CieXyy>(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)