|
|
|
@ -9,6 +9,36 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats |
|
|
|
{ |
|
|
|
public class NormalizedByte4Tests |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Tests the equality operators for equality.
|
|
|
|
/// </summary>
|
|
|
|
[Fact] |
|
|
|
public void AreEqual() |
|
|
|
{ |
|
|
|
var color1 = new NormalizedByte4(0.0f, 0.0f, 0.0f, 0.0f); |
|
|
|
var color2 = new NormalizedByte4(new Vector4(0.0f)); |
|
|
|
var color3 = new NormalizedByte4(new Vector4(1.0f, 0.0f, 1.0f, 1.0f)); |
|
|
|
var color4 = new NormalizedByte4(1.0f, 0.0f, 1.0f, 1.0f); |
|
|
|
|
|
|
|
Assert.Equal(color1, color2); |
|
|
|
Assert.Equal(color3, color4); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Tests the equality operators for inequality.
|
|
|
|
/// </summary>
|
|
|
|
[Fact] |
|
|
|
public void AreNotEqual() |
|
|
|
{ |
|
|
|
var color1 = new NormalizedByte4(0.0f, 0.0f, 0.0f, 0.0f); |
|
|
|
var color2 = new NormalizedByte4(new Vector4(1.0f)); |
|
|
|
var color3 = new NormalizedByte4(new Vector4(1.0f, 0.0f, 0.0f, 1.0f)); |
|
|
|
var color4 = new NormalizedByte4(1.0f, 1.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
Assert.NotEqual(color1, color2); |
|
|
|
Assert.NotEqual(color3, color4); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_PackedValues() |
|
|
|
{ |
|
|
|
@ -61,6 +91,90 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats |
|
|
|
Assert.Equal(expected, actual); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromArgb32() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromArgb32(new Argb32(255, 255, 255, 255)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromBgr24() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromBgr24(new Bgr24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromGrey8() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromGray8(new Gray8(byte.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromGrey16() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromGray16(new Gray16(ushort.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromRgb24() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromRgb24(new Rgb24(byte.MaxValue, byte.MaxValue, byte.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromRgba32() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromRgba32(new Rgba32(255, 255, 255, 255)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromBgra5551() |
|
|
|
{ |
|
|
|
@ -74,5 +188,47 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats |
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, normalizedByte4.ToVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromRgb48() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromRgb48(new Rgb48(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_FromRgba64() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = default(NormalizedByte4); |
|
|
|
Vector4 expected = Vector4.One; |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.FromRgba64(new Rgba64(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue, ushort.MaxValue)); |
|
|
|
|
|
|
|
// assert
|
|
|
|
Assert.Equal(expected, byte4.ToScaledVector4()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void NormalizedByte4_ToRgba32() |
|
|
|
{ |
|
|
|
// arrange
|
|
|
|
var byte4 = new NormalizedByte4(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); |
|
|
|
var expected = new Rgba32(Vector4.One); |
|
|
|
var actual = default(Rgba32); |
|
|
|
|
|
|
|
// act
|
|
|
|
byte4.ToRgba32(ref actual); |
|
|
|
|
|
|
|
Assert.Equal(expected, actual); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|