public void Decode_HandlesNegativeZero() { var encoded = Base64.Encode((byte)(StructureByte(0) | 0x1)).ToString(); Assert.That(VlqDecoder.Decode(ref encoded), Is.EqualTo(0)); Assert.That(encoded, Is.EqualTo(string.Empty)); }
public void Decode_AmendsInputStringForUnprocessedTokens() { var encoded = "6rk2BxhsuC"; Assert.That(VlqDecoder.Decode(ref encoded), Is.EqualTo(886973)); Assert.That(encoded, Is.EqualTo("xhsuC")); }
public void Decode_HandlesMultiDigitPositiveValues() { // Example encoded value from http://qfox.nl/weblog/281 var encoded = "6rk2B"; Assert.That(VlqDecoder.Decode(ref encoded), Is.EqualTo(886973)); }
public void Decode_HandlesSinglePositiveValues() { var encoded = Base64.Encode(StructureByte(12)).ToString(); Assert.That(VlqDecoder.Decode(ref encoded), Is.EqualTo(12)); Assert.That(encoded, Is.EqualTo(string.Empty)); }
public MappingSegment(int generatedLineIndex, string encodedFields) { GeneratedLineIndex = generatedLineIndex; GeneratedColumnIndex = VlqDecoder.Decode(ref encodedFields); SourcesIndex = GetNextValue(ref encodedFields); SourceLineIndex = GetNextValue(ref encodedFields); SourceColumnIndex = GetNextValue(ref encodedFields); NamesIndex = GetNextValue(ref encodedFields); }
public void Decode_HandlesMultiDigitNegativeValues() { var encoded = "xhsuC"; Assert.That(VlqDecoder.Decode(ref encoded), Is.EqualTo(-1284120)); }
public void Decode_ThrowsArgumentException_IfContinuationTokenButNoRemainingChars() { var encoded = Base64.Encode(63).ToString(); Assert.Throws(typeof(ArgumentException), () => VlqDecoder.Decode(ref encoded)); }
public void Decode_ThrowsArgumentException_IfNoCharsInInputString() { var empty = string.Empty; Assert.Throws(typeof(ArgumentException), () => VlqDecoder.Decode(ref empty)); }
private static int?GetNextValue(ref string encoded) { return(encoded.Length == 0 ? null : (int?)VlqDecoder.Decode(ref encoded)); }