Browse Source

Fix colorspace string representation tests.

af/merge-core
James Jackson-South 8 years ago
parent
commit
8a6d032022
  1. 2
      src/ImageSharp/ColorSpaces/CieLch.cs
  2. 2
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  3. 2
      src/ImageSharp/ColorSpaces/CieLuv.cs
  4. 2
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  5. 2
      src/ImageSharp/ColorSpaces/CieXyy.cs
  6. 2
      src/ImageSharp/ColorSpaces/CieXyz.cs
  7. 2
      src/ImageSharp/ColorSpaces/Cmyk.cs
  8. 2
      src/ImageSharp/ColorSpaces/Hsl.cs
  9. 2
      src/ImageSharp/ColorSpaces/Hsv.cs
  10. 2
      src/ImageSharp/ColorSpaces/HunterLab.cs
  11. 2
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  12. 2
      src/ImageSharp/ColorSpaces/Lms.cs
  13. 2
      src/ImageSharp/ColorSpaces/Rgb.cs
  14. 2
      src/ImageSharp/ColorSpaces/YCbCr.cs
  15. 65
      tests/ImageSharp.Tests/Colorspaces/Conversion/StringRepresentationTests.cs
  16. 65
      tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs

2
src/ImageSharp/ColorSpaces/CieLch.cs

@ -128,7 +128,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLch [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}]";
public override string ToString() => $"CieLch({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})";
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

