1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-10 03:45:41 +00:00

[X10D.Unity] Add tests for Color(32).Deconstruct

This commit is contained in:
Oliver Booth 2023-02-27 13:55:06 +00:00
parent 55a2e99b82
commit 3607034818
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
2 changed files with 38 additions and 0 deletions

View File

@ -18,6 +18,25 @@ namespace X10D.Unity.Tests.Drawing
private static readonly Color32 Magenta = new(255, 0, 255, 255); private static readonly Color32 Magenta = new(255, 0, 255, 255);
private static readonly Color32 Yellow = new(255, 255, 0, 255); private static readonly Color32 Yellow = new(255, 255, 0, 255);
[UnityTest]
public IEnumerator Deconstruct_ShouldDeconstruct_ToCorrectValues()
{
byte a, r, g, b;
(r, g, b) = White;
Assert.AreEqual(255, r);
Assert.AreEqual(255, g);
Assert.AreEqual(255, b);
(a, r, g, b) = Yellow;
Assert.AreEqual(255, a);
Assert.AreEqual(255, r);
Assert.AreEqual(255, g);
Assert.AreEqual(0, b);
yield break;
}
[UnityTest] [UnityTest]
public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor() public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
{ {

View File

@ -20,6 +20,25 @@ namespace X10D.Unity.Tests.Drawing
private static readonly Color Magenta = new(1, 0, 1); private static readonly Color Magenta = new(1, 0, 1);
private static readonly Color Yellow = new(1, 1, 0); private static readonly Color Yellow = new(1, 1, 0);
[UnityTest]
public IEnumerator Deconstruct_ShouldDeconstruct_ToCorrectValues()
{
float a, r, g, b;
(r, g, b) = White;
Assert.AreEqual(1.0f, r);
Assert.AreEqual(1.0f, g);
Assert.AreEqual(1.0f, b);
(a, r, g, b) = Yellow;
Assert.AreEqual(1.0f, a);
Assert.AreEqual(1.0f, r);
Assert.AreEqual(1.0f, g);
Assert.AreEqual(0.0f, b);
yield break;
}
[UnityTest] [UnityTest]
public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor() public IEnumerator GetClosestConsoleColor_ShouldReturnClosestColor_GivenValidColor()
{ {