public void FromHexChars_Regularly_ShouldReturnExpectedOutput(string text, string hexString) { var chars = System.Text.Encoding.UTF8.GetBytes(hexString); Span <byte> outputBytes = stackalloc byte[text.Length]; Hexadecimal.FromHexChars(chars, outputBytes); var originalString = System.Text.Encoding.UTF8.GetString(outputBytes); Assert.Equal(text, originalString); }
public void FromHexChars_AfterToHexChars_ShouldReturnOriginalInput(string text, string hexString) { var bytes = System.Text.Encoding.UTF8.GetBytes(text); Span <byte> outputChars = stackalloc byte[hexString.Length]; Hexadecimal.ToHexChars(bytes, outputChars); Span <byte> decodedBytes = stackalloc byte[bytes.Length]; Hexadecimal.FromHexChars(outputChars, decodedBytes); var originalString = System.Text.Encoding.UTF8.GetString(decodedBytes); Assert.Equal(text, originalString); }