Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public void TooBig_Int32()
        {
            var bytes = Varint.Encode((long)Int32.MaxValue + 1);

            ExceptionAssert.Throws <InvalidDataException>(() => Varint.DecodeInt32(bytes));
        }
Esempio n. 4
0
        public void Decode_From_Offset()
        {
            var x = new byte[] { 0x00, 0xAC, 0x02 };

            Assert.AreEqual(300, Varint.DecodeInt32(x, 1));
        }