2
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLchuv [ L={this.L:#0.##}, C={this.C:#0.##}, H={this.H:#0.##}";
public override string ToString() => $"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLuv [ L={this.L:#0.##}, U={this.U:#0.##}, V={this.V:#0.##} ]";
public override string ToString() => $"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
public override int GetHashCode() => HashHelpers.Combine(this.X.GetHashCode(), this.Y.GetHashCode());
/// <inheritdoc/>
public override string ToString() => $"CieXyChromaticityCoordinates [ X={this.X:#0.##}, Y={this.Y:#0.##}]";
public override string ToString() => $"CieXyChromaticityCoordinates({this.X:#0.##}, {this.Y:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyChromaticityCoordinates other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -91,7 +91,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieXyy [ X={this.X:#0.##}, Y={this.Y:#0.##}, Yl={this.Yl:#0.##} ]";
public override string ToString() => $"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyy other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieXyz [ X={this.X:#0.##}, Y={this.Y:#0.##}, Z={this.Z:#0.##} ]";
public override string ToString() => $"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Cmyk [ C={this.C:#0.##}, M={this.M:#0.##}, Y={this.Y:#0.##}, K={this.K:#0.##}]";
public override string ToString() => $"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Hsl.cs

@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Hsl [ H={this.H:#0.##}, S={this.S:#0.##}, L={this.L:#0.##} ]";
public override string ToString() => $"Hsl({this.H:#0.##}, {this.S:#0.##}, {this.L:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsl other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Hsv.cs

@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Hsv [ H={this.H:#0.##}, S={this.S:#0.##}, V={this.V:#0.##} ]";
public override string ToString() => $"Hsv({this.H:#0.##}, {this.S:#0.##}, {this.V:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsv other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"HunterLab [ L={this.L:#0.##}, A={this.A:#0.##}, B={this.B:#0.##}]";
public override string ToString() => $"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"LinearRgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
public override string ToString() => $"LinearRgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Lms.cs

@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Lms [ L={this.L:#0.##}, M={this.M:#0.##}, S={this.S:#0.##} ]";
public override string ToString() => $"Lms({this.L:#0.##}, {this.M:#0.##}, {this.S:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Lms other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/Rgb.cs

@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Rgb [ R={this.R:#0.##}, G={this.G:#0.##}, B={this.B:#0.##} ]";
public override string ToString() => $"Rgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Rgb other && this.Equals(other);

2
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"YCbCr [ Y={this.Y}, Cb={this.Cb}, Cr={this.Cr} ]";
public override string ToString() => $"YCbCr({this.Y}, {this.Cb}, {this.Cr})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other);

65
tests/ImageSharp.Tests/Colorspaces/Conversion/StringRepresentationTests.cs

@ -1,65 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.ColorSpaces;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Colorspaces.Conversion
{
public class StringRepresentationTests
{
private static readonly Vector3 one = new Vector3(1);
private static readonly Vector3 zero = new Vector3(0);
private static readonly Vector3 random = new Vector3(42.4F, 94.5F, 83.4F);
public static readonly TheoryData<object, string> TestData = new TheoryData<object, string>
{
{ new CieLab(zero), "CieLab(0,0,0)" },
{ new CieLch(zero), "CieLch(0,0,0)" },
{ new CieLchuv(zero), "CieLchuv(0,0,0)" },
{ new CieLuv(zero), "CieLuv(0,0,0)" },
{ new CieXyz(zero), "CieXyz(0,0,0)" },
{ new CieXyy(zero), "CieXyy(0,0,0)" },
{ new HunterLab(zero), "HunterLab(0,0,0)" },
{ new Lms(zero), "Lms(0,0,0)" },
{ new LinearRgb(zero), "LinearRgb(0,0,0)" },
{ new Rgb(zero), "Rgb(0,0,0)" },
{ new Hsl(zero), "Hsl(0,0,0)" },
{ new Hsv(zero), "Hsv(0,0,0)" },
{ new YCbCr(zero), "YCbCr(0,0,0)" },
{ new CieLab(one), "CieLab(1,1,1)" },
{ new CieLch(one), "CieLch(1,1,1)" },
{ new CieLchuv(one), "CieLchuv(1,1,1)" },
{ new CieLuv(one), "CieLuv(1,1,1)" },
{ new CieXyz(one), "CieXyz(1,1,1)" },
{ new CieXyy(one), "CieXyy(1,1,1)" },
{ new HunterLab(one), "HunterLab(1,1,1)" },
{ new Lms(one), "Lms(1,1,1)" },
{ new LinearRgb(one), "LinearRgb(1,1,1)" },
{ new Rgb(one), "Rgb(1,1,1)" },
{ new Hsl(one), "Hsl(1,1,1)" },
{ new Hsv(one), "Hsv(1,1,1)" },
{ new YCbCr(one), "YCbCr(1,1,1)" },
{ new CieLab(random), "CieLab(42.4,94.5,83.4)" },
{ new CieLch(random), "CieLch(42.4,94.5,83.4)" },
{ new CieLchuv(random), "CieLchuv(42.4,94.5,83.4)" },
{ new CieLuv(random), "CieLuv(42.4,94.5,83.4)" },
{ new CieXyz(random), "CieXyz(42.4,94.5,83.4)" },
{ new CieXyy(random), "CieXyy(42.4,94.5,83.4)" },
{ new HunterLab(random), "HunterLab(42.4,94.5,83.4)" },
{ new Lms(random), "Lms(42.4,94.5,83.4)" },
{ new LinearRgb(random), "LinearRgb(1,1,1)" }, // clamping to 1 is expected
{ new Rgb(random), "Rgb(1,1,1)" }, // clamping to 1 is expected
{ new Hsl(random), "Hsl(42.4,1,1)" }, // clamping to 1 is expected
{ new Hsv(random), "Hsv(42.4,1,1)" }, // clamping to 1 is expected
{ new YCbCr(random), "YCbCr(42.4,94.5,83.4)" },
};
[Theory]
[MemberData(nameof(TestData))]
public void StringRepresentationsAreCorrect(object color, string text) => Assert.Equal(text, color.ToString());
}
}

65
tests/ImageSharp.Tests/Colorspaces/StringRepresentationTests.cs

@ -0,0 +1,65 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using SixLabors.ImageSharp.ColorSpaces;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Colorspaces
{
public class StringRepresentationTests
{
private static readonly Vector3 one = new Vector3(1);
private static readonly Vector3 zero = new Vector3(0);
private static readonly Vector3 random = new Vector3(42.4F, 94.5F, 83.4F);
public static readonly TheoryData<object, string> TestData = new TheoryData<object, string>
{
{ new CieLab(zero), "CieLab(0, 0, 0)" },
{ new CieLch(zero), "CieLch(0, 0, 0)" },
{ new CieLchuv(zero), "CieLchuv(0, 0, 0)" },
{ new CieLuv(zero), "CieLuv(0, 0, 0)" },
{ new CieXyz(zero), "CieXyz(0, 0, 0)" },
{ new CieXyy(zero), "CieXyy(0, 0, 0)" },
{ new HunterLab(zero), "HunterLab(0, 0, 0)" },
{ new Lms(zero), "Lms(0, 0, 0)" },
{ new LinearRgb(zero), "LinearRgb(0, 0, 0)" },
{ new Rgb(zero), "Rgb(0, 0, 0)" },
{ new Hsl(zero), "Hsl(0, 0, 0)" },
{ new Hsv(zero), "Hsv(0, 0, 0)" },
{ new YCbCr(zero), "YCbCr(0, 0, 0)" },
{ new CieLab(one), "CieLab(1, 1, 1)" },
{ new CieLch(one), "CieLch(1, 1, 1)" },
{ new CieLchuv(one), "CieLchuv(1, 1, 1)" },
{ new CieLuv(one), "CieLuv(1, 1, 1)" },
{ new CieXyz(one), "CieXyz(1, 1, 1)" },
{ new CieXyy(one), "CieXyy(1, 1, 1)" },
{ new HunterLab(one), "HunterLab(1, 1, 1)" },
{ new Lms(one), "Lms(1, 1, 1)" },
{ new LinearRgb(one), "LinearRgb(1, 1, 1)" },
{ new Rgb(one), "Rgb(1, 1, 1)" },
{ new Hsl(one), "Hsl(1, 1, 1)" },
{ new Hsv(one), "Hsv(1, 1, 1)" },
{ new YCbCr(one), "YCbCr(1, 1, 1)" },
{ new CieLab(random), "CieLab(42.4, 94.5, 83.4)" },
{ new CieLch(random), "CieLch(42.4, 94.5, 83.4)" },
{ new CieLchuv(random), "CieLchuv(42.4, 94.5, 83.4)" },
{ new CieLuv(random), "CieLuv(42.4, 94.5, 83.4)" },
{ new CieXyz(random), "CieXyz(42.4, 94.5, 83.4)" },
{ new CieXyy(random), "CieXyy(42.4, 94.5, 83.4)" },
{ new HunterLab(random), "HunterLab(42.4, 94.5, 83.4)" },
{ new Lms(random), "Lms(42.4, 94.5, 83.4)" },
{ new LinearRgb(random), "LinearRgb(1, 1, 1)" }, // clamping to 1 is expected
{ new Rgb(random), "Rgb(1, 1, 1)" }, // clamping to 1 is expected
{ new Hsl(random), "Hsl(42.4, 1, 1)" }, // clamping to 1 is expected
{ new Hsv(random), "Hsv(42.4, 1, 1)" }, // clamping to 1 is expected
{ new YCbCr(random), "YCbCr(42.4, 94.5, 83.4)" },
};
[Theory]
[MemberData(nameof(TestData))]
public void StringRepresentationsAreCorrect(object color, string text) => Assert.Equal(text, color.ToString());
}
}
Loading…
Cancel
Save