예제 #1
0
        public void TestUnsignedMinMax()
        {
            var stream = new MsgPackStream();

            stream.WriteUInt8(byte.MinValue);
            stream.WriteUInt8(byte.MaxValue);
            stream.WriteUInt16(ushort.MinValue);
            stream.WriteUInt16(ushort.MaxValue);
            stream.WriteUInt32(uint.MinValue);
            stream.WriteUInt32(uint.MaxValue);
            stream.WriteUInt64(ulong.MinValue);
            stream.WriteUInt64(ulong.MaxValue);

            stream.Position = 0;
            Assert.AreEqual(byte.MinValue, stream.ReadUInt8());
            Assert.AreEqual(byte.MaxValue, stream.ReadUInt8());
            Assert.AreEqual(ushort.MinValue, stream.ReadUInt16());
            Assert.AreEqual(ushort.MaxValue, stream.ReadUInt16());
            Assert.AreEqual(uint.MinValue, stream.ReadUInt32());
            Assert.AreEqual(uint.MaxValue, stream.ReadUInt32());
            Assert.AreEqual(ulong.MinValue, stream.ReadUInt64());
            Assert.AreEqual(ulong.MaxValue, stream.ReadUInt64());
        }
예제 #2
0
        public void TestUnsigned()
        {
            var stream = new MsgPackStream();

            stream.WriteUInt8(255);
            Assert.AreEqual(stream.Position, 1);

            stream.WriteUInt16(12431);
            Assert.AreEqual(stream.Position, 3);

            stream.WriteUInt32(761);
            Assert.AreEqual(stream.Position, 7);

            stream.WriteUInt64(64);
            Assert.AreEqual(stream.Position, 15);

            stream.Position = 0;
            Assert.AreEqual(255, stream.ReadUInt8());
            Assert.AreEqual(12431, stream.ReadUInt16());
            Assert.AreEqual(761, stream.ReadUInt32());
            Assert.AreEqual(64, stream.ReadUInt64());
        }