Skip to content

Commit

Permalink
resolve failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
korylprince committed Nov 25, 2024
1 parent 4744ad4 commit 6597e9a
Showing 1 changed file with 67 additions and 43 deletions.
110 changes: 67 additions & 43 deletions encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,50 +81,62 @@ var indentRef = `<?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>Boolean</key>
<true/>
<key>BooleanList</key>
<array>
<true/>
<false/>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>Strings</key>
<array>
<string>a</string>
<string>b</string>
</array>
<key>band-size</key>
<integer>8388608</integer>
<key>bundle-backingstore-version</key>
<integer>1</integer>
<key>diskimage-bundle-type</key>
<string>com.apple.diskimage.sparsebundle</string>
<key>size</key>
<integer>4398046511104</integer>
<key>useless</key>
<dict>
<key>unused-string</key>
<string>unused</string>
</dict>
<key>Boolean</key>
<true/>
<key>BooleanList</key>
<array>
<true/>
<false/>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>Strings</key>
<array>
<string>a</string>
<string>b</string>
</array>
<key>band-size</key>
<integer>8388608</integer>
<key>bundle-backingstore-version</key>
<integer>1</integer>
<key>diskimage-bundle-type</key>
<string>com.apple.diskimage.sparsebundle</string>
<key>size</key>
<integer>4398046511104</integer>
<key>useless</key>
<dict>
<key>unused-string</key>
<string>unused</string>
</dict>
</dict>
</plist>
`

var indentRefOmit = `<?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>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>bundle-backingstore-version</key>
<integer>1</integer>
<key>diskimage-bundle-type</key>
<string>com.apple.diskimage.sparsebundle</string>
<key>size</key>
<integer>4398046511104</integer>
</dict>
<dict>
<key>Boolean</key>
<true/>
<key>BooleanList</key>
<array>
<true/>
<false/>
</array>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>Strings</key>
<array>
<string>a</string>
<string>b</string>
</array>
<key>bundle-backingstore-version</key>
<integer>1</integer>
<key>diskimage-bundle-type</key>
<string>com.apple.diskimage.sparsebundle</string>
<key>size</key>
<integer>4398046511104</integer>
</dict>
</plist>
`

Expand Down Expand Up @@ -193,11 +205,11 @@ func TestNewLineString(t *testing.T) {
var ok = `<?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>Content</key>
<string>foo
<dict>
<key>Content</key>
<string>foo
bar</string>
</dict>
</dict>
</plist>
`
out := string(b)
Expand Down Expand Up @@ -230,7 +242,7 @@ func TestIndent(t *testing.T) {
BooleanList: []bool{true, false},
Strings: []string{"a", "b"},
}
b, err := MarshalIndent(sparseBundleHeader, " ")
b, err := MarshalIndent(sparseBundleHeader, " ")
if err != nil {
t.Fatal(err)
}
Expand All @@ -251,21 +263,27 @@ func TestOmitNotEmpty(t *testing.T) {
DiskImageBundleType string `plist:"diskimage-bundle-type"`
Size uint64 `plist:"size"`
Unused testStruct `plist:"useless"`
Boolean bool
BooleanList []bool
Strings []string
}{
InfoDictionaryVersion: "6.0",
BandSize: 8388608,
Size: 4 * 1048576 * 1024 * 1024,
DiskImageBundleType: "com.apple.diskimage.sparsebundle",
BackingStoreVersion: 1,
Unused: testStruct{UnusedString: "unused"},
Boolean: true,
BooleanList: []bool{true, false},
Strings: []string{"a", "b"},
}
b, err := MarshalIndent(sparseBundleHeader, " ")
if err != nil {
t.Fatal(err)
}
out := string(b)
if out != indentRef {
t.Errorf("MarshalIndent(%v) = \n%v, \nwant\n %v", sparseBundleHeader, out, indentRef)
t.Errorf("MarshalIndent(%v) = \n%v, \nwant\n %v", sparseBundleHeader, out, indentRefOmit)
}
}

Expand All @@ -278,11 +296,17 @@ func TestOmitIsEmpty(t *testing.T) {
DiskImageBundleType string `plist:"diskimage-bundle-type"`
Size uint64 `plist:"size"`
Unused testStruct `plist:"useless,omitempty"`
Boolean bool
BooleanList []bool
Strings []string
}{
InfoDictionaryVersion: "6.0",
Size: 4 * 1048576 * 1024 * 1024,
DiskImageBundleType: "com.apple.diskimage.sparsebundle",
BackingStoreVersion: 1,
Boolean: true,
BooleanList: []bool{true, false},
Strings: []string{"a", "b"},
}
b, err := MarshalIndent(sparseBundleHeader, " ")
if err != nil {
Expand Down

0 comments on commit 6597e9a

Please sign in to comment.