mirror of
https://github.com/claunia/plist-cil.git
synced 2025-12-16 19:14:26 +00:00
General refactor and clean-up.
This commit is contained in:
@@ -1,68 +1,99 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class BinaryPropertyListParserTests
|
||||
{
|
||||
public class BinaryPropertyListParserTests
|
||||
{
|
||||
[Theory, 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)]
|
||||
public void ParseUnsignedIntTest(byte[] binaryValue, int expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseUnsignedInt(binaryValue));
|
||||
[Theory]
|
||||
[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)]
|
||||
public void ParseUnsignedIntTest(byte[] binaryValue, int expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseUnsignedInt(binaryValue));
|
||||
|
||||
[Theory, InlineData(new byte[]
|
||||
{
|
||||
0x57
|
||||
}, 0x57), InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34
|
||||
}, 0x1234), InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56
|
||||
}, 0x123456), InlineData(new byte[]
|
||||
{
|
||||
0x40, 0x2d, 0xf8, 0x4d
|
||||
}, 0x402df84d), InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a
|
||||
}, 0x123456789a), InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc
|
||||
}, 0x123456789abc), InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde
|
||||
}, 0x123456789abcde), 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)), InlineData(new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x19
|
||||
}, unchecked((long)0xfffffffffffffc19))]
|
||||
public void ParseLongTest(byte[] binaryValue, long expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseLong(binaryValue));
|
||||
[Theory]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x57
|
||||
},
|
||||
0x57)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34
|
||||
},
|
||||
0x1234)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56
|
||||
},
|
||||
0x123456)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x40, 0x2d, 0xf8, 0x4d
|
||||
},
|
||||
0x402df84d)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a
|
||||
},
|
||||
0x123456789a)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc
|
||||
},
|
||||
0x123456789abc)]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde
|
||||
},
|
||||
0x123456789abcde)]
|
||||
[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))]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x19
|
||||
},
|
||||
unchecked((long)0xfffffffffffffc19))]
|
||||
public void ParseLongTest(byte[] binaryValue, long expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseLong(binaryValue));
|
||||
|
||||
[Theory, 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)]
|
||||
public void ParseDoubleTest(byte[] binaryValue, double expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseDouble(binaryValue), 14);
|
||||
}
|
||||
[Theory]
|
||||
[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)]
|
||||
public void ParseDoubleTest(byte[] binaryValue, double expectedValue) =>
|
||||
Assert.Equal(expectedValue, BinaryPropertyListParser.ParseDouble(binaryValue), 14);
|
||||
}
|
||||
@@ -2,85 +2,87 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class BinaryPropertyListWriterTests
|
||||
{
|
||||
public class BinaryPropertyListWriterTests
|
||||
[Fact]
|
||||
public void Roundtrip2Test()
|
||||
{
|
||||
[Fact]
|
||||
public void Roundtrip2Test()
|
||||
byte[] data = File.ReadAllBytes("test-files/plist2.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
|
||||
using var actualOutput = new MemoryStream();
|
||||
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist2.bin");
|
||||
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist2.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
|
||||
using var actualOutput = new MemoryStream();
|
||||
writer.Write(root);
|
||||
}
|
||||
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist2.bin");
|
||||
[Fact]
|
||||
public void Roundtrip3Test()
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist3.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
using var actualOutput = new MemoryStream();
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist3.bin");
|
||||
|
||||
writer.Write(root);
|
||||
}
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
|
||||
[Fact]
|
||||
public void Roundtrip3Test()
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist3.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
|
||||
using var actualOutput = new MemoryStream();
|
||||
writer.Write(root);
|
||||
}
|
||||
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist3.bin");
|
||||
[Fact]
|
||||
public void Roundtrip4Test()
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist4.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
using var actualOutput = new MemoryStream();
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream);
|
||||
writer.ReuseObjectIds = false;
|
||||
writer.Write(root);
|
||||
}
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist4.bin");
|
||||
|
||||
[Fact]
|
||||
public void Roundtrip4Test()
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist4.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
|
||||
using var actualOutput = new MemoryStream();
|
||||
writer.Write(root);
|
||||
}
|
||||
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist4.bin");
|
||||
[Fact]
|
||||
public void RoundtripTest()
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
using var actualOutput = new MemoryStream();
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist.bin");
|
||||
|
||||
writer.Write(root);
|
||||
}
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
|
||||
[Fact]
|
||||
public void RoundtripTest()
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
byte[] data = File.ReadAllBytes("test-files/plist.bin");
|
||||
NSObject root = PropertyListParser.Parse(data);
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
|
||||
using var actualOutput = new MemoryStream();
|
||||
|
||||
using Stream expectedOutput = File.OpenRead("test-files/plist.bin");
|
||||
|
||||
using var validatingStream = new ValidatingStream(actualOutput, expectedOutput);
|
||||
|
||||
var writer = new BinaryPropertyListWriter(validatingStream)
|
||||
{
|
||||
ReuseObjectIds = false
|
||||
};
|
||||
|
||||
writer.Write(root);
|
||||
}
|
||||
writer.Write(root);
|
||||
}
|
||||
}
|
||||
@@ -27,166 +27,165 @@ using System.IO;
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public static class IssueTest
|
||||
{
|
||||
public static class IssueTest
|
||||
/// <summary>
|
||||
/// Makes sure that binary data is line-wrapped correctly when being serialized, in a scenario where the binary
|
||||
/// data is not indented (no leading whitespace).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void RoundtripDataTest()
|
||||
{
|
||||
/// <summary>
|
||||
/// Makes sure that binary data is line-wrapped correctly when being serialized, in a scenario where the binary
|
||||
/// data is not indented (no leading whitespace).
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void RoundtripDataTest()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripBinary.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinary.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripBinary.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinary.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure that binary data is line-wrapped correctly when being serialized, in a scenario where the binary
|
||||
/// data is indented.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void RoundtripDataTest2()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripBinaryIndentation.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinaryIndentation.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
/// <summary>
|
||||
/// Makes sure that binary data is line-wrapped correctly when being serialized, in a scenario where the binary
|
||||
/// data is indented.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public static void RoundtripDataTest2()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripBinaryIndentation.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinaryIndentation.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void RoundtripRealTest()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripReal.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripReal.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
[Fact]
|
||||
public static void RoundtripRealTest()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/RoundtripReal.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripReal.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, false, true);
|
||||
}
|
||||
Assert.Equal(expected, actual, false, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void RoundtripTest()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/Roundtrip.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/Roundtrip.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
[Fact]
|
||||
public static void RoundtripTest()
|
||||
{
|
||||
string expected = File.ReadAllText(@"test-files/Roundtrip.plist");
|
||||
NSObject value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/Roundtrip.plist"));
|
||||
string actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, false, true);
|
||||
}
|
||||
Assert.Equal(expected, actual, false, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue16()
|
||||
{
|
||||
float x = ((NSNumber)PropertyListParser.Parse(new FileInfo("test-files/issue16.plist"))).floatValue();
|
||||
Assert.True(x == (float)2.71828);
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue16()
|
||||
{
|
||||
float x = ((NSNumber)PropertyListParser.Parse(new FileInfo("test-files/issue16.plist"))).floatValue();
|
||||
Assert.True(x == (float)2.71828);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue18()
|
||||
{
|
||||
var x = new NSNumber(-999);
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue18.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue18.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue18()
|
||||
{
|
||||
var x = new NSNumber(-999);
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue18.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue18.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue21()
|
||||
{
|
||||
string x = ((NSString)PropertyListParser.Parse(new FileInfo("test-files/issue21.plist"))).ToString();
|
||||
Assert.Equal("Lot&s of &persand&s and other escapable \"\'<>€ characters", x);
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue21()
|
||||
{
|
||||
string x = ((NSString)PropertyListParser.Parse(new FileInfo("test-files/issue21.plist"))).ToString();
|
||||
Assert.Equal("Lot&s of &persand&s and other escapable \"\'<>€ characters", x);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue22()
|
||||
{
|
||||
var x1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji.plist"));
|
||||
var x2 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji-xml.plist"));
|
||||
PropertyListParser.SaveAsBinary(x1, new FileInfo("test-files/out-testIssue22.plist"));
|
||||
var y1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22.plist"));
|
||||
PropertyListParser.SaveAsXml(x2, new FileInfo("test-files/out-testIssue22-xml.plist"));
|
||||
var y2 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22-xml.plist"));
|
||||
Assert.True(x1.Equals(x2));
|
||||
Assert.True(x1.Equals(y1));
|
||||
Assert.True(x1.Equals(y2));
|
||||
Assert.True(x2.Equals(y1));
|
||||
Assert.True(x2.Equals(y2));
|
||||
[Fact]
|
||||
public static void TestIssue22()
|
||||
{
|
||||
var x1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji.plist"));
|
||||
var x2 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue22-emoji-xml.plist"));
|
||||
PropertyListParser.SaveAsBinary(x1, new FileInfo("test-files/out-testIssue22.plist"));
|
||||
var y1 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22.plist"));
|
||||
PropertyListParser.SaveAsXml(x2, new FileInfo("test-files/out-testIssue22-xml.plist"));
|
||||
var y2 = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/out-testIssue22-xml.plist"));
|
||||
Assert.True(x1.Equals(x2));
|
||||
Assert.True(x1.Equals(y1));
|
||||
Assert.True(x1.Equals(y2));
|
||||
Assert.True(x2.Equals(y1));
|
||||
Assert.True(x2.Equals(y2));
|
||||
|
||||
string emojiString = "Test Test, \uD83D\uDE30\u2754\uD83D\uDC4D\uD83D\uDC4E\uD83D\uDD25";
|
||||
string emojiString = "Test Test, \uD83D\uDE30\u2754\uD83D\uDC4D\uD83D\uDC4E\uD83D\uDD25";
|
||||
|
||||
Assert.Equal(emojiString, x1.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, x2.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, y1.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, y2.ObjectForKey("emojiString").ToString());
|
||||
}
|
||||
Assert.Equal(emojiString, x1.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, x2.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, y1.ObjectForKey("emojiString").ToString());
|
||||
Assert.Equal(emojiString, y2.ObjectForKey("emojiString").ToString());
|
||||
}
|
||||
|
||||
[Fact(Skip = "Support for property lists with a root element which is not plist is not implemented")]
|
||||
public static void TestIssue30()
|
||||
{
|
||||
#pragma warning disable 219
|
||||
var arr = (NSArray)PropertyListParser.Parse(new FileInfo("test-files/issue30.plist"));
|
||||
#pragma warning restore 219
|
||||
}
|
||||
[Fact(Skip = "Support for property lists with a root element which is not plist is not implemented")]
|
||||
public static void TestIssue30()
|
||||
{
|
||||
#pragma warning disable 219
|
||||
var arr = (NSArray)PropertyListParser.Parse(new FileInfo("test-files/issue30.plist"));
|
||||
#pragma warning restore 219
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue33()
|
||||
{
|
||||
#pragma warning disable 219
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
|
||||
#pragma warning restore 219
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue33()
|
||||
{
|
||||
#pragma warning disable 219
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
|
||||
#pragma warning restore 219
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue38()
|
||||
{
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
|
||||
[Fact]
|
||||
public static void TestIssue38()
|
||||
{
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue33.pbxproj"));
|
||||
|
||||
NSObject fileRef =
|
||||
((NSDictionary)((NSDictionary)dict.Get("objects")).Get("65541A9C16D13B8C00A968D5")).Get("fileRef");
|
||||
NSObject fileRef =
|
||||
((NSDictionary)((NSDictionary)dict.Get("objects")).Get("65541A9C16D13B8C00A968D5")).Get("fileRef");
|
||||
|
||||
Assert.True(fileRef.Equals(new NSString("65541A9B16D13B8C00A968D5")));
|
||||
}
|
||||
Assert.True(fileRef.Equals(new NSString("65541A9B16D13B8C00A968D5")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue4()
|
||||
{
|
||||
var d = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));
|
||||
Assert.Equal("Kid\u2019s iPhone", ((NSString)d.ObjectForKey("Device Name")).ToString());
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue4()
|
||||
{
|
||||
var d = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));
|
||||
Assert.Equal("Kid\u2019s iPhone", ((NSString)d.ObjectForKey("Device Name")).ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue49()
|
||||
{
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue49.plist"));
|
||||
Assert.Empty(dict);
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue49()
|
||||
{
|
||||
var dict = (NSDictionary)PropertyListParser.Parse(new FileInfo("test-files/issue49.plist"));
|
||||
Assert.Empty(dict);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestIssue7()
|
||||
{
|
||||
// also a test for issue 12
|
||||
// the issue4 test has a UTF-16-BE string in its binary representation
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue7.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue7.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
[Fact]
|
||||
public static void TestIssue7()
|
||||
{
|
||||
// also a test for issue 12
|
||||
// the issue4 test has a UTF-16-BE string in its binary representation
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/issue4.plist"));
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testIssue7.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testIssue7.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRealInResourceRule()
|
||||
{
|
||||
var dict = (NSDictionary)XmlPropertyListParser.Parse(new FileInfo("test-files/ResourceRules.plist"));
|
||||
Assert.Single(dict);
|
||||
Assert.True(dict.ContainsKey("weight"));
|
||||
[Fact]
|
||||
public static void TestRealInResourceRule()
|
||||
{
|
||||
var dict = (NSDictionary)XmlPropertyListParser.Parse(new FileInfo("test-files/ResourceRules.plist"));
|
||||
Assert.Single(dict);
|
||||
Assert.True(dict.ContainsKey("weight"));
|
||||
|
||||
object weight = dict["weight"].ToObject();
|
||||
Assert.IsType<double>(weight);
|
||||
Assert.Equal(10d, (double)weight);
|
||||
}
|
||||
object weight = dict["weight"].ToObject();
|
||||
Assert.IsType<double>(weight);
|
||||
Assert.Equal(10d, (double)weight);
|
||||
}
|
||||
}
|
||||
@@ -2,90 +2,89 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class NSArrayTests
|
||||
{
|
||||
public class NSArrayTests
|
||||
/// <summary>Tests the addition of a .NET object to the NSArray</summary>
|
||||
[Fact]
|
||||
public void AddAndContainsObjectTest()
|
||||
{
|
||||
/// <summary>Tests the addition of a .NET object to the NSArray</summary>
|
||||
[Fact]
|
||||
public void AddAndContainsObjectTest()
|
||||
var array = new NSArray
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
1
|
||||
};
|
||||
1
|
||||
};
|
||||
|
||||
Assert.True(array.Contains(1));
|
||||
Assert.False(array.Contains(2));
|
||||
}
|
||||
Assert.True(array.Contains(1));
|
||||
Assert.False(array.Contains(2));
|
||||
}
|
||||
|
||||
/// <summary>Tests the <see cref="NSArray.GetEnumerator" /> method.</summary>
|
||||
[Fact]
|
||||
public void EnumeratorTest()
|
||||
/// <summary>Tests the <see cref="NSArray.GetEnumerator" /> method.</summary>
|
||||
[Fact]
|
||||
public void EnumeratorTest()
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
0,
|
||||
1
|
||||
};
|
||||
0,
|
||||
1
|
||||
};
|
||||
|
||||
using IEnumerator<NSObject> enumerator = array.GetEnumerator();
|
||||
using IEnumerator<NSObject> enumerator = array.GetEnumerator();
|
||||
|
||||
Assert.Null(enumerator.Current);
|
||||
Assert.Null(enumerator.Current);
|
||||
|
||||
Assert.True(enumerator.MoveNext());
|
||||
Assert.Equal(new NSNumber(0), enumerator.Current);
|
||||
Assert.True(enumerator.MoveNext());
|
||||
Assert.Equal(new NSNumber(0), enumerator.Current);
|
||||
|
||||
Assert.True(enumerator.MoveNext());
|
||||
Assert.Equal(new NSNumber(1), enumerator.Current);
|
||||
Assert.True(enumerator.MoveNext());
|
||||
Assert.Equal(new NSNumber(1), enumerator.Current);
|
||||
|
||||
Assert.False(enumerator.MoveNext());
|
||||
}
|
||||
Assert.False(enumerator.MoveNext());
|
||||
}
|
||||
|
||||
/// <summary>Tests the <see cref="NSArray.IndexOf(object)" /> method for .NET objects.</summary>
|
||||
[Fact]
|
||||
public void IndexOfTest()
|
||||
/// <summary>Tests the <see cref="NSArray.IndexOf(object)" /> method for .NET objects.</summary>
|
||||
[Fact]
|
||||
public void IndexOfTest()
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
1,
|
||||
"test"
|
||||
};
|
||||
1,
|
||||
"test"
|
||||
};
|
||||
|
||||
Assert.Equal(0, array.IndexOf(1));
|
||||
Assert.Equal(1, array.IndexOf("test"));
|
||||
}
|
||||
Assert.Equal(0, array.IndexOf(1));
|
||||
Assert.Equal(1, array.IndexOf("test"));
|
||||
}
|
||||
|
||||
/// <summary>Tests the <see cref="NSArray.Insert(int, object)" /> method for a .NET object.</summary>
|
||||
[Fact]
|
||||
public void InsertTest()
|
||||
/// <summary>Tests the <see cref="NSArray.Insert(int, object)" /> method for a .NET object.</summary>
|
||||
[Fact]
|
||||
public void InsertTest()
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
0,
|
||||
1,
|
||||
2
|
||||
};
|
||||
0,
|
||||
1,
|
||||
2
|
||||
};
|
||||
|
||||
array.Insert(1, "test");
|
||||
array.Insert(1, "test");
|
||||
|
||||
Assert.Equal(4, array.Count);
|
||||
Assert.Equal("test", array[1].ToObject());
|
||||
}
|
||||
Assert.Equal(4, array.Count);
|
||||
Assert.Equal("test", array[1].ToObject());
|
||||
}
|
||||
|
||||
/// <summary>Tests the <see cref="NSArray.Remove(object)" /> method for a .NET object.</summary>
|
||||
[Fact]
|
||||
public void RemoveTest()
|
||||
/// <summary>Tests the <see cref="NSArray.Remove(object)" /> method for a .NET object.</summary>
|
||||
[Fact]
|
||||
public void RemoveTest()
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
var array = new NSArray
|
||||
{
|
||||
0
|
||||
};
|
||||
0
|
||||
};
|
||||
|
||||
Assert.False(array.Remove((object)1));
|
||||
Assert.True(array.Remove((object)0));
|
||||
Assert.False(array.Remove((object)1));
|
||||
Assert.True(array.Remove((object)0));
|
||||
|
||||
Assert.Empty(array);
|
||||
}
|
||||
Assert.Empty(array);
|
||||
}
|
||||
}
|
||||
@@ -2,26 +2,25 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class NSDateTests
|
||||
{
|
||||
public class NSDateTests
|
||||
[Fact]
|
||||
public static void ConstructorTest()
|
||||
{
|
||||
[Fact]
|
||||
public static void ConstructorTest()
|
||||
{
|
||||
var actual = new NSDate("2000-01-01T00:00:00Z");
|
||||
var expected = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
Assert.Equal(expected, actual.Date.ToUniversalTime());
|
||||
}
|
||||
var actual = new NSDate("2000-01-01T00:00:00Z");
|
||||
var expected = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
Assert.Equal(expected, actual.Date.ToUniversalTime());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void MakeDateStringTest()
|
||||
{
|
||||
var date = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
string expected = "2000-01-01T00:00:00Z";
|
||||
string actual = NSDate.MakeDateString(date);
|
||||
[Fact]
|
||||
public static void MakeDateStringTest()
|
||||
{
|
||||
var date = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
string expected = "2000-01-01T00:00:00Z";
|
||||
string actual = NSDate.MakeDateString(date);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
@@ -3,521 +3,513 @@ using System.Collections.Generic;
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class NSNumberTests
|
||||
{
|
||||
public class NSNumberTests
|
||||
public static IEnumerable<object[]> SpanConstructorTestData() => new List<object[]>
|
||||
{
|
||||
public static IEnumerable<object[]> SpanConstructorTestData() => new List<object[]>
|
||||
// INTEGER values
|
||||
// 0
|
||||
new object[]
|
||||
{
|
||||
// INTEGER values
|
||||
// 0
|
||||
new object[]
|
||||
new byte[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00
|
||||
},
|
||||
NSNumber.INTEGER, false, 0, 0.0
|
||||
0x00
|
||||
},
|
||||
NSNumber.INTEGER, false, 0, 0.0
|
||||
},
|
||||
|
||||
// 1-byte value < sbyte.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10
|
||||
},
|
||||
NSNumber.INTEGER, true, 16, 16.0
|
||||
},
|
||||
|
||||
// 1-byte value > sbyte.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, byte.MaxValue, (double)byte.MaxValue
|
||||
},
|
||||
|
||||
// 2-byte value < short.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 4096, 4096.0
|
||||
},
|
||||
|
||||
// 2-byte value > short.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, ushort.MaxValue, (double)ushort.MaxValue
|
||||
},
|
||||
|
||||
// 4-byte value < int.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 0x10000000, 1.0 * 0x10000000
|
||||
},
|
||||
|
||||
// 4-bit value > int.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, uint.MaxValue, (double)uint.MaxValue
|
||||
},
|
||||
|
||||
// 64-bit value < long.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 0x1000000000000000, 1.0 * 0x1000000000000000
|
||||
},
|
||||
|
||||
// 64-bit value > long.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, -1, -1.0
|
||||
},
|
||||
|
||||
// 128-bit positive value
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, unchecked((long)0xffffffffffffa000), 1.0 * unchecked((long)0xffffffffffffa000)
|
||||
},
|
||||
|
||||
// 128-bit negative value
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
},
|
||||
NSNumber.INTEGER, true, -1, -1.0
|
||||
},
|
||||
|
||||
// REAL values
|
||||
// 4-byte value (float)
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.0
|
||||
},
|
||||
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x41, 0x20, 0x00, 0x00
|
||||
},
|
||||
NSNumber.REAL, true, 10, 10.0
|
||||
},
|
||||
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x3d, 0xcc, 0xcc, 0xcd
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.1
|
||||
},
|
||||
|
||||
// 8-byte value (double)
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.0
|
||||
},
|
||||
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.REAL, true, 10, 10.0
|
||||
},
|
||||
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x3f, 0xb9, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.1
|
||||
}
|
||||
};
|
||||
|
||||
[Theory, MemberData(nameof(SpanConstructorTestData))]
|
||||
public void SpanConstructorTest(byte[] data, int type, bool boolValue, long longValue, double doubleValue)
|
||||
// 1-byte value < sbyte.maxValue
|
||||
new object[]
|
||||
{
|
||||
var number = new NSNumber((Span<byte>)data, type);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
new byte[]
|
||||
{
|
||||
0x10
|
||||
},
|
||||
NSNumber.INTEGER, true, 16, 16.0
|
||||
},
|
||||
|
||||
// 1-byte value > sbyte.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, byte.MaxValue, (double)byte.MaxValue
|
||||
},
|
||||
|
||||
// 2-byte value < short.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 4096, 4096.0
|
||||
},
|
||||
|
||||
// 2-byte value > short.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, ushort.MaxValue, (double)ushort.MaxValue
|
||||
},
|
||||
|
||||
// 4-byte value < int.maxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 0x10000000, 1.0 * 0x10000000
|
||||
},
|
||||
|
||||
// 4-bit value > int.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, uint.MaxValue, (double)uint.MaxValue
|
||||
},
|
||||
|
||||
// 64-bit value < long.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, 0x1000000000000000, 1.0 * 0x1000000000000000
|
||||
},
|
||||
|
||||
// 64-bit value > long.MaxValue
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
||||
},
|
||||
NSNumber.INTEGER, true, -1, -1.0
|
||||
},
|
||||
|
||||
// 128-bit positive value
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xa0, 0x00
|
||||
},
|
||||
NSNumber.INTEGER, true, unchecked((long)0xffffffffffffa000), 1.0 * unchecked((long)0xffffffffffffa000)
|
||||
},
|
||||
|
||||
// 128-bit negative value
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||
},
|
||||
NSNumber.INTEGER, true, -1, -1.0
|
||||
},
|
||||
|
||||
// REAL values
|
||||
// 4-byte value (float)
|
||||
new object[]
|
||||
{
|
||||
"\0\0\0\0"u8.ToArray(),
|
||||
NSNumber.REAL, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"A \0\0"u8.ToArray(),
|
||||
NSNumber.REAL, true, 10, 10.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x3d, 0xcc, 0xcc, 0xcd
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.1
|
||||
},
|
||||
|
||||
// 8-byte value (double)
|
||||
new object[]
|
||||
{
|
||||
"\0\0\0\0\0\0\0\0"u8.ToArray(),
|
||||
NSNumber.REAL, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"@$\0\0\0\0\0\0"u8.ToArray(),
|
||||
NSNumber.REAL, true, 10, 10.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
new byte[]
|
||||
{
|
||||
0x3f, 0xb9, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a
|
||||
},
|
||||
NSNumber.REAL, false, 0, 0.1
|
||||
}
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void SpanConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((Span<byte>)null, NSNumber.INTEGER));
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((Span<byte>)null, NSNumber.REAL));
|
||||
[Theory]
|
||||
[MemberData(nameof(SpanConstructorTestData))]
|
||||
public void SpanConstructorTest(byte[] data, int type, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber((Span<byte>)data, type);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(),
|
||||
NSNumber.INTEGER));
|
||||
[Fact]
|
||||
public void SpanConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((Span<byte>)null, NSNumber.INTEGER));
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((Span<byte>)null, NSNumber.REAL));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(), NSNumber.REAL));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(), 9));
|
||||
}
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(),
|
||||
NSNumber.INTEGER));
|
||||
|
||||
[Fact]
|
||||
public void StringAndTypeConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((string)null, NSNumber.INTEGER));
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((string)null, NSNumber.REAL));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber("0", 9));
|
||||
}
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(), NSNumber.REAL));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber((Span<byte>)Array.Empty<byte>(), 9));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void NSNumberConstructorTest()
|
||||
{
|
||||
var number = new NSNumber("10032936613", NSNumber.INTEGER);
|
||||
Assert.Equal(NSNumber.INTEGER, number.GetNSNumberType());
|
||||
Assert.Equal(10032936613, number.ToObject());
|
||||
}
|
||||
[Fact]
|
||||
public void StringAndTypeConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((string)null, NSNumber.INTEGER));
|
||||
Assert.Throws<ArgumentNullException>(() => new NSNumber((string)null, NSNumber.REAL));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber("0", 9));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void NSNumberWithDecimalTest()
|
||||
{
|
||||
var number = new NSNumber("1360155352.748765", NSNumber.REAL);
|
||||
Assert.Equal("1360155352.748765", number.ToString());
|
||||
}
|
||||
[Fact]
|
||||
public static void NSNumberConstructorTest()
|
||||
{
|
||||
var number = new NSNumber("10032936613", NSNumber.INTEGER);
|
||||
Assert.Equal(NSNumber.INTEGER, number.GetNSNumberType());
|
||||
Assert.Equal(10032936613, number.ToObject());
|
||||
}
|
||||
|
||||
// The tests below make sure the numbers are being parsed correctly, and do not depend on the culture info
|
||||
// being set. Especially, decimal point may vary between cultures and we don't want to take a dependency on that
|
||||
// The value being used comes seen in a real property list:
|
||||
[Fact]
|
||||
public static void NSNumberWithDecimalTest()
|
||||
{
|
||||
var number = new NSNumber("1360155352.748765", NSNumber.REAL);
|
||||
Assert.Equal("1360155352.748765", number.ToString());
|
||||
}
|
||||
|
||||
// The tests below make sure the numbers are being parsed correctly, and do not depend on the culture info
|
||||
// being set. Especially, decimal point may vary between cultures and we don't want to take a dependency on that
|
||||
// The value being used comes seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
[Fact]
|
||||
[UseCulture("en-US")]
|
||||
public static void ParseNumberEnTest()
|
||||
{
|
||||
var number = new NSNumber("7200.000001");
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200.000001d, number.ToDouble());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[UseCulture("nl-BE")]
|
||||
public static void ParseNumberNlTest()
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
[Fact, UseCulture("en-US")]
|
||||
public static void ParseNumberEnTest()
|
||||
var number = new NSNumber("7200.000001");
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200.000001d, number.ToDouble());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[UseCulture("en-US")]
|
||||
public static void ParseNumberEnTest2()
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
var number = new NSNumber("7200.000000", NSNumber.REAL);
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200d, number.ToDouble());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[UseCulture("nl-BE")]
|
||||
public static void ParseNumberNlTest2()
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
var number = new NSNumber("7200.000000", NSNumber.REAL);
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200d, number.ToDouble());
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> StringConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
var number = new NSNumber("7200.000001");
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200.000001d, number.ToDouble());
|
||||
"0x00", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x1000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x00001000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x0000000000001000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
|
||||
// Long values, formatted as decimal values
|
||||
new object[]
|
||||
{
|
||||
"0", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"10", true, 10, 10.0
|
||||
},
|
||||
|
||||
// Decimal values
|
||||
new object[]
|
||||
{
|
||||
"0.0", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0.10", false, 0, 0.1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"3.14", true, 3, 3.14
|
||||
},
|
||||
|
||||
// Boolean values
|
||||
new object[]
|
||||
{
|
||||
"yes", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"true", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"Yes", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"True", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"YES", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"TRUE", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"no", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"false", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"No", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"False", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"NO", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"FALSE", false, 0, 0
|
||||
}
|
||||
};
|
||||
|
||||
[Fact, UseCulture("nl-BE")]
|
||||
public static void ParseNumberNlTest()
|
||||
[Theory]
|
||||
[MemberData(nameof(StringConstructorTestData))]
|
||||
public void StringConstructorTest(string value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber(null));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber("plist"));
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Int32ConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
var number = new NSNumber("7200.000001");
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200.000001d, number.ToDouble());
|
||||
0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
int.MaxValue, true, int.MaxValue, int.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
int.MinValue, true, int.MinValue, int.MinValue
|
||||
}
|
||||
};
|
||||
|
||||
[Fact, UseCulture("en-US")]
|
||||
public static void ParseNumberEnTest2()
|
||||
[Theory]
|
||||
[MemberData(nameof(Int32ConstructorTestData))]
|
||||
public void Int32ConstructorTest(int value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Int64ConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
var number = new NSNumber("7200.000000", NSNumber.REAL);
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200d, number.ToDouble());
|
||||
0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
long.MaxValue, true, long.MaxValue, long.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
long.MinValue, true, long.MinValue, long.MinValue
|
||||
}
|
||||
};
|
||||
|
||||
[Fact, UseCulture("nl-BE")]
|
||||
public static void ParseNumberNlTest2()
|
||||
[Theory]
|
||||
[MemberData(nameof(Int64ConstructorTestData))]
|
||||
public void Int64ConstructorTest(long value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DoubleConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
// As seen in a real property list:
|
||||
// <key>TimeZoneOffsetFromUTC</key>
|
||||
// <real>7200.000000</real>
|
||||
var number = new NSNumber("7200.000000", NSNumber.REAL);
|
||||
Assert.True(number.isReal());
|
||||
Assert.Equal(7200d, number.ToDouble());
|
||||
0.0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1.0, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1.0, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.Epsilon, false, 0, double.Epsilon
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.MaxValue, true, long.MinValue /* Overflow! */, double.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.MinValue, true, long.MinValue, double.MinValue
|
||||
}
|
||||
};
|
||||
|
||||
public static IEnumerable<object[]> StringConstructorTestData() => new List<object[]>
|
||||
[Theory]
|
||||
[MemberData(nameof(DoubleConstructorTestData))]
|
||||
public void DoubleConstructorTest(double value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> BoolConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
"0x00", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x1000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x00001000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0x0000000000001000", true, 0x1000, 1.0 * 0x1000
|
||||
},
|
||||
|
||||
// Long values, formatted as decimal values
|
||||
new object[]
|
||||
{
|
||||
"0", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"10", true, 10, 10.0
|
||||
},
|
||||
|
||||
// Decimal values
|
||||
new object[]
|
||||
{
|
||||
"0.0", false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"0.10", false, 0, 0.1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"3.14", true, 3, 3.14
|
||||
},
|
||||
|
||||
// Boolean values
|
||||
new object[]
|
||||
{
|
||||
"yes", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"true", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"Yes", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"True", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"YES", true, 1, 1
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"TRUE", true, 1, 1
|
||||
},
|
||||
|
||||
new object[]
|
||||
{
|
||||
"no", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"false", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"No", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"False", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"NO", false, 0, 0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
"FALSE", false, 0, 0
|
||||
}
|
||||
};
|
||||
|
||||
[Theory, MemberData(nameof(StringConstructorTestData))]
|
||||
public void StringConstructorTest(string value, bool boolValue, long longValue, double doubleValue)
|
||||
false, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
true, true, 1, 1.0
|
||||
}
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void StringConstructorInvalidValuesTest()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber(null));
|
||||
Assert.Throws<ArgumentException>(() => new NSNumber("plist"));
|
||||
}
|
||||
[Theory]
|
||||
[MemberData(nameof(BoolConstructorTestData))]
|
||||
public void BoolConstructorTest(bool value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Int32ConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
int.MaxValue, true, int.MaxValue, int.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
int.MinValue, true, int.MinValue, int.MinValue
|
||||
}
|
||||
};
|
||||
[Fact]
|
||||
public void EqualTest()
|
||||
{
|
||||
var a = new NSNumber(2);
|
||||
var b = new NSNumber(2);
|
||||
|
||||
[Theory, MemberData(nameof(Int32ConstructorTestData))]
|
||||
public void Int32ConstructorTest(int value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> Int64ConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
long.MaxValue, true, long.MaxValue, long.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
long.MinValue, true, long.MinValue, long.MinValue
|
||||
}
|
||||
};
|
||||
|
||||
[Theory, MemberData(nameof(Int64ConstructorTestData))]
|
||||
public void Int64ConstructorTest(long value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DoubleConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
0.0, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
1.0, true, 1, 1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
-1.0, true, -1, -1.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.Epsilon, false, 0, double.Epsilon
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.MaxValue, true, long.MinValue /* Overflow! */, double.MaxValue
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
double.MinValue, true, long.MinValue, double.MinValue
|
||||
}
|
||||
};
|
||||
|
||||
[Theory, MemberData(nameof(DoubleConstructorTestData))]
|
||||
public void DoubleConstructorTest(double value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> BoolConstructorTestData() => new List<object[]>
|
||||
{
|
||||
// Long values, formatted as hexadecimal values
|
||||
new object[]
|
||||
{
|
||||
false, false, 0, 0.0
|
||||
},
|
||||
new object[]
|
||||
{
|
||||
true, true, 1, 1.0
|
||||
}
|
||||
};
|
||||
|
||||
[Theory, MemberData(nameof(BoolConstructorTestData))]
|
||||
public void BoolConstructorTest(bool value, bool boolValue, long longValue, double doubleValue)
|
||||
{
|
||||
var number = new NSNumber(value);
|
||||
Assert.Equal(boolValue, number.ToBool());
|
||||
Assert.Equal(longValue, number.ToLong());
|
||||
Assert.Equal(doubleValue, number.ToDouble(), 5);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualTest()
|
||||
{
|
||||
var a = new NSNumber(2);
|
||||
var b = new NSNumber(2);
|
||||
|
||||
Assert.Equal(a.GetHashCode(), b.GetHashCode());
|
||||
Assert.True(a.Equals(b));
|
||||
Assert.True(b.Equals(a));
|
||||
}
|
||||
Assert.Equal(a.GetHashCode(), b.GetHashCode());
|
||||
Assert.True(a.Equals(b));
|
||||
Assert.True(b.Equals(a));
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class NSStringTests
|
||||
{
|
||||
public class NSStringTests
|
||||
const string START_TOKEN = "<string>";
|
||||
const string END_TOKEN = "</string>";
|
||||
|
||||
[InlineData("abc", "abc")]
|
||||
[InlineData("a>b", "a>b")]
|
||||
[InlineData("a<b", "a<b")]
|
||||
[InlineData("a&b", "a&b")]
|
||||
[Theory]
|
||||
public void Content_IsEscaped(string value, string content)
|
||||
{
|
||||
const string START_TOKEN = "<string>";
|
||||
const string END_TOKEN = "</string>";
|
||||
var element = new NSString(value);
|
||||
string xml = element.ToXmlPropertyList();
|
||||
|
||||
[InlineData("abc", "abc")]
|
||||
[InlineData("a>b", "a>b")]
|
||||
[InlineData("a<b", "a<b")]
|
||||
[InlineData("a&b", "a&b")]
|
||||
[Theory]
|
||||
public void Content_IsEscaped(string value, string content)
|
||||
{
|
||||
var element = new NSString(value);
|
||||
string xml = element.ToXmlPropertyList();
|
||||
// Strip the leading and trailing data, so we just get the string element itself
|
||||
int start = xml.IndexOf(START_TOKEN) + START_TOKEN.Length;
|
||||
int end = xml.IndexOf(END_TOKEN);
|
||||
string actualContent = xml.Substring(start, end - start);
|
||||
|
||||
// Strip the leading and trailing data, so we just get the string element itself
|
||||
int start = xml.IndexOf(START_TOKEN) + START_TOKEN.Length;
|
||||
int end = xml.IndexOf(END_TOKEN);
|
||||
string actualContent = xml.Substring(start, end - start);
|
||||
|
||||
Assert.Equal(content, actualContent);
|
||||
}
|
||||
Assert.Equal(content, actualContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,315 +29,327 @@ using System.IO;
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public static class ParseTest
|
||||
{
|
||||
public static class ParseTest
|
||||
static bool ArrayEquals(byte[] arrayA, byte[] arrayB)
|
||||
{
|
||||
static bool ArrayEquals(byte[] arrayA, byte[] arrayB)
|
||||
{
|
||||
if(arrayA.Length != arrayB.Length)
|
||||
return false;
|
||||
if(arrayA.Length != arrayB.Length) return false;
|
||||
|
||||
for(int i = 0; i < arrayA.Length; i++)
|
||||
if(arrayA[i] != arrayB[i])
|
||||
return false;
|
||||
for(int i = 0; i < arrayA.Length; i++)
|
||||
if(arrayA[i] != arrayB[i]) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* NSSet only occurs in binary property lists, so we have to test it separately.
|
||||
* NSSets are not yet supported in reading/writing, as binary property list format v1+ is required.
|
||||
*/
|
||||
/*
|
||||
[Fact]
|
||||
public static void TestSet()
|
||||
{
|
||||
NSSet s = new NSSet();
|
||||
s.AddObject(new NSNumber(1));
|
||||
s.AddObject(new NSNumber(3));
|
||||
s.AddObject(new NSNumber(2));
|
||||
|
||||
NSSet orderedSet = new NSSet(true);
|
||||
s.AddObject(new NSNumber(1));
|
||||
s.AddObject(new NSNumber(3));
|
||||
s.AddObject(new NSNumber(2));
|
||||
|
||||
NSDictionary dict = new NSDictionary();
|
||||
dict.Add("set1", s);
|
||||
dict.Add("set2", orderedSet);
|
||||
|
||||
PropertyListParser.SaveAsBinary(dict, new FileInfo("test-files/out-testSet.plist"));
|
||||
NSObject ParsedRoot = PropertyListParser.Parse(new FileInfo("test-files/out-testSet.plist"));
|
||||
Assert.True(ParsedRoot.Equals(dict));
|
||||
}*/
|
||||
[Fact]
|
||||
public static void TestASCII()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1-ascii.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
|
||||
var actualDate = (NSDate)d.ObjectForKey("date");
|
||||
DateTime expectedDate = new DateTime(2011, 11, 28, 9, 21, 30, DateTimeKind.Utc).ToLocalTime();
|
||||
|
||||
Assert.Equal(actualDate.Date, expectedDate);
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes, new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
}));
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSString("YES")));
|
||||
Assert.True(a[1].Equals(new NSString("NO")));
|
||||
Assert.True(a[2].Equals(new NSString("87")));
|
||||
Assert.True(a[3].Equals(new NSString("3.14159")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void testAsciiUtf8CharactersInQuotedString()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test-ascii-utf8.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.Equal(2, d.Count);
|
||||
Assert.Equal("JÔÖú@2x.jpg", d.ObjectForKey("path").ToString());
|
||||
Assert.Equal("QÔÖú@2x 啕.jpg", d.ObjectForKey("Key QÔÖª@2x 䌡").ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestASCIIWriting()
|
||||
{
|
||||
var inf = new FileInfo("test-files/test1.plist");
|
||||
var outf = new FileInfo("test-files/out-test1-ascii.plist");
|
||||
var in2 = new FileInfo("test-files/test1-ascii.plist");
|
||||
var x = (NSDictionary)PropertyListParser.Parse(inf);
|
||||
PropertyListParser.SaveAsASCII(x, outf);
|
||||
|
||||
//Information gets lost when saving into the ASCII format (NSNumbers are converted to NSStrings)
|
||||
|
||||
var y = (NSDictionary)PropertyListParser.Parse(outf);
|
||||
var z = (NSDictionary)PropertyListParser.Parse(in2);
|
||||
Assert.True(y.Equals(z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the binary reader/writer.
|
||||
*/
|
||||
[Fact]
|
||||
public static void TestBinary()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));
|
||||
|
||||
// save and load as binary
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testBinary.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testBinary.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestGnuStepASCII()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1-ascii-gnustep.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
|
||||
Assert.True(((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011, 11, 28, 9, 21, 30,
|
||||
DateTimeKind.Utc).ToLocalTime()));
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes, new byte[]
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
}));
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSNumber(true)));
|
||||
Assert.True(a[1].Equals(new NSNumber(false)));
|
||||
Assert.True(a[2].Equals(new NSNumber(87)));
|
||||
Assert.True(a[3].Equals(new NSNumber(3.14159)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestGnuStepASCIIWriting()
|
||||
{
|
||||
var inf = new FileInfo("test-files/test1.plist");
|
||||
var outf = new FileInfo("test-files/out-test1-ascii-gnustep.plist");
|
||||
var x = (NSDictionary)PropertyListParser.Parse(inf);
|
||||
PropertyListParser.SaveAsGnuStepASCII(x, outf);
|
||||
NSObject y = PropertyListParser.Parse(outf);
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestWrap()
|
||||
{
|
||||
bool bl = true;
|
||||
byte byt = 24;
|
||||
short shrt = 12;
|
||||
int i = 42;
|
||||
long lng = 30000000000L;
|
||||
float flt = 124.3f;
|
||||
double dbl = 32.0;
|
||||
var date = new DateTime();
|
||||
string strg = "Hello World";
|
||||
|
||||
byte[] bytes =
|
||||
{
|
||||
0x00, 0xAF, 0xAF
|
||||
};
|
||||
|
||||
object[] array =
|
||||
{
|
||||
bl, byt, shrt, i, lng, flt, dbl, date, strg, bytes
|
||||
};
|
||||
|
||||
int[] array2 =
|
||||
{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3000
|
||||
};
|
||||
|
||||
List<object> list = new(array);
|
||||
|
||||
Dictionary<string, object> map = new();
|
||||
map.Add("int", i);
|
||||
map.Add("long", lng);
|
||||
map.Add("date", date);
|
||||
|
||||
List<Dictionary<string,object>> listOfMaps = new()
|
||||
{
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "int", i },
|
||||
{ "long", lng },
|
||||
{ "date", date }
|
||||
}
|
||||
};
|
||||
|
||||
var WrappedO = NSObject.Wrap((object)bl);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True(WrappedO.ToObject().Equals(bl));
|
||||
|
||||
WrappedO = NSObject.Wrap((object)byt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == byt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)shrt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == shrt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)i);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == i);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)lng);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((long)WrappedO.ToObject() == lng);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)flt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((double)WrappedO.ToObject() == flt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)dbl);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((double)WrappedO.ToObject() == dbl);
|
||||
|
||||
WrappedO = NSObject.Wrap(date);
|
||||
Assert.True(WrappedO is (NSDate));
|
||||
Assert.True(((DateTime)WrappedO.ToObject()).Equals(date));
|
||||
|
||||
WrappedO = NSObject.Wrap(strg);
|
||||
Assert.True(WrappedO is (NSString));
|
||||
Assert.Equal((string)WrappedO.ToObject(), strg);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)bytes);
|
||||
Assert.True(WrappedO is (NSData));
|
||||
byte[] data = (byte[])WrappedO.ToObject();
|
||||
Assert.True(data.Length == bytes.Length);
|
||||
|
||||
for(int x = 0; x < bytes.Length; x++)
|
||||
Assert.True(data[x] == bytes[x]);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)array);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
object[] objArray = (object[])WrappedO.ToObject();
|
||||
Assert.True(objArray.Length == array.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap(array2);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
Assert.True(((NSArray)WrappedO).Count == array2.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)list);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
objArray = (object[])WrappedO.ToObject();
|
||||
Assert.True(objArray.Length == array.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)map);
|
||||
Assert.True(WrappedO is (NSDictionary));
|
||||
var dict = (NSDictionary)WrappedO;
|
||||
Assert.True(((NSNumber)dict.ObjectForKey("int")).ToLong() == i);
|
||||
Assert.True(((NSNumber)dict.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)dict.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
WrappedO = NSObject.Wrap((object)listOfMaps);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
var arrayOfMaps = (NSArray)WrappedO;
|
||||
Assert.True(arrayOfMaps.Count == 1);
|
||||
var firstMap = (NSDictionary)arrayOfMaps[0];
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("int")).ToLong() == i);
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)firstMap.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
// TODO
|
||||
/*
|
||||
Object unWrappedO = WrappedO.ToObject();
|
||||
Map map2 = (Map)unWrappedO;
|
||||
Assert.True(((int)map.get("int")) == i);
|
||||
Assert.True(((long)map.get("long")) == lng);
|
||||
Assert.True(((DateTime)map.get("date")).Equals(date));*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the xml reader/writer
|
||||
/**
|
||||
* NSSet only occurs in binary property lists, so we have to test it separately.
|
||||
* NSSets are not yet supported in reading/writing, as binary property list format v1+ is required.
|
||||
*/
|
||||
[Fact]
|
||||
public static void TestXml()
|
||||
{
|
||||
// Parse an example plist file
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));
|
||||
/*
|
||||
[Fact]
|
||||
public static void TestSet()
|
||||
{
|
||||
NSSet s = new NSSet();
|
||||
s.AddObject(new NSNumber(1));
|
||||
s.AddObject(new NSNumber(3));
|
||||
s.AddObject(new NSNumber(2));
|
||||
|
||||
// check the data in it
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
NSSet orderedSet = new NSSet(true);
|
||||
s.AddObject(new NSNumber(1));
|
||||
s.AddObject(new NSNumber(3));
|
||||
s.AddObject(new NSNumber(2));
|
||||
|
||||
Assert.True(((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011, 11, 28, 10, 21, 30,
|
||||
DateTimeKind.Utc)) ||
|
||||
((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011, 11, 28, 9, 21, 30,
|
||||
DateTimeKind.Utc)));
|
||||
NSDictionary dict = new NSDictionary();
|
||||
dict.Add("set1", s);
|
||||
dict.Add("set2", orderedSet);
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes, new byte[]
|
||||
PropertyListParser.SaveAsBinary(dict, new FileInfo("test-files/out-testSet.plist"));
|
||||
NSObject ParsedRoot = PropertyListParser.Parse(new FileInfo("test-files/out-testSet.plist"));
|
||||
Assert.True(ParsedRoot.Equals(dict));
|
||||
}*/
|
||||
[Fact]
|
||||
public static void TestASCII()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1-ascii.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
|
||||
var actualDate = (NSDate)d.ObjectForKey("date");
|
||||
DateTime expectedDate = new DateTime(2011, 11, 28, 9, 21, 30, DateTimeKind.Utc).ToLocalTime();
|
||||
|
||||
Assert.Equal(actualDate.Date, expectedDate);
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes,
|
||||
[
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
]));
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSString("YES")));
|
||||
Assert.True(a[1].Equals(new NSString("NO")));
|
||||
Assert.True(a[2].Equals(new NSString("87")));
|
||||
Assert.True(a[3].Equals(new NSString("3.14159")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void testAsciiUtf8CharactersInQuotedString()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test-ascii-utf8.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.Equal(2, d.Count);
|
||||
Assert.Equal("JÔÖú@2x.jpg", d.ObjectForKey("path").ToString());
|
||||
Assert.Equal("QÔÖú@2x 啕.jpg", d.ObjectForKey("Key QÔÖª@2x 䌡").ToString());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestASCIIWriting()
|
||||
{
|
||||
var inf = new FileInfo("test-files/test1.plist");
|
||||
var outf = new FileInfo("test-files/out-test1-ascii.plist");
|
||||
var in2 = new FileInfo("test-files/test1-ascii.plist");
|
||||
var x = (NSDictionary)PropertyListParser.Parse(inf);
|
||||
PropertyListParser.SaveAsASCII(x, outf);
|
||||
|
||||
//Information gets lost when saving into the ASCII format (NSNumbers are converted to NSStrings)
|
||||
|
||||
var y = (NSDictionary)PropertyListParser.Parse(outf);
|
||||
var z = (NSDictionary)PropertyListParser.Parse(in2);
|
||||
Assert.True(y.Equals(z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the binary reader/writer.
|
||||
*/
|
||||
[Fact]
|
||||
public static void TestBinary()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));
|
||||
|
||||
// save and load as binary
|
||||
PropertyListParser.SaveAsBinary(x, new FileInfo("test-files/out-testBinary.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testBinary.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestGnuStepASCII()
|
||||
{
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1-ascii-gnustep.plist"));
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
|
||||
Assert.True(((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011, 11, 28, 9, 21, 30, DateTimeKind.Utc)
|
||||
.ToLocalTime()));
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes,
|
||||
[
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
]));
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSNumber(true)));
|
||||
Assert.True(a[1].Equals(new NSNumber(false)));
|
||||
Assert.True(a[2].Equals(new NSNumber(87)));
|
||||
Assert.True(a[3].Equals(new NSNumber(3.14159)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestGnuStepASCIIWriting()
|
||||
{
|
||||
var inf = new FileInfo("test-files/test1.plist");
|
||||
var outf = new FileInfo("test-files/out-test1-ascii-gnustep.plist");
|
||||
var x = (NSDictionary)PropertyListParser.Parse(inf);
|
||||
PropertyListParser.SaveAsGnuStepASCII(x, outf);
|
||||
NSObject y = PropertyListParser.Parse(outf);
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestWrap()
|
||||
{
|
||||
bool bl = true;
|
||||
byte byt = 24;
|
||||
short shrt = 12;
|
||||
int i = 42;
|
||||
long lng = 30000000000L;
|
||||
float flt = 124.3f;
|
||||
double dbl = 32.0;
|
||||
var date = new DateTime();
|
||||
string strg = "Hello World";
|
||||
|
||||
byte[] bytes =
|
||||
[
|
||||
0x00, 0xAF, 0xAF
|
||||
];
|
||||
|
||||
object[] array =
|
||||
[
|
||||
bl, byt, shrt, i, lng, flt, dbl, date, strg, bytes
|
||||
];
|
||||
|
||||
int[] array2 =
|
||||
[
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3000
|
||||
];
|
||||
|
||||
List<object> list = new(array);
|
||||
|
||||
Dictionary<string, object> map = new();
|
||||
map.Add("int", i);
|
||||
map.Add("long", lng);
|
||||
map.Add("date", date);
|
||||
|
||||
List<Dictionary<string, object>> listOfMaps =
|
||||
[
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
}));
|
||||
{
|
||||
"int", i
|
||||
},
|
||||
{
|
||||
"long", lng
|
||||
},
|
||||
{
|
||||
"date", date
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSNumber(true)));
|
||||
Assert.True(a[1].Equals(new NSNumber(false)));
|
||||
Assert.True(a[2].Equals(new NSNumber(87)));
|
||||
Assert.True(a[3].Equals(new NSNumber(3.14159)));
|
||||
var WrappedO = NSObject.Wrap((object)bl);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True(WrappedO.ToObject().Equals(bl));
|
||||
|
||||
// read/write it, make sure we get the same thing
|
||||
PropertyListParser.SaveAsXml(x, new FileInfo("test-files/out-testXml.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testXml.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
WrappedO = NSObject.Wrap((object)byt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == byt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)shrt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == shrt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)i);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((int)WrappedO.ToObject() == i);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)lng);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((long)WrappedO.ToObject() == lng);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)flt);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((double)WrappedO.ToObject() == flt);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)dbl);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True((double)WrappedO.ToObject() == dbl);
|
||||
|
||||
WrappedO = NSObject.Wrap(date);
|
||||
Assert.True(WrappedO is (NSDate));
|
||||
Assert.True(((DateTime)WrappedO.ToObject()).Equals(date));
|
||||
|
||||
WrappedO = NSObject.Wrap(strg);
|
||||
Assert.True(WrappedO is (NSString));
|
||||
Assert.Equal((string)WrappedO.ToObject(), strg);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)bytes);
|
||||
Assert.True(WrappedO is (NSData));
|
||||
byte[] data = (byte[])WrappedO.ToObject();
|
||||
Assert.True(data.Length == bytes.Length);
|
||||
|
||||
for(int x = 0; x < bytes.Length; x++) Assert.True(data[x] == bytes[x]);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)array);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
object[] objArray = (object[])WrappedO.ToObject();
|
||||
Assert.True(objArray.Length == array.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap(array2);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
Assert.True(((NSArray)WrappedO).Count == array2.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)list);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
objArray = (object[])WrappedO.ToObject();
|
||||
Assert.True(objArray.Length == array.Length);
|
||||
|
||||
WrappedO = NSObject.Wrap((object)map);
|
||||
Assert.True(WrappedO is (NSDictionary));
|
||||
var dict = (NSDictionary)WrappedO;
|
||||
Assert.True(((NSNumber)dict.ObjectForKey("int")).ToLong() == i);
|
||||
Assert.True(((NSNumber)dict.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)dict.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
WrappedO = NSObject.Wrap(listOfMaps);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
var arrayOfMaps = (NSArray)WrappedO;
|
||||
Assert.True(arrayOfMaps.Count == 1);
|
||||
var firstMap = (NSDictionary)arrayOfMaps[0];
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("int")).ToLong() == i);
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)firstMap.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
// TODO
|
||||
/*
|
||||
Object unWrappedO = WrappedO.ToObject();
|
||||
Map map2 = (Map)unWrappedO;
|
||||
Assert.True(((int)map.get("int")) == i);
|
||||
Assert.True(((long)map.get("long")) == lng);
|
||||
Assert.True(((DateTime)map.get("date")).Equals(date));*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the xml reader/writer
|
||||
*/
|
||||
[Fact]
|
||||
public static void TestXml()
|
||||
{
|
||||
// Parse an example plist file
|
||||
NSObject x = PropertyListParser.Parse(new FileInfo("test-files/test1.plist"));
|
||||
|
||||
// check the data in it
|
||||
var d = (NSDictionary)x;
|
||||
Assert.True(d.Count == 5);
|
||||
Assert.Equal("valueA", ((NSString)d.ObjectForKey("keyA")).ToString());
|
||||
Assert.Equal("value&B", ((NSString)d.ObjectForKey("key&B")).ToString());
|
||||
|
||||
Assert.True(((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011,
|
||||
11,
|
||||
28,
|
||||
10,
|
||||
21,
|
||||
30,
|
||||
DateTimeKind.Utc)) ||
|
||||
((NSDate)d.ObjectForKey("date")).Date.Equals(new DateTime(2011,
|
||||
11,
|
||||
28,
|
||||
9,
|
||||
21,
|
||||
30,
|
||||
DateTimeKind.Utc)));
|
||||
|
||||
Assert.True(ArrayEquals(((NSData)d.ObjectForKey("data")).Bytes,
|
||||
[
|
||||
0x00, 0x00, 0x00, 0x04, 0x10, 0x41, 0x08, 0x20, 0x82
|
||||
]));
|
||||
|
||||
var a = (NSArray)d.ObjectForKey("array");
|
||||
Assert.True(a.Count == 4);
|
||||
Assert.True(a[0].Equals(new NSNumber(true)));
|
||||
Assert.True(a[1].Equals(new NSNumber(false)));
|
||||
Assert.True(a[2].Equals(new NSNumber(87)));
|
||||
Assert.True(a[3].Equals(new NSNumber(3.14159)));
|
||||
|
||||
// read/write it, make sure we get the same thing
|
||||
PropertyListParser.SaveAsXml(x, new FileInfo("test-files/out-testXml.plist"));
|
||||
NSObject y = PropertyListParser.Parse(new FileInfo("test-files/out-testXml.plist"));
|
||||
Assert.True(x.Equals(y));
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,18 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class PropertyListParserTests
|
||||
{
|
||||
public class PropertyListParserTests
|
||||
static void ParseEmptyStreamTestDelegate()
|
||||
{
|
||||
static void ParseEmptyStreamTestDelegate()
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
PropertyListParser.Parse(stream);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ParseEmptyStreamTest() =>
|
||||
Assert.Throws<PropertyListFormatException>(ParseEmptyStreamTestDelegate);
|
||||
PropertyListParser.Parse(stream);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void ParseEmptyStreamTest() =>
|
||||
Assert.Throws<PropertyListFormatException>(ParseEmptyStreamTestDelegate);
|
||||
}
|
||||
@@ -2,131 +2,140 @@
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public class UIDTests
|
||||
{
|
||||
public class UIDTests
|
||||
[Theory]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
[Theory, InlineData(new byte[]
|
||||
{
|
||||
0xAB
|
||||
}), InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD
|
||||
}), InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0xFE
|
||||
}), InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0xFE, 0xFE, 0xEF, 0xCD, 0xAB
|
||||
})]
|
||||
public void UidFromArrayTest(byte[] array)
|
||||
{
|
||||
var uid = new UID(array);
|
||||
Assert.Equal(array, uid.Bytes);
|
||||
}
|
||||
0xAB
|
||||
})]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD
|
||||
})]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0xFE
|
||||
})]
|
||||
[InlineData(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0xFE, 0xFE, 0xEF, 0xCD, 0xAB
|
||||
})]
|
||||
public void UidFromArrayTest(byte[] array)
|
||||
{
|
||||
var uid = new UID(array);
|
||||
Assert.Equal(array, uid.Bytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BinaryRoundTripTest()
|
||||
{
|
||||
var original = new UID(0xabcd);
|
||||
[Fact]
|
||||
public void BinaryRoundTripTest()
|
||||
{
|
||||
var original = new UID(0xabcd);
|
||||
|
||||
using var stream = new MemoryStream();
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
BinaryPropertyListWriter.Write(stream, original);
|
||||
stream.Position = 0;
|
||||
var roundtrip = BinaryPropertyListParser.Parse(stream) as UID;
|
||||
Assert.Equal(original.Bytes, roundtrip.Bytes);
|
||||
}
|
||||
BinaryPropertyListWriter.Write(stream, original);
|
||||
stream.Position = 0;
|
||||
var roundtrip = BinaryPropertyListParser.Parse(stream) as UID;
|
||||
Assert.Equal(original.Bytes, roundtrip.Bytes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ByteUidTest()
|
||||
{
|
||||
var uid = new UID(0xAB);
|
||||
[Fact]
|
||||
public void ByteUidTest()
|
||||
{
|
||||
var uid = new UID(0xAB);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABu, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABu, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IntUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF00);
|
||||
[Fact]
|
||||
public void IntUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF00);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABCDEF00, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABCDEF00, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LongUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF0000EFCDAB);
|
||||
[Fact]
|
||||
public void LongUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF0000EFCDAB);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABCDEF0000EFCDAB, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABCDEF0000EFCDAB, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UIntUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF00u);
|
||||
[Fact]
|
||||
public void UIntUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF00u);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABCDEF00u, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABCDEF00u, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ULongUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF0000EFCDABu);
|
||||
[Fact]
|
||||
public void ULongUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDEF0000EFCDABu);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABCDEF0000EFCDABu, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABCDEF0000EFCDABu, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UShortUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDu);
|
||||
[Fact]
|
||||
public void UShortUidTest()
|
||||
{
|
||||
var uid = new UID(0xABCDu);
|
||||
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD
|
||||
}, uid.Bytes);
|
||||
Assert.Equal(new byte[]
|
||||
{
|
||||
0xAB, 0xCD
|
||||
},
|
||||
uid.Bytes);
|
||||
|
||||
Assert.Equal(0xABCDu, uid.ToUInt64());
|
||||
}
|
||||
Assert.Equal(0xABCDu, uid.ToUInt64());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void XmlRoundTripTest()
|
||||
{
|
||||
var original = new UID(0xabcd);
|
||||
[Fact]
|
||||
public void XmlRoundTripTest()
|
||||
{
|
||||
var original = new UID(0xabcd);
|
||||
|
||||
string plist = original.ToXmlPropertyList();
|
||||
string plist = original.ToXmlPropertyList();
|
||||
|
||||
// UIDs don't exist in XML property lists, but they are represented as dictionaries
|
||||
// for compability purposes
|
||||
var roundtrip = XmlPropertyListParser.ParseString(plist) as UID;
|
||||
Assert.Equal(0xabcdUL, roundtrip.ToUInt64());
|
||||
}
|
||||
// UIDs don't exist in XML property lists, but they are represented as dictionaries
|
||||
// for compability purposes
|
||||
var roundtrip = XmlPropertyListParser.ParseString(plist) as UID;
|
||||
Assert.Equal(0xabcdUL, roundtrip.ToUInt64());
|
||||
}
|
||||
}
|
||||
@@ -52,19 +52,19 @@ public class UseCultureAttribute : BeforeAfterTestAttribute
|
||||
/// <param name="methodUnderTest">The method under test</param>
|
||||
public override void Before(MethodInfo methodUnderTest)
|
||||
{
|
||||
#if NETCORE
|
||||
#if NETCORE
|
||||
originalCulture = CultureInfo.CurrentCulture;
|
||||
originalUICulture = CultureInfo.CurrentUICulture;
|
||||
|
||||
CultureInfo.CurrentCulture = Culture;
|
||||
CultureInfo.CurrentUICulture = Culture;
|
||||
#else
|
||||
#else
|
||||
originalCulture = Thread.CurrentThread.CurrentCulture;
|
||||
originalUICulture = Thread.CurrentThread.CurrentUICulture;
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = Culture;
|
||||
Thread.CurrentThread.CurrentUICulture = UICulture;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,12 +74,12 @@ public class UseCultureAttribute : BeforeAfterTestAttribute
|
||||
/// <param name="methodUnderTest">The method under test</param>
|
||||
public override void After(MethodInfo methodUnderTest)
|
||||
{
|
||||
#if NETCORE
|
||||
#if NETCORE
|
||||
CultureInfo.CurrentCulture = originalCulture;
|
||||
CultureInfo.CurrentUICulture = originalUICulture;
|
||||
#else
|
||||
#else
|
||||
Thread.CurrentThread.CurrentCulture = originalCulture;
|
||||
Thread.CurrentThread.CurrentUICulture = originalUICulture;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -9,93 +9,91 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="Stream" /> which writes its output to a <see cref="Stream" /> and validates that the data which
|
||||
/// is being written to the output stream matches the data in a reference stream.
|
||||
/// </summary>
|
||||
internal class ValidatingStream : Stream
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="Stream" /> which writes its output to a <see cref="Stream" /> and validates that the data which
|
||||
/// is being written to the output stream matches the data in a reference stream.
|
||||
/// </summary>
|
||||
internal class ValidatingStream : Stream
|
||||
readonly Stream expectedOutput;
|
||||
readonly Stream output;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="ValidatingCompositeStream" /> class.</summary>
|
||||
/// <param name="output">The <see cref="Stream" /> to which to write data.</param>
|
||||
/// <param name="expectedOutput">The reference stream for <paramref name="output" />.</param>
|
||||
public ValidatingStream(Stream output, Stream expectedOutput)
|
||||
{
|
||||
readonly Stream expectedOutput;
|
||||
readonly Stream output;
|
||||
this.output = output ?? throw new ArgumentNullException(nameof(output));
|
||||
this.expectedOutput = expectedOutput ?? throw new ArgumentNullException(nameof(expectedOutput));
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="ValidatingCompositeStream" /> class.</summary>
|
||||
/// <param name="output">The <see cref="Stream" /> to which to write data.</param>
|
||||
/// <param name="expectedOutput">The reference stream for <paramref name="output" />.</param>
|
||||
public ValidatingStream(Stream output, Stream expectedOutput)
|
||||
{
|
||||
this.output = output ?? throw new ArgumentNullException(nameof(output));
|
||||
this.expectedOutput = expectedOutput ?? throw new ArgumentNullException(nameof(expectedOutput));
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override bool CanRead => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanRead => false;
|
||||
/// <inheritdoc />
|
||||
public override bool CanSeek => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanSeek => false;
|
||||
/// <inheritdoc />
|
||||
public override bool CanWrite => true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool CanWrite => true;
|
||||
/// <inheritdoc />
|
||||
public override long Length => output.Length;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Length => output.Length;
|
||||
/// <inheritdoc />
|
||||
public override long Position
|
||||
{
|
||||
get => output.Position;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Position
|
||||
{
|
||||
get => output.Position;
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override void Flush() => output.Flush();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Flush() => output.Flush();
|
||||
/// <inheritdoc />
|
||||
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||
/// <inheritdoc />
|
||||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
|
||||
throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task<int>
|
||||
ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
|
||||
throw new NotSupportedException();
|
||||
/// <inheritdoc />
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException();
|
||||
/// <inheritdoc />
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetLength(long value) => throw new NotImplementedException();
|
||||
/// <inheritdoc />
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
byte[] expected = new byte[buffer.Length];
|
||||
expectedOutput.Read(expected, offset, count);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
byte[] expected = new byte[buffer.Length];
|
||||
expectedOutput.Read(expected, offset, count);
|
||||
byte[] bufferChunk = buffer.Skip(offset).Take(count).ToArray();
|
||||
byte[] expectedChunk = expected.Skip(offset).Take(count).ToArray();
|
||||
|
||||
byte[] bufferChunk = buffer.Skip(offset).Take(count).ToArray();
|
||||
byte[] expectedChunk = expected.Skip(offset).Take(count).ToArray();
|
||||
// Make sure the data being writen matches the data which was written to the expected stream.
|
||||
// This will detect any errors as the invalid data is being written out - as opposed to post-
|
||||
// test binary validation.
|
||||
Assert.Equal(expectedChunk, bufferChunk);
|
||||
output.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
// Make sure the data being writen matches the data which was written to the expected stream.
|
||||
// This will detect any errors as the invalid data is being written out - as opposed to post-
|
||||
// test binary validation.
|
||||
Assert.Equal(expectedChunk, bufferChunk);
|
||||
output.Write(buffer, offset, count);
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
byte[] expected = new byte[buffer.Length];
|
||||
await expectedOutput.ReadAsync(expected, offset, count, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
byte[] expected = new byte[buffer.Length];
|
||||
await expectedOutput.ReadAsync(expected, offset, count, cancellationToken).ConfigureAwait(false);
|
||||
byte[] bufferChunk = buffer.Skip(offset).Take(count).ToArray();
|
||||
byte[] expectedChunk = expected.Skip(offset).Take(count).ToArray();
|
||||
|
||||
byte[] bufferChunk = buffer.Skip(offset).Take(count).ToArray();
|
||||
byte[] expectedChunk = expected.Skip(offset).Take(count).ToArray();
|
||||
// Make sure the data being writen matches the data which was written to the expected stream.
|
||||
// This will detect any errors as the invalid data is being written out - as opposed to post-
|
||||
// test binary validation.
|
||||
Assert.Equal(expectedChunk, bufferChunk);
|
||||
|
||||
// Make sure the data being writen matches the data which was written to the expected stream.
|
||||
// This will detect any errors as the invalid data is being written out - as opposed to post-
|
||||
// test binary validation.
|
||||
Assert.Equal(expectedChunk, bufferChunk);
|
||||
|
||||
await output.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
await output.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -3,123 +3,122 @@ using System.Linq;
|
||||
using Claunia.PropertyList;
|
||||
using Xunit;
|
||||
|
||||
namespace plistcil.test
|
||||
namespace plistcil.test;
|
||||
|
||||
public static class ValuePreprocessorTests
|
||||
{
|
||||
public static class ValuePreprocessorTests
|
||||
// lock tests to make sure temporarily added / replaced preprocessors don't interfere with the other tests in this suite
|
||||
private static readonly object _testLock = new();
|
||||
|
||||
[Fact]
|
||||
public static void TestPassiveDefaultPreprocessorsRegistered()
|
||||
{
|
||||
// lock tests to make sure temporarily added / replaced preprocessors don't interfere with the other tests in this suite
|
||||
private static readonly object _testLock = new();
|
||||
byte[] testByteArray = [0x1, 0x2, 0x4, 0x8];
|
||||
|
||||
[Fact]
|
||||
public static void TestPassiveDefaultPreprocessorsRegistered()
|
||||
Assert.Equal(true, ValuePreprocessor.Preprocess(true, ValuePreprocessor.Type.BOOL));
|
||||
Assert.Equal(false, ValuePreprocessor.Preprocess(false, ValuePreprocessor.Type.BOOL));
|
||||
Assert.Equal("true", ValuePreprocessor.Preprocess("true", ValuePreprocessor.Type.BOOL));
|
||||
|
||||
Assert.Equal("42", ValuePreprocessor.Preprocess("42", ValuePreprocessor.Type.INTEGER));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.INTEGER));
|
||||
|
||||
Assert.Equal("3.14159", ValuePreprocessor.Preprocess("3.14159", ValuePreprocessor.Type.FLOATING_POINT));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.FLOATING_POINT));
|
||||
|
||||
Assert.Equal("2.71828", ValuePreprocessor.Preprocess("2.71828", ValuePreprocessor.Type.UNDEFINED_NUMBER));
|
||||
|
||||
Assert.Equal("TestString", ValuePreprocessor.Preprocess("TestString", ValuePreprocessor.Type.STRING));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.STRING));
|
||||
|
||||
Assert.Equal("TestData", ValuePreprocessor.Preprocess("TestData", ValuePreprocessor.Type.DATA));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.DATA));
|
||||
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.DATE));
|
||||
Assert.Equal("01.02.1903", ValuePreprocessor.Preprocess("01.02.1903", ValuePreprocessor.Type.DATE));
|
||||
Assert.Equal(23.0, ValuePreprocessor.Preprocess(23.0, ValuePreprocessor.Type.DATE));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisterPreprocessor()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
byte[] testByteArray = [0x1, 0x2, 0x4, 0x8];
|
||||
Func<string, string> examplePreprocessor = value => new string(value.Reverse().ToArray());
|
||||
string testString = "TestString";
|
||||
string expected = "gnirtStseT";
|
||||
|
||||
Assert.Equal(true, ValuePreprocessor.Preprocess(true, ValuePreprocessor.Type.BOOL));
|
||||
Assert.Equal(false, ValuePreprocessor.Preprocess(false, ValuePreprocessor.Type.BOOL));
|
||||
Assert.Equal("true", ValuePreprocessor.Preprocess("true", ValuePreprocessor.Type.BOOL));
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
Assert.Equal("42", ValuePreprocessor.Preprocess("42", ValuePreprocessor.Type.INTEGER));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.INTEGER));
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
string actual = ValuePreprocessor.Preprocess(testString, testType);
|
||||
|
||||
Assert.Equal("3.14159", ValuePreprocessor.Preprocess("3.14159", ValuePreprocessor.Type.FLOATING_POINT));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.FLOATING_POINT));
|
||||
Assert.Equal(actual, expected);
|
||||
|
||||
Assert.Equal("2.71828", ValuePreprocessor.Preprocess("2.71828", ValuePreprocessor.Type.UNDEFINED_NUMBER));
|
||||
|
||||
Assert.Equal("TestString", ValuePreprocessor.Preprocess("TestString", ValuePreprocessor.Type.STRING));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.STRING));
|
||||
|
||||
Assert.Equal("TestData", ValuePreprocessor.Preprocess("TestData", ValuePreprocessor.Type.DATA));
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.DATA));
|
||||
|
||||
Assert.Equal(testByteArray, ValuePreprocessor.Preprocess(testByteArray, ValuePreprocessor.Type.DATE));
|
||||
Assert.Equal("01.02.1903", ValuePreprocessor.Preprocess("01.02.1903", ValuePreprocessor.Type.DATE));
|
||||
Assert.Equal(23.0, ValuePreprocessor.Preprocess(23.0, ValuePreprocessor.Type.DATE));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisterPreprocessor()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
Func<string, string> examplePreprocessor = value => new string(value.Reverse().ToArray());
|
||||
string testString = "TestString";
|
||||
string expected = "gnirtStseT";
|
||||
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
string actual = ValuePreprocessor.Preprocess(testString, testType);
|
||||
|
||||
Assert.Equal(actual, expected);
|
||||
|
||||
ValuePreprocessor.Unset<string>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisteredPreprocessorSelection1()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
Func<short, short> examplePreprocessor = value => (short)(value - 1);
|
||||
short testShort = 42;
|
||||
string testString = "TestString";
|
||||
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
// correct value type, differing data type
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
ValuePreprocessor.Set(ValuePreprocessor.GetDefault<string>(), testType);
|
||||
|
||||
string actual1 = ValuePreprocessor.Preprocess(testString, testType);
|
||||
short actual2 = ValuePreprocessor.Preprocess(testShort, testType);
|
||||
|
||||
// assert unchanged, since the selected preprocessor != tested preprocessor
|
||||
Assert.Equal(actual1, testString);
|
||||
Assert.NotEqual(actual2, testShort);
|
||||
|
||||
ValuePreprocessor.Remove<short>(testType);
|
||||
ValuePreprocessor.Remove<string>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisteredPreprocessorSelection2()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
Func<string, string> examplePreprocessor = value => new string(value.Reverse().ToArray());
|
||||
byte[] testByteArray = [0x42,];
|
||||
string testString = "TestString";
|
||||
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
// correct value type, differing data type
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
ValuePreprocessor.Set(ValuePreprocessor.GetDefault<byte[]>(), testType);
|
||||
|
||||
string actual1 = ValuePreprocessor.Preprocess(testString, testType);
|
||||
byte[] actual2 = ValuePreprocessor.Preprocess(testByteArray, testType);
|
||||
|
||||
Assert.NotEqual(actual1, testString);
|
||||
|
||||
// assert unchanged, since the selected preprocessor != tested preprocessor
|
||||
Assert.Equal(actual2, testByteArray);
|
||||
|
||||
ValuePreprocessor.Unset<string>(testType);
|
||||
ValuePreprocessor.Remove<byte[]>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestUnregisteredPreprocessorThrows()
|
||||
{
|
||||
int[] testArray = [1, 2, 4, 8];
|
||||
|
||||
// there's no registered preprocessor for byte array arguments for STRING
|
||||
Assert.Throws<ArgumentException>(() => ValuePreprocessor.Preprocess(testArray, ValuePreprocessor.Type.STRING));
|
||||
ValuePreprocessor.Unset<string>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisteredPreprocessorSelection1()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
Func<short, short> examplePreprocessor = value => (short)(value - 1);
|
||||
short testShort = 42;
|
||||
string testString = "TestString";
|
||||
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
// correct value type, differing data type
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
ValuePreprocessor.Set(ValuePreprocessor.GetDefault<string>(), testType);
|
||||
|
||||
string actual1 = ValuePreprocessor.Preprocess(testString, testType);
|
||||
short actual2 = ValuePreprocessor.Preprocess(testShort, testType);
|
||||
|
||||
// assert unchanged, since the selected preprocessor != tested preprocessor
|
||||
Assert.Equal(actual1, testString);
|
||||
Assert.NotEqual(actual2, testShort);
|
||||
|
||||
ValuePreprocessor.Remove<short>(testType);
|
||||
ValuePreprocessor.Remove<string>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestRegisteredPreprocessorSelection2()
|
||||
{
|
||||
lock(_testLock)
|
||||
{
|
||||
Func<string, string> examplePreprocessor = value => new string(value.Reverse().ToArray());
|
||||
byte[] testByteArray = [0x42];
|
||||
string testString = "TestString";
|
||||
|
||||
var testType = (ValuePreprocessor.Type)42;
|
||||
|
||||
// correct value type, differing data type
|
||||
ValuePreprocessor.Set(examplePreprocessor, testType);
|
||||
ValuePreprocessor.Set(ValuePreprocessor.GetDefault<byte[]>(), testType);
|
||||
|
||||
string actual1 = ValuePreprocessor.Preprocess(testString, testType);
|
||||
byte[] actual2 = ValuePreprocessor.Preprocess(testByteArray, testType);
|
||||
|
||||
Assert.NotEqual(actual1, testString);
|
||||
|
||||
// assert unchanged, since the selected preprocessor != tested preprocessor
|
||||
Assert.Equal(actual2, testByteArray);
|
||||
|
||||
ValuePreprocessor.Unset<string>(testType);
|
||||
ValuePreprocessor.Remove<byte[]>(testType);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestUnregisteredPreprocessorThrows()
|
||||
{
|
||||
int[] testArray = [1, 2, 4, 8];
|
||||
|
||||
// there's no registered preprocessor for byte array arguments for STRING
|
||||
Assert.Throws<ArgumentException>(() => ValuePreprocessor.Preprocess(testArray, ValuePreprocessor.Type.STRING));
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
|
||||
<PackageReference Include="xunit" Version="2.9.3"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
@@ -14,7 +14,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\plist-cil\plist-cil.csproj" />
|
||||
<ProjectReference Include="..\plist-cil\plist-cil.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -111,7 +111,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
|
||||
@@ -1,80 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>PkgInfo</key>
|
||||
<data>
|
||||
n57qDP4tZfLD1rCS43W0B4LQjzE=
|
||||
</data>
|
||||
<key>icon.png</key>
|
||||
<data>
|
||||
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>PkgInfo</key>
|
||||
<data>
|
||||
n57qDP4tZfLD1rCS43W0B4LQjzE=
|
||||
</data>
|
||||
<key>icon.png</key>
|
||||
<data>
|
||||
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>.*</key>
|
||||
<true/>
|
||||
<key>Info.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>ResourceRules.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>100</real>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*</key>
|
||||
<true/>
|
||||
<key>Info.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>ResourceRules.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>100</real>
|
||||
</dict>
|
||||
<key>^(Frameworks|SharedFrameworks|Plugins|Plug-ins|XPCServices|Helpers|MacOS)/</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>0.0</real>
|
||||
</dict>
|
||||
<key>^[^/]+$</key>
|
||||
<dict>
|
||||
<key>top</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>0.0</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>PkgInfo</key>
|
||||
<data>
|
||||
n57qDP4tZfLD1rCS43W0B4LQjzE=
|
||||
</data>
|
||||
<key>icon.png</key>
|
||||
<data>
|
||||
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>PkgInfo</key>
|
||||
<data>
|
||||
n57qDP4tZfLD1rCS43W0B4LQjzE=
|
||||
</data>
|
||||
<key>icon.png</key>
|
||||
<data>
|
||||
EUOeOW/HpmiAZeEGzJm8j3hE6vo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>.*</key>
|
||||
<true/>
|
||||
<key>Info.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>ResourceRules.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>100</real>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*</key>
|
||||
<true/>
|
||||
<key>Info.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>ResourceRules.plist</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>100</real>
|
||||
</dict>
|
||||
<key>^(Frameworks|SharedFrameworks|Plugins|Plug-ins|XPCServices|Helpers|MacOS)/</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>0.0</real>
|
||||
</dict>
|
||||
<key>^[^/]+$</key>
|
||||
<dict>
|
||||
<key>top</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>0.0</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<data>
|
||||
MjAxMy0wMi0wMiAyMDoxNjo0MiBHTVQ6IGhhbmRsZV9tZXNzYWdlOiBBbmQgeW91IHdp
|
||||
bGwga25vdyBteSBuYW1lIGlzIHRoZSBMb3JkIHdoZW4gSSBsYXkgbXkgdmVuZ2VhbmNl
|
||||
IHVwb24gdGhlZS4=
|
||||
</data>
|
||||
<data>
|
||||
MjAxMy0wMi0wMiAyMDoxNjo0MiBHTVQ6IGhhbmRsZV9tZXNzYWdlOiBBbmQgeW91IHdp
|
||||
bGwga25vdyBteSBuYW1lIGlzIHRoZSBMb3JkIHdoZW4gSSBsYXkgbXkgdmVuZ2VhbmNl
|
||||
IHVwb24gdGhlZS4=
|
||||
</data>
|
||||
</plist>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>keyA</key>
|
||||
<data>
|
||||
MjAxMy0wMi0wMiAyMDoxNjo0MiBHTVQ6IGhhbmRsZV9tZXNzYWdlOiBBbmQgeW91IHdp
|
||||
bGwga25vdyBteSBuYW1lIGlzIHRoZSBMb3JkIHdoZW4gSSBsYXkgbXkgdmVuZ2VhbmNl
|
||||
IHVwb24gdGhlZS4=
|
||||
</data>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>keyA</key>
|
||||
<data>
|
||||
MjAxMy0wMi0wMiAyMDoxNjo0MiBHTVQ6IGhhbmRsZV9tZXNzYWdlOiBBbmQgeW91IHdp
|
||||
bGwga25vdyBteSBuYW1lIGlzIHRoZSBMb3JkIHdoZW4gSSBsYXkgbXkgdmVuZ2VhbmNl
|
||||
IHVwb24gdGhlZS4=
|
||||
</data>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<real>1360155352.748765</real>
|
||||
<real>1360155352.748765</real>
|
||||
</plist>
|
||||
|
||||
Reference in New Issue
Block a user