Files
plist-cil/plist-cil.test/BinaryPropertyListParserTests.cs

36 lines
1.7 KiB
C#
Raw Normal View History

2018-06-19 17:16:08 +02:00
using Claunia.PropertyList;
using Xunit;
namespace plistcil.test
{
public class BinaryPropertyListParserTests
{
[Theory]
2018-07-09 19:57:08 +01:00
[InlineData(new byte[] {0x08}, 0x08)]
[InlineData(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07}, 7)]
[InlineData(new byte[] {0x00, 0x0e, 0x47, 0x7b}, 0x00000000000e477b)]
2018-06-19 17:16:08 +02:00
public void ParseUnsignedIntTest(byte[] binaryValue, int expectedValue)
{
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseUnsignedInt(binaryValue));
}
[Theory]
2018-07-09 19:57:08 +01:00
[InlineData(new byte[] {0x57}, 0x57)]
[InlineData(new byte[] {0x40, 0x2d, 0xf8, 0x4d}, 0x402df84d)]
[InlineData(new byte[] {0x41, 0xb4, 0x83, 0x98, 0x2a, 0x00, 0x00, 0x00}, 0x41b483982a000000)]
[InlineData(new byte[] {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x19}, unchecked((long)0xfffffffffffffc19))]
2018-06-19 17:16:08 +02:00
public void ParseLongTest(byte[] binaryValue, long expectedValue)
{
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseLong(binaryValue));
}
[Theory]
2018-07-09 19:57:08 +01:00
[InlineData(new byte[] {0x41, 0xb4, 0x83, 0x98, 0x2a, 0x00, 0x00, 0x00}, 344168490)]
[InlineData(new byte[] {0x40, 0x09, 0x21, 0xf9, 0xf0, 0x1b, 0x86, 0x6e}, 3.14159)]
[InlineData(new byte[] {0x40, 0x2d, 0xf8, 0x4d}, 2.71828007698059)]
2018-06-19 17:16:08 +02:00
public void ParseDoubleTest(byte[] binaryValue, double expectedValue)
{
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseDouble(binaryValue), 14);
}
}
2018-07-09 19:57:08 +01:00
}