mirror of
https://github.com/claunia/plist-cil.git
synced 2025-12-16 19:14:26 +00:00
Fix indentation, add unit test
This commit is contained in:
@@ -159,7 +159,8 @@ namespace plistcil.test
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes sure that binary data is line-wrapped correctly when being serialized.
|
||||
/// 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()
|
||||
@@ -168,7 +169,21 @@ namespace plistcil.test
|
||||
var value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinary.plist"));
|
||||
var actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, false, 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()
|
||||
{
|
||||
var expected = File.ReadAllText(@"test-files/RoundtripBinaryIndentation.plist");
|
||||
var value = XmlPropertyListParser.Parse(new FileInfo(@"test-files/RoundtripBinaryIndentation.plist"));
|
||||
var actual = value.ToXmlPropertyList();
|
||||
|
||||
Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,4 +112,10 @@
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="test-files\RoundtripBinaryIndentation.plist">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
12
plist-cil.test/test-files/RoundtripBinaryIndentation.plist
Normal file
12
plist-cil.test/test-files/RoundtripBinaryIndentation.plist
Normal file
@@ -0,0 +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">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>keyA</key>
|
||||
<data>
|
||||
MjAxMy0wMi0wMiAyMDoxNjo0MiBHTVQ6IGhhbmRsZV9tZXNzYWdlOiBBbmQgeW91IHdp
|
||||
bGwga25vdyBteSBuYW1lIGlzIHRoZSBMb3JkIHdoZW4gSSBsYXkgbXkgdmVuZ2VhbmNl
|
||||
IHVwb24gdGhlZS4=
|
||||
</data>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -159,10 +159,9 @@ namespace Claunia.PropertyList
|
||||
string base64 = GetBase64EncodedData();
|
||||
foreach (string line in base64.Split('\n'))
|
||||
{
|
||||
Indent(xml, level);
|
||||
|
||||
for (int offset = 0; offset < base64.Length; offset += DataLineLength)
|
||||
{
|
||||
Indent(xml, level);
|
||||
xml.Append(line.Substring(offset, Math.Min(DataLineLength, line.Length - offset)));
|
||||
xml.Append(NSObject.NEWLINE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user