Updated CPos struct to use a bit field for all properties.

This commit is contained in:
teinarss
2018-10-01 17:57:28 +02:00
committed by Paul Chote
parent 9f82ef999f
commit cfaf5a6467
7 changed files with 61 additions and 14 deletions

View File

@@ -0,0 +1,31 @@
using System.Runtime.Remoting.Metadata;
using NUnit.Framework;
namespace OpenRA.Test
{
[TestFixture]
public class CPosTest
{
[TestCase(TestName = "Packing x,y and layer into int")]
public void PackUnpackBits()
{
var values = new int[] { -2048, -1024, 0, 1024, 2047 };
var layerValues = new byte[] { 0, 128, 255 };
foreach (var x in values)
{
foreach (var y in values)
{
foreach (var layer in layerValues)
{
var cell = new CPos(x, y, layer);
Assert.AreEqual(x, cell.X);
Assert.AreEqual(y, cell.Y);
Assert.AreEqual(layer, cell.Layer);
}
}
}
}
}
}

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Test
var o = new Order("Test", null, Target.Invalid, true)
{
TargetString = "TargetString",
ExtraLocation = new CPos(int.MinValue, int.MaxValue, 128),
ExtraLocation = new CPos(2047, 2047, 128),
ExtraData = uint.MaxValue,
IsImmediate = true,
}.Serialize();