// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.ColorProfiles; namespace SixLabors.ImageSharp.Tests.ColorProfiles; /// /// Tests - conversions. /// public class CieXyzAndCieLchConversionTests { private static readonly ApproximateColorProfileComparer Comparer = new(.0002f); [Theory] [InlineData(0, 0, 0, 0, 0, 0)] [InlineData(0.360555, 0.936901, 0.1001514, 97.50697, 161.235321, 143.157)] public void Convert_CieXyz_to_CieLch(float x, float y, float yl, float l, float c, float h) { // Arrange CieXyz input = new(x, y, yl); CieLch expected = new(l, c, h); ColorProfileConverter converter = new(); Span inputSpan = new CieXyz[5]; inputSpan.Fill(input); Span actualSpan = new CieLch[5]; // Act CieLch actual = converter.Convert(input); converter.Convert(inputSpan, actualSpan); // Assert Assert.Equal(expected, actual, Comparer); for (int i = 0; i < actualSpan.Length; i++) { Assert.Equal(expected, actualSpan[i], Comparer); } } [Theory] [InlineData(0, 0, 0, 0, 0, 0)] [InlineData(97.50697, 161.235321, 143.157, 0.3605551, 0.936901, 0.1001514)] public void Convert_CieLch_to_CieXyz(float l, float c, float h, float x, float y, float yl) { // Arrange CieLch input = new(l, c, h); CieXyz expected = new(x, y, yl); ColorProfileConverter converter = new(); Span inputSpan = new CieLch[5]; inputSpan.Fill(input); Span actualSpan = new CieXyz[5]; // Act CieXyz actual = converter.Convert(input); converter.Convert(inputSpan, actualSpan); // Assert Assert.Equal(expected, actual, Comparer); for (int i = 0; i < actualSpan.Length; i++) { Assert.Equal(expected, actualSpan[i], Comparer); } } }