From 6597e9a9f89395a813073f08e6d27d71cee38d8c Mon Sep 17 00:00:00 2001 From: Kory Prince Date: Sun, 24 Nov 2024 20:41:42 -0600 Subject: [PATCH] resolve failing test cases --- encode_test.go | 110 ++++++++++++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 43 deletions(-) diff --git a/encode_test.go b/encode_test.go index a0d1246..5ec2107 100644 --- a/encode_test.go +++ b/encode_test.go @@ -81,33 +81,33 @@ var indentRef = ` - Boolean - - BooleanList - - - - - CFBundleInfoDictionaryVersion - 6.0 - Strings - - a - b - - band-size - 8388608 - bundle-backingstore-version - 1 - diskimage-bundle-type - com.apple.diskimage.sparsebundle - size - 4398046511104 - useless - - unused-string - unused - + Boolean + + BooleanList + + + + + CFBundleInfoDictionaryVersion + 6.0 + Strings + + a + b + + band-size + 8388608 + bundle-backingstore-version + 1 + diskimage-bundle-type + com.apple.diskimage.sparsebundle + size + 4398046511104 + useless + + unused-string + unused + ` @@ -115,16 +115,28 @@ var indentRef = ` var indentRefOmit = ` - - CFBundleInfoDictionaryVersion - 6.0 - bundle-backingstore-version - 1 - diskimage-bundle-type - com.apple.diskimage.sparsebundle - size - 4398046511104 - + + Boolean + + BooleanList + + + + + CFBundleInfoDictionaryVersion + 6.0 + Strings + + a + b + + bundle-backingstore-version + 1 + diskimage-bundle-type + com.apple.diskimage.sparsebundle + size + 4398046511104 + ` @@ -193,11 +205,11 @@ func TestNewLineString(t *testing.T) { var ok = ` - - Content - foo + + Content + foo bar - + ` out := string(b) @@ -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) } @@ -251,6 +263,9 @@ 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, @@ -258,6 +273,9 @@ func TestOmitNotEmpty(t *testing.T) { 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 { @@ -265,7 +283,7 @@ func TestOmitNotEmpty(t *testing.T) { } 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) } } @@ -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 {