public void Short4() { // Test the limits. Assert.Equal((ulong)0x0, new Short4(Vector4.Zero).PackedValue); Assert.Equal((ulong)0x7FFF7FFF7FFF7FFF, new Short4(Vector4.One * 0x7FFF).PackedValue); Assert.Equal(0x8000800080008000, new Short4(Vector4.One * -0x8000).PackedValue); // Test ToVector4. Assert.Equal(Vector4.One * 0x7FFF, new Short4(Vector4.One * 0x7FFF).ToVector4()); Assert.Equal(Vector4.Zero, new Short4(Vector4.Zero).ToVector4()); Assert.Equal(Vector4.One * -0x8000, new Short4(Vector4.One * -0x8000).ToVector4()); Assert.Equal(Vector4.UnitX * 0x7FFF, new Short4(Vector4.UnitX * 0x7FFF).ToVector4()); Assert.Equal(Vector4.UnitY * 0x7FFF, new Short4(Vector4.UnitY * 0x7FFF).ToVector4()); Assert.Equal(Vector4.UnitZ * 0x7FFF, new Short4(Vector4.UnitZ * 0x7FFF).ToVector4()); Assert.Equal(Vector4.UnitW * 0x7FFF, new Short4(Vector4.UnitW * 0x7FFF).ToVector4()); // Test clamping. Assert.Equal(Vector4.One * 0x7FFF, new Short4(Vector4.One * 1234567.0f).ToVector4()); Assert.Equal(Vector4.One * -0x8000, new Short4(Vector4.One * -1234567.0f).ToVector4()); // Test Ordering float x = 0.1f; float y = -0.3f; float z = 0.5f; float w = -0.7f; Assert.Equal(18446462598732840960, new Short4(x, y, z, w).PackedValue); x = 11547; y = 12653; z = 29623; w = 193; Assert.Equal((ulong)0x00c173b7316d2d1b, new Short4(x, y, z, w).PackedValue); var rgb = default(Rgb24); var rgba = default(Rgba32); var bgr = default(Bgr24); var bgra = default(Bgra32); new Short4(x, y, z, w).ToRgb24(ref rgb); Assert.Equal(rgb, new Rgb24(172, 177, 243)); new Short4(x, y, z, w).ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(172, 177, 243, 128)); new Short4(x, y, z, w).ToBgr24(ref bgr); Assert.Equal(bgr, new Bgr24(172, 177, 243)); new Short4(x, y, z, w).ToBgra32(ref bgra); Assert.Equal(bgra, new Bgra32(172, 177, 243, 128)); var r = new Short4(); r.PackFromRgba32(new Rgba32(20, 38, 0, 255)); r.ToRgba32(ref rgba); Assert.Equal(rgba, new Rgba32(20, 38, 0, 255)); }
public void Short4_ToRgba32() { // arrange var shortValue = new Short4(11547, 12653, 29623, 193); var actual = default(Rgba32); var expected = new Rgba32(172, 177, 243, 128); // act shortValue.ToRgba32(ref actual); // assert Assert.Equal(expected, actual); }