public Delegate GenerateDecoder(Type type, Func <Type, Delegate> recurse) { return(new Func <DecodeBuffer, Int16>(input => { return (Int16)SignedVlq.Decode(input); })); }
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); } }
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)); }
public void SignedVlqEncodeDecodeA() { var encoded = SignedVlq.Encode(SignedVlq.MaxValue - Int32.MaxValue ^ 16).ToArray(); Assert.Equal(SignedVlq.MaxValue - Int32.MaxValue ^ 16, SignedVlq.Decode(encoded)); }
public void SignedVlqEncodeDecode32() { var encoded = SignedVlq.Encode(Int32.MaxValue).ToArray(); Assert.Equal(Int32.MaxValue, SignedVlq.Decode(encoded)); }