Test packed UInt64

This commit is contained in:
Paul Pacheco 2018-07-17 07:22:46 -05:00
parent 6581497e0c
commit bb605930ea

View File

@ -61,7 +61,7 @@ public void TestPackedUInt32()
writer.WritePackedUInt32(67821);
writer.WritePackedUInt32(16777210);
writer.WritePackedUInt32(16777219);
writer.WritePackedUInt32(UInt16.MaxValue);
writer.WritePackedUInt32(UInt32.MaxValue);
writer.FinishMessage();
@ -74,7 +74,42 @@ public void TestPackedUInt32()
Assert.That(reader.ReadPackedUInt32(), Is.EqualTo(67821));
Assert.That(reader.ReadPackedUInt32(), Is.EqualTo(16777210));
Assert.That(reader.ReadPackedUInt32(), Is.EqualTo(16777219));
Assert.That(reader.ReadPackedUInt32(), Is.EqualTo(UInt16.MaxValue));
Assert.That(reader.ReadPackedUInt32(), Is.EqualTo(UInt32.MaxValue));
}
[Test]
public void TestPackedUInt64()
{
NetworkWriter writer = new NetworkWriter();
writer.StartMessage((short)1337);
writer.WritePackedUInt64(0);
writer.WritePackedUInt64(234);
writer.WritePackedUInt64(2284);
writer.WritePackedUInt64(67821);
writer.WritePackedUInt64(16777210);
writer.WritePackedUInt64(16777219);
writer.WritePackedUInt64(4294967295);
writer.WritePackedUInt64(1099511627775);
writer.WritePackedUInt64(281474976710655);
writer.WritePackedUInt64(72057594037927935);
writer.WritePackedUInt64(UInt64.MaxValue);
writer.FinishMessage();
NetworkReader reader = new NetworkReader(writer.ToArray());
reader.ReadInt16();
Assert.That(reader.ReadUInt16(), Is.EqualTo(1337)); // contentSize (messasge.size - 4 bytes header)
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(0));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(234));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(2284));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(67821));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(16777210));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(16777219));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(4294967295));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(1099511627775));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(281474976710655));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(72057594037927935));
Assert.That(reader.ReadPackedUInt64(), Is.EqualTo(UInt64.MaxValue));
}
[Test]