Updated CPos struct to use a bit field for all properties.
This commit is contained in:
31
OpenRA.Test/OpenRA.Game/CPosTest.cs
Normal file
31
OpenRA.Test/OpenRA.Game/CPosTest.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user