ModernUO/Projects/Server.Tests/Tests/Utility/HexStringConverterTest.cs
Kamron Batman 211c2ba8ee
fix(core): Streamlines text encoding (#407)
- [X] Streamlines text encoding
2021-01-13 18:56:32 -08:00

25 lines
799 B
C#

using System;
using Server.Text;
using Xunit;
namespace Server.Tests
{
public class HexStringConverterTest
{
[Theory, InlineData("ABCDEF1234", new byte[] { 0xAB, 0xCD, 0xEF, 0x12, 0x34 })]
public void TestGetBytes(string input, byte[] bytes)
{
Span<byte> outputBytes = stackalloc byte[input.Length / 2];
HexStringConverter.GetBytes(input, outputBytes);
Assert.Equal(bytes, outputBytes.ToArray());
Assert.Equal(input, bytes.ToHexString());
}
[Theory, InlineData("[AB, CD, EF, 12, 34]", new byte[] { 0xAB, 0xCD, 0xEF, 0x12, 0x34 })]
public void TestsGetStringDelimited(string expected, byte[] bytes)
{
Assert.Equal(expected, bytes.ToDelimitedHexString());
}
}
}