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 Zero() { var x = new byte[] { 0 }; Assert.AreEqual(1, Varint.RequiredBytes(0)); CollectionAssert.AreEqual(x, Varint.Encode(0)); Assert.AreEqual(0, Varint.DecodeInt32(x)); }
public void TooBig_Int32() { var bytes = Varint.Encode((long)Int32.MaxValue + 1); ExceptionAssert.Throws <InvalidDataException>(() => Varint.DecodeInt32(bytes)); }
public void Decode_From_Offset() { var x = new byte[] { 0x00, 0xAC, 0x02 }; Assert.AreEqual(300, Varint.DecodeInt32(x, 1)); }