public static void DecodeInvalidLength(string input) { var base16 = input.ToCharArray(); Assert.False(Base16.TryGetDecodedLength(base16, out var length)); Assert.Equal(0, length); }
public static void Decode(string input, string expected) { var bytes = Encoding.UTF8.GetBytes(expected); var base16 = input.ToCharArray(); Assert.True(Base16.TryGetDecodedLength(base16, out var length)); var actual = new byte[length]; Assert.True(Base16.TryDecode(base16, actual)); Assert.Equal(bytes, actual); }
public static void DecodeInvalidChars(int pos) { var base16 = "00".ToCharArray(); for (var i = 0; i < 65536; i++) { if (i >= '0' && i <= '9' || i >= 'A' && i <= 'F' || i >= 'a' && i <= 'f') { continue; } base16[pos] = (char)i; Assert.True(Base16.TryGetDecodedLength(base16, out var length)); var actual = new byte[length]; Assert.False(Base16.TryDecode(base16, actual)); } }
public static void TryGetDecodedLengthNull() { Assert.Throws <ArgumentNullException>("base16", () => Base16.TryGetDecodedLength((string)null, out var decodedLength)); }