Пример #1
0
 public Delegate GenerateDecoder(Type type, Func <Type, Delegate> recurse)
 {
     return(new Func <DecodeBuffer, Int16>(input =>
     {
         return (Int16)SignedVlq.Decode(input);
     }));
 }
Пример #2
0
        public void SignedVlqNeg100To100()
        {
            for (var i = -100; i < 100; i++)
            {
                var encoded = SignedVlq.Encode(i).ToArray();
                var output  = SignedVlq.Decode(encoded);

                Assert.Equal(i, output);
            }
        }
Пример #3
0
        public override Object Decode(DecodeBuffer input)
        {
            var v = SignedVlq.Decode(input);

            if (IsNullable)
            {
                if (v == 0)
                {
                    return(null);
                }
                v--;
            }
            v *= Increment;

            return(Convert.ChangeType(v, UnderlyingType));
        }
Пример #4
0
        public void SignedVlqEncodeDecodeA()
        {
            var encoded = SignedVlq.Encode(SignedVlq.MaxValue - Int32.MaxValue ^ 16).ToArray();

            Assert.Equal(SignedVlq.MaxValue - Int32.MaxValue ^ 16, SignedVlq.Decode(encoded));
        }
Пример #5
0
        public void SignedVlqEncodeDecode32()
        {
            var encoded = SignedVlq.Encode(Int32.MaxValue).ToArray();

            Assert.Equal(Int32.MaxValue, SignedVlq.Decode(encoded));
        }