Files
Aaru/Aaru.Tests/Helpers/Marshal.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2022-03-06 13:29:38 +00:00
namespace Aaru.Tests.Helpers;
2022-03-07 07:36:44 +00:00
using NUnit.Framework;
2022-03-06 13:29:38 +00:00
[TestFixture]
public class Marshal
{
2022-03-06 13:29:38 +00:00
readonly string[] _testStrings =
{
2022-03-06 13:29:38 +00:00
"275048534431364760011a77d2014701", "0235800001000000", "0xbabeface", "0xcefaadde"
};
2022-03-06 13:29:38 +00:00
readonly byte[][] _resultBytes =
{
new byte[]
{
0x27, 0x50, 0x48, 0x53, 0x44, 0x31, 0x36, 0x47, 0x60, 0x01, 0x1a, 0x77, 0xd2, 0x01, 0x47, 0x01
},
new byte[]
{
2022-03-06 13:29:38 +00:00
0x02, 0x35, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00
},
new byte[]
{
0xba, 0xbe, 0xfa, 0xce
},
new byte[]
{
0xce, 0xfa, 0xad, 0xde
}
};
2022-03-06 13:29:38 +00:00
[Test]
public void ConvertFromHexAscii()
{
2022-03-07 07:36:44 +00:00
for(var i = 0; i < _testStrings.Length; i++)
{
2022-03-06 13:29:38 +00:00
int count = Aaru.Helpers.Marshal.ConvertFromHexAscii(_testStrings[i], out byte[] buf);
2022-03-06 13:29:38 +00:00
Assert.AreEqual(_resultBytes[i].Length, buf.Length);
Assert.AreEqual(_resultBytes[i].Length, count);
Assert.AreEqual(_resultBytes[i], buf);
}
}
}