public void ThreeHundred() { var x = new byte[] { 0xAC, 0x02 }; Assert.AreEqual(2, Varint.RequiredBytes(300)); CollectionAssert.AreEqual(x, Varint.Encode(300)); Assert.AreEqual(300, Varint.DecodeInt32(x)); }
public void MaxLong() { var x = "ffffffffffffffff7f".ToHexBuffer(); Assert.AreEqual(9, Varint.RequiredBytes(long.MaxValue)); CollectionAssert.AreEqual(x, Varint.Encode(long.MaxValue)); Assert.AreEqual(long.MaxValue, Varint.DecodeInt64(x)); }
public void Zero() { var x = new byte[] { 0 }; Assert.AreEqual(1, Varint.RequiredBytes(0)); CollectionAssert.AreEqual(x, Varint.Encode(0)); Assert.AreEqual(0, Varint.DecodeInt32(x)); }