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

31 lines
940 B
C#
Raw Normal View History

2022-03-07 07:36:44 +00:00
using NUnit.Framework;
namespace Aaru.Tests.Helpers;
2022-03-06 13:29:38 +00:00
[TestFixture]
public class Marshal
{
2022-03-06 13:29:38 +00:00
readonly string[] _testStrings =
2024-05-01 04:39:38 +01:00
[
2022-03-06 13:29:38 +00:00
"275048534431364760011a77d2014701", "0235800001000000", "0xbabeface", "0xcefaadde"
2024-05-01 04:39:38 +01:00
];
2022-03-06 13:29:38 +00:00
readonly byte[][] _resultBytes =
2024-05-01 04:39:38 +01:00
[
[0x27, 0x50, 0x48, 0x53, 0x44, 0x31, 0x36, 0x47, 0x60, 0x01, 0x1a, 0x77, 0xd2, 0x01, 0x47, 0x01],
[0x02, 0x35, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00], [0xba, 0xbe, 0xfa, 0xce], [0xce, 0xfa, 0xad, 0xde]
];
2022-03-06 13:29:38 +00:00
[Test]
public void ConvertFromHexAscii()
{
2023-10-03 23:44:33 +01: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);
2024-05-02 03:40:35 +01:00
Assert.That(buf, Has.Length.EqualTo(_resultBytes[i].Length));
Assert.That(count, Is.EqualTo(_resultBytes[i].Length));
Assert.That(buf, Is.EqualTo(_resultBytes[i]));
}
}
}