mirror of https://github.com/SixLabors/ImageSharp
14 changed files with 632 additions and 0 deletions
@ -0,0 +1,44 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieLab"/> struct.
|
|||
/// </summary>
|
|||
public class CieLabTests |
|||
{ |
|||
[Fact] |
|||
public void CieLabConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float a = -64F; |
|||
const float b = 87F; |
|||
CieLab cieLab = new(l, a, b); |
|||
|
|||
Assert.Equal(l, cieLab.L); |
|||
Assert.Equal(a, cieLab.A); |
|||
Assert.Equal(b, cieLab.B); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieLabEquality() |
|||
{ |
|||
CieLab x = default; |
|||
CieLab y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieLab)); |
|||
Assert.True(new CieLab(1, 0, 1) != default); |
|||
Assert.False(new CieLab(1, 0, 1) == default); |
|||
Assert.Equal(default, default(CieLab)); |
|||
Assert.Equal(new CieLab(1, 0, 1), new CieLab(1, 0, 1)); |
|||
Assert.Equal(new CieLab(Vector3.One), new CieLab(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(new CieLab(1, 0, 1) == default); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieLch"/> struct.
|
|||
/// </summary>
|
|||
public class CieLchTests |
|||
{ |
|||
[Fact] |
|||
public void CieLchConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float c = 64F; |
|||
const float h = 287F; |
|||
CieLch cieLch = new(l, c, h); |
|||
|
|||
Assert.Equal(l, cieLch.L); |
|||
Assert.Equal(c, cieLch.C); |
|||
Assert.Equal(h, cieLch.H); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieLchEquality() |
|||
{ |
|||
CieLch x = default; |
|||
CieLch y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieLch)); |
|||
Assert.False(default != default(CieLch)); |
|||
Assert.Equal(default, default(CieLch)); |
|||
Assert.Equal(new CieLch(1, 0, 1), new CieLch(1, 0, 1)); |
|||
Assert.Equal(new CieLch(Vector3.One), new CieLch(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieLchuv"/> struct.
|
|||
/// </summary>
|
|||
public class CieLchuvTests |
|||
{ |
|||
[Fact] |
|||
public void CieLchuvConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float c = 64F; |
|||
const float h = 287F; |
|||
CieLchuv cieLchuv = new(l, c, h); |
|||
|
|||
Assert.Equal(l, cieLchuv.L); |
|||
Assert.Equal(c, cieLchuv.C); |
|||
Assert.Equal(h, cieLchuv.H); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieLchuvEquality() |
|||
{ |
|||
CieLchuv x = default; |
|||
CieLchuv y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieLchuv)); |
|||
Assert.False(default != default(CieLchuv)); |
|||
Assert.Equal(default, default(CieLchuv)); |
|||
Assert.Equal(new CieLchuv(1, 0, 1), new CieLchuv(1, 0, 1)); |
|||
Assert.Equal(new CieLchuv(Vector3.One), new CieLchuv(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieLuv"/> struct.
|
|||
/// </summary>
|
|||
public class CieLuvTests |
|||
{ |
|||
[Fact] |
|||
public void CieLuvConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float c = -64F; |
|||
const float h = 87F; |
|||
CieLuv cieLuv = new(l, c, h); |
|||
|
|||
Assert.Equal(l, cieLuv.L); |
|||
Assert.Equal(c, cieLuv.U); |
|||
Assert.Equal(h, cieLuv.V); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieLuvEquality() |
|||
{ |
|||
CieLuv x = default; |
|||
CieLuv y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieLuv)); |
|||
Assert.False(default != default(CieLuv)); |
|||
Assert.Equal(default, default(CieLuv)); |
|||
Assert.Equal(new CieLuv(1, 0, 1), new CieLuv(1, 0, 1)); |
|||
Assert.Equal(new CieLuv(Vector3.One), new CieLuv(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieXyChromaticityCoordinates"/> struct.
|
|||
/// </summary>
|
|||
public class CieXyChromaticityCoordinatesTests |
|||
{ |
|||
[Fact] |
|||
public void CieXyChromaticityCoordinatesConstructorAssignsFields() |
|||
{ |
|||
const float x = .75F; |
|||
const float y = .64F; |
|||
CieXyChromaticityCoordinates coordinates = new(x, y); |
|||
|
|||
Assert.Equal(x, coordinates.X); |
|||
Assert.Equal(y, coordinates.Y); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieXyChromaticityCoordinatesEquality() |
|||
{ |
|||
CieXyChromaticityCoordinates x = default; |
|||
CieXyChromaticityCoordinates y = new(1, 1); |
|||
|
|||
Assert.True(default == default(CieXyChromaticityCoordinates)); |
|||
Assert.True(new CieXyChromaticityCoordinates(1, 0) != default); |
|||
Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); |
|||
Assert.Equal(default, default(CieXyChromaticityCoordinates)); |
|||
Assert.Equal(new CieXyChromaticityCoordinates(1, 0), new CieXyChromaticityCoordinates(1, 0)); |
|||
Assert.Equal(new CieXyChromaticityCoordinates(1, 1), new CieXyChromaticityCoordinates(1, 1)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(new CieXyChromaticityCoordinates(1, 0) == default); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieXyy"/> struct.
|
|||
/// </summary>
|
|||
public class CieXyyTests |
|||
{ |
|||
[Fact] |
|||
public void CieXyyConstructorAssignsFields() |
|||
{ |
|||
const float x = 75F; |
|||
const float y = 64F; |
|||
const float yl = 287F; |
|||
CieXyy cieXyy = new(x, y, yl); |
|||
|
|||
Assert.Equal(x, cieXyy.X); |
|||
Assert.Equal(y, cieXyy.Y); |
|||
Assert.Equal(y, cieXyy.Y); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieXyyEquality() |
|||
{ |
|||
CieXyy x = default; |
|||
CieXyy y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieXyy)); |
|||
Assert.False(default != default(CieXyy)); |
|||
Assert.Equal(default, default(CieXyy)); |
|||
Assert.Equal(new CieXyy(1, 0, 1), new CieXyy(1, 0, 1)); |
|||
Assert.Equal(new CieXyy(Vector3.One), new CieXyy(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="CieXyz"/> struct.
|
|||
/// </summary>
|
|||
public class CieXyzTests |
|||
{ |
|||
[Fact] |
|||
public void CieXyzConstructorAssignsFields() |
|||
{ |
|||
const float x = 75F; |
|||
const float y = 64F; |
|||
const float z = 287F; |
|||
CieXyz cieXyz = new(x, y, z); |
|||
|
|||
Assert.Equal(x, cieXyz.X); |
|||
Assert.Equal(y, cieXyz.Y); |
|||
Assert.Equal(z, cieXyz.Z); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CieXyzEquality() |
|||
{ |
|||
CieXyz x = default; |
|||
CieXyz y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(CieXyz)); |
|||
Assert.False(default != default(CieXyz)); |
|||
Assert.Equal(default, default(CieXyz)); |
|||
Assert.Equal(new CieXyz(1, 0, 1), new CieXyz(1, 0, 1)); |
|||
Assert.Equal(new CieXyz(Vector3.One), new CieXyz(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="Cmyk"/> struct.
|
|||
/// </summary>
|
|||
public class CmykTests |
|||
{ |
|||
[Fact] |
|||
public void CmykConstructorAssignsFields() |
|||
{ |
|||
const float c = .75F; |
|||
const float m = .64F; |
|||
const float y = .87F; |
|||
const float k = .334F; |
|||
Cmyk cmyk = new(c, m, y, k); |
|||
|
|||
Assert.Equal(c, cmyk.C); |
|||
Assert.Equal(m, cmyk.M); |
|||
Assert.Equal(y, cmyk.Y); |
|||
Assert.Equal(k, cmyk.K); |
|||
} |
|||
|
|||
[Fact] |
|||
public void CmykEquality() |
|||
{ |
|||
Cmyk x = default; |
|||
Cmyk y = new(Vector4.One); |
|||
|
|||
Assert.True(default == default(Cmyk)); |
|||
Assert.False(default != default(Cmyk)); |
|||
Assert.Equal(default, default(Cmyk)); |
|||
Assert.Equal(new Cmyk(1, 0, 1, 0), new Cmyk(1, 0, 1, 0)); |
|||
Assert.Equal(new Cmyk(Vector4.One), new Cmyk(Vector4.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorSpaces; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="Hsl"/> struct.
|
|||
/// </summary>
|
|||
public class HslTests |
|||
{ |
|||
[Fact] |
|||
public void HslConstructorAssignsFields() |
|||
{ |
|||
const float h = 275F; |
|||
const float s = .64F; |
|||
const float l = .87F; |
|||
Hsl hsl = new(h, s, l); |
|||
|
|||
Assert.Equal(h, hsl.H); |
|||
Assert.Equal(s, hsl.S); |
|||
Assert.Equal(l, hsl.L); |
|||
} |
|||
|
|||
[Fact] |
|||
public void HslEquality() |
|||
{ |
|||
Hsl x = default; |
|||
Hsl y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(Hsl)); |
|||
Assert.False(default != default(Hsl)); |
|||
Assert.Equal(default, default(Hsl)); |
|||
Assert.Equal(new Hsl(1, 0, 1), new Hsl(1, 0, 1)); |
|||
Assert.Equal(new Hsl(Vector3.One), new Hsl(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="Hsv"/> struct.
|
|||
/// </summary>
|
|||
public class HsvTests |
|||
{ |
|||
[Fact] |
|||
public void HsvConstructorAssignsFields() |
|||
{ |
|||
const float h = 275F; |
|||
const float s = .64F; |
|||
const float v = .87F; |
|||
Hsv hsv = new(h, s, v); |
|||
|
|||
Assert.Equal(h, hsv.H); |
|||
Assert.Equal(s, hsv.S); |
|||
Assert.Equal(v, hsv.V); |
|||
} |
|||
|
|||
[Fact] |
|||
public void HsvEquality() |
|||
{ |
|||
Hsv x = default; |
|||
Hsv y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(Hsv)); |
|||
Assert.False(default != default(Hsv)); |
|||
Assert.Equal(default, default(Hsv)); |
|||
Assert.Equal(new Hsv(1, 0, 1), new Hsv(1, 0, 1)); |
|||
Assert.Equal(new Hsv(Vector3.One), new Hsv(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="HunterLab"/> struct.
|
|||
/// </summary>
|
|||
public class HunterLabTests |
|||
{ |
|||
[Fact] |
|||
public void HunterLabConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float a = -64F; |
|||
const float b = 87F; |
|||
HunterLab hunterLab = new(l, a, b); |
|||
|
|||
Assert.Equal(l, hunterLab.L); |
|||
Assert.Equal(a, hunterLab.A); |
|||
Assert.Equal(b, hunterLab.B); |
|||
} |
|||
|
|||
[Fact] |
|||
public void HunterLabEquality() |
|||
{ |
|||
HunterLab x = default; |
|||
HunterLab y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(HunterLab)); |
|||
Assert.True(new HunterLab(1, 0, 1) != default); |
|||
Assert.False(new HunterLab(1, 0, 1) == default); |
|||
Assert.Equal(default, default(HunterLab)); |
|||
Assert.Equal(new HunterLab(1, 0, 1), new HunterLab(1, 0, 1)); |
|||
Assert.Equal(new HunterLab(Vector3.One), new HunterLab(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="Lms"/> struct.
|
|||
/// </summary>
|
|||
public class LmsTests |
|||
{ |
|||
[Fact] |
|||
public void LmsConstructorAssignsFields() |
|||
{ |
|||
const float l = 75F; |
|||
const float m = -64F; |
|||
const float s = 87F; |
|||
Lms lms = new(l, m, s); |
|||
|
|||
Assert.Equal(l, lms.L); |
|||
Assert.Equal(m, lms.M); |
|||
Assert.Equal(s, lms.S); |
|||
} |
|||
|
|||
[Fact] |
|||
public void LmsEquality() |
|||
{ |
|||
Lms x = default; |
|||
Lms y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(Lms)); |
|||
Assert.True(new Lms(1, 0, 1) != default); |
|||
Assert.False(new Lms(1, 0, 1) == default); |
|||
Assert.Equal(default, default(Lms)); |
|||
Assert.Equal(new Lms(1, 0, 1), new Lms(1, 0, 1)); |
|||
Assert.Equal(new Lms(Vector3.One), new Lms(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="Rgb"/> struct.
|
|||
/// </summary>
|
|||
public class RgbTests |
|||
{ |
|||
[Fact] |
|||
public void RgbConstructorAssignsFields() |
|||
{ |
|||
const float r = .75F; |
|||
const float g = .64F; |
|||
const float b = .87F; |
|||
Rgb rgb = new(r, g, b); |
|||
|
|||
Assert.Equal(r, rgb.R); |
|||
Assert.Equal(g, rgb.G); |
|||
Assert.Equal(b, rgb.B); |
|||
} |
|||
|
|||
[Fact] |
|||
public void RgbEquality() |
|||
{ |
|||
Rgb x = default; |
|||
Rgb y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(Rgb)); |
|||
Assert.False(default != default(Rgb)); |
|||
Assert.Equal(default, default(Rgb)); |
|||
Assert.Equal(new Rgb(1, 0, 1), new Rgb(1, 0, 1)); |
|||
Assert.Equal(new Rgb(Vector3.One), new Rgb(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
|
|||
[Fact] |
|||
public void RgbAndRgb24Interop() |
|||
{ |
|||
const byte r = 64; |
|||
const byte g = 128; |
|||
const byte b = 255; |
|||
|
|||
Rgb24 rgb24 = Rgb24.FromScaledVector4(new Rgb(r / 255F, g / 255F, b / 255F).ToScaledVector4()); |
|||
Rgb rgb2 = Rgb.FromScaledVector4(rgb24.ToScaledVector4()); |
|||
|
|||
Assert.Equal(r, rgb24.R); |
|||
Assert.Equal(g, rgb24.G); |
|||
Assert.Equal(b, rgb24.B); |
|||
|
|||
Assert.Equal(r / 255F, rgb2.R); |
|||
Assert.Equal(g / 255F, rgb2.G); |
|||
Assert.Equal(b / 255F, rgb2.B); |
|||
} |
|||
|
|||
[Fact] |
|||
public void RgbAndRgba32Interop() |
|||
{ |
|||
const byte r = 64; |
|||
const byte g = 128; |
|||
const byte b = 255; |
|||
|
|||
Rgba32 rgba32 = Rgba32.FromScaledVector4(new Rgb(r / 255F, g / 255F, b / 255F).ToScaledVector4()); |
|||
Rgb rgb2 = Rgb.FromScaledVector4(rgba32.ToScaledVector4()); |
|||
|
|||
Assert.Equal(r, rgba32.R); |
|||
Assert.Equal(g, rgba32.G); |
|||
Assert.Equal(b, rgba32.B); |
|||
|
|||
Assert.Equal(r / 255F, rgb2.R); |
|||
Assert.Equal(g / 255F, rgb2.G); |
|||
Assert.Equal(b / 255F, rgb2.B); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Numerics; |
|||
using SixLabors.ImageSharp.ColorProfiles; |
|||
|
|||
namespace SixLabors.ImageSharp.Tests.ColorProfiles; |
|||
|
|||
/// <summary>
|
|||
/// Tests the <see cref="YCbCr"/> struct.
|
|||
/// </summary>
|
|||
public class YCbCrTests |
|||
{ |
|||
[Fact] |
|||
public void YCbCrConstructorAssignsFields() |
|||
{ |
|||
const float y = 75F; |
|||
const float cb = 64F; |
|||
const float cr = 87F; |
|||
YCbCr yCbCr = new(y, cb, cr); |
|||
|
|||
Assert.Equal(y, yCbCr.Y); |
|||
Assert.Equal(cb, yCbCr.Cb); |
|||
Assert.Equal(cr, yCbCr.Cr); |
|||
} |
|||
|
|||
[Fact] |
|||
public void YCbCrEquality() |
|||
{ |
|||
YCbCr x = default; |
|||
YCbCr y = new(Vector3.One); |
|||
|
|||
Assert.True(default == default(YCbCr)); |
|||
Assert.False(default != default(YCbCr)); |
|||
Assert.Equal(default, default(YCbCr)); |
|||
Assert.Equal(new YCbCr(1, 0, 1), new YCbCr(1, 0, 1)); |
|||
Assert.Equal(new YCbCr(Vector3.One), new YCbCr(Vector3.One)); |
|||
Assert.False(x.Equals(y)); |
|||
Assert.False(x.Equals((object)y)); |
|||
Assert.False(x.GetHashCode().Equals(y.GetHashCode())); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue