Esempio n. 1
0
        public void VarInts()
        {
            var s = new ReusableStream(1000);

            var ints = new ulong[]
            {
                17,
                23,
                0,
                1,
                2,
                127,
                128,
                255,
                256,
                (ulong)short.MaxValue,
                ushort.MaxValue,
                int.MaxValue,
                uint.MaxValue,
                long.MaxValue,
                ulong.MaxValue,
                0x7FUL,
                0x7FUL + 1,
                0x3FFFUL,
                0x3FFFUL + 1,
                0x1FFFFFUL,
                0x1FFFFFUL + 1,
                0xFFFFFFFUL,
                0xFFFFFFFUL + 1,
                0x7FFFFFFFFUL,
                0x7FFFFFFFFUL + 1,
                0x3FFFFFFFFFFUL,
                0x3FFFFFFFFFFUL + 1,
                0x1FFFFFFFFFFFFUL,
                0x1FFFFFFFFFFFFUL + 1,
                0xFFFFFFFFFFFFFFUL,
                0xFFFFFFFFFFFFFFUL + 1,
                0x7FFFFFFFFFFFFFFFUL,
                0x7FFFFFFFFFFFFFFFUL + 1,
            };

            foreach (var ui in ints)
            {
                s.WriteVarUInt(ui);
            }

            s.ResetForReading();

            foreach (var ui in ints)
            {
                var read = s.ReadVarUInt();
                Assert.AreEqual(ui, read);
            }
        }