Пример #1
0
        public void TakeTest()
        {
            var bytes = new byte[]
            {
                0x01,
                0x7f,
                0xC2, 0x80,
                0xDF, 0xBF,
                0xE0, 0xA0, 0x80,
                0xEF, 0xBF, 0xBF,
                0xF0, 0x90, 0x80, 0x80,
                0xF7, 0xBF, 0xBF, 0xBF,
                0xF8, 0x88, 0x80, 0x80, 0x80,
                0xFB, 0xBF, 0xBF, 0xBF, 0xBF,
                0xFC, 0x84, 0x80, 0x80, 0x80, 0x80,
                0xFF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF,
                0x00,
                0x01,
            };

            var vilist = VarInt.TakeAll(new ArraySegment <byte>(bytes)).ToArray();

            Assert.AreEqual(12, vilist.Length);
            Assert.AreEqual <VarInt>(1, vilist[0]);
            Assert.AreEqual <VarInt>(0x7F, vilist[1]);
            Assert.AreEqual <VarInt>(0x80, vilist[2]);
            Assert.AreEqual <VarInt>(0x7FF, vilist[3]);
            Assert.AreEqual <VarInt>(0x800, vilist[4]);
            Assert.AreEqual <VarInt>(0xFFFF, vilist[5]);
            Assert.AreEqual <VarInt>(0x10000, vilist[6]);
            Assert.AreEqual <VarInt>(0x1FFFFF, vilist[7]);
            Assert.AreEqual <VarInt>(0x200000, vilist[8]);
            Assert.AreEqual <VarInt>(0x3FFFFFF, vilist[9]);
            Assert.AreEqual <VarInt>(0x4000000, vilist[10]);
            Assert.AreEqual <VarInt>(0xFFFFFFFF, vilist[11]);
        }