| 1 |
package plist |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
"math" |
| 6 |
"reflect" |
| 7 |
"time" |
| 8 |
) |
| 9 |
|
| 10 |
type TestData struct { |
| 11 |
Name string |
| 12 |
Value interface{} |
| 13 |
DecodeValue interface{} |
| 14 |
Documents map[int][]byte |
| 15 |
SkipDecode map[int]bool |
| 16 |
SkipEncode map[int]bool |
| 17 |
} |
| 18 |
|
| 19 |
type SparseBundleHeader struct { |
| 20 |
InfoDictionaryVersion string `plist:"CFBundleInfoDictionaryVersion"` |
| 21 |
BandSize uint64 `plist:"band-size"` |
| 22 |
BackingStoreVersion int `plist:"bundle-backingstore-version"` |
| 23 |
DiskImageBundleType string `plist:"diskimage-bundle-type"` |
| 24 |
Size uint64 `plist:"size"` |
| 25 |
} |
| 26 |
|
| 27 |
type EmbedA struct { |
| 28 |
EmbedC |
| 29 |
EmbedB EmbedB |
| 30 |
FieldA string |
| 31 |
} |
| 32 |
|
| 33 |
type EmbedB struct { |
| 34 |
FieldB string |
| 35 |
*EmbedC |
| 36 |
} |
| 37 |
|
| 38 |
type EmbedC struct { |
| 39 |
FieldA1 string `plist:"FieldA"` |
| 40 |
FieldA2 string |
| 41 |
FieldB string |
| 42 |
FieldC string |
| 43 |
} |
| 44 |
|
| 45 |
type TextMarshalingBool struct { |
| 46 |
b bool |
| 47 |
} |
| 48 |
|
| 49 |
func (b TextMarshalingBool) MarshalText() ([]byte, error) { |
| 50 |
if b.b { |
| 51 |
return []byte("truthful"), nil |
| 52 |
} |
| 53 |
return []byte("non-factual"), nil |
| 54 |
} |
| 55 |
|
| 56 |
func (b *TextMarshalingBool) UnmarshalText(text []byte) error { |
| 57 |
if string(text) == "truthful" { |
| 58 |
b.b = true |
| 59 |
} |
| 60 |
return nil |
| 61 |
} |
| 62 |
|
| 63 |
type TextMarshalingBoolViaPointer struct { |
| 64 |
b bool |
| 65 |
} |
| 66 |
|
| 67 |
func (b *TextMarshalingBoolViaPointer) MarshalText() ([]byte, error) { |
| 68 |
if b.b { |
| 69 |
return []byte("plausible"), nil |
| 70 |
} |
| 71 |
return []byte("unimaginable"), nil |
| 72 |
} |
| 73 |
|
| 74 |
func (b *TextMarshalingBoolViaPointer) UnmarshalText(text []byte) error { |
| 75 |
if string(text) == "plausible" { |
| 76 |
b.b = true |
| 77 |
} |
| 78 |
return nil |
| 79 |
} |
| 80 |
|
| 81 |
type ArrayThatSerializesAsOneObject struct { |
| 82 |
values []uint64 |
| 83 |
} |
| 84 |
|
| 85 |
func (f ArrayThatSerializesAsOneObject) MarshalPlist() (interface{}, error) { |
| 86 |
if len(f.values) == 1 { |
| 87 |
return f.values[0], nil |
| 88 |
} |
| 89 |
return f.values, nil |
| 90 |
} |
| 91 |
|
| 92 |
func (f *ArrayThatSerializesAsOneObject) UnmarshalPlist(unmarshal func(interface{}) error) error { |
| 93 |
var ui uint64 |
| 94 |
if err := unmarshal(&ui); err == nil { |
| 95 |
f.values = []uint64{ui} |
| 96 |
return nil |
| 97 |
} |
| 98 |
|
| 99 |
return unmarshal(&f.values) |
| 100 |
} |
| 101 |
|
| 102 |
type PlistMarshalingBoolByPointer struct { |
| 103 |
b bool |
| 104 |
} |
| 105 |
|
| 106 |
func (b *PlistMarshalingBoolByPointer) MarshalPlist() (interface{}, error) { |
| 107 |
if b.b { |
| 108 |
return int64(-1), nil |
| 109 |
} |
| 110 |
return int64(-2), nil |
| 111 |
} |
| 112 |
|
| 113 |
func (b *PlistMarshalingBoolByPointer) UnmarshalPlist(unmarshal func(interface{}) error) error { |
| 114 |
var val int64 |
| 115 |
err := unmarshal(&val) |
| 116 |
if err != nil { |
| 117 |
return err |
| 118 |
} |
| 119 |
|
| 120 |
b.b = val == -1 |
| 121 |
return nil |
| 122 |
} |
| 123 |
|
| 124 |
type BothMarshaler struct{} |
| 125 |
|
| 126 |
func (b *BothMarshaler) MarshalPlist() (interface{}, error) { |
| 127 |
return map[string]string{"a": "b"}, nil |
| 128 |
} |
| 129 |
|
| 130 |
func (b *BothMarshaler) MarshalText() ([]byte, error) { |
| 131 |
return []byte("shouldn't see this"), nil |
| 132 |
} |
| 133 |
|
| 134 |
type BothUnmarshaler struct { |
| 135 |
Blah int64 `plist:"blah,omitempty"` |
| 136 |
} |
| 137 |
|
| 138 |
func (b *BothUnmarshaler) UnmarshalPlist(unmarshal func(interface{}) error) error { |
| 139 |
|
| 140 |
return nil |
| 141 |
} |
| 142 |
|
| 143 |
func (b *BothUnmarshaler) UnmarshalText(text []byte) error { |
| 144 |
return errors.New("shouldn't hit this") |
| 145 |
} |
| 146 |
|
| 147 |
var xmlPreamble = `<?xml version="1.0" encoding="UTF-8"?> |
| 148 |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 149 |
` |
| 150 |
|
| 151 |
var tests = []TestData{ |
| 152 |
{ |
| 153 |
Name: "String", |
| 154 |
Value: "Hello", |
| 155 |
Documents: map[int][]byte{ |
| 156 |
OpenStepFormat: []byte(`Hello`), |
| 157 |
GNUStepFormat: []byte(`Hello`), |
| 158 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><string>Hello</string></plist>`), |
| 159 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 85, 72, 101, 108, 108, 111, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14}, |
| 160 |
}, |
| 161 |
}, |
| 162 |
{ |
| 163 |
Name: "String containing apostrophe", |
| 164 |
Value: "'", |
| 165 |
Documents: map[int][]byte{ |
| 166 |
OpenStepFormat: []byte(`"'"`), |
| 167 |
GNUStepFormat: []byte(`"'"`), |
| 168 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><string>'</string></plist>`), |
| 169 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 81, 39, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10}, |
| 170 |
}, |
| 171 |
}, |
| 172 |
{ |
| 173 |
Name: "Basic Structure", |
| 174 |
Value: struct { |
| 175 |
Name string |
| 176 |
}{ |
| 177 |
Name: "Dustin", |
| 178 |
}, |
| 179 |
Documents: map[int][]byte{ |
| 180 |
OpenStepFormat: []byte(`{Name=Dustin;}`), |
| 181 |
GNUStepFormat: []byte(`{Name=Dustin;}`), |
| 182 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>Name</key><string>Dustin</string></dict></plist>`), |
| 183 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 209, 1, 2, 84, 78, 97, 109, 101, 86, 68, 117, 115, 116, 105, 110, 8, 11, 16, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23}, |
| 184 |
}, |
| 185 |
}, |
| 186 |
{ |
| 187 |
Name: "Basic Structure with non-exported fields", |
| 188 |
Value: struct { |
| 189 |
Name string |
| 190 |
age int |
| 191 |
}{ |
| 192 |
Name: "Dustin", |
| 193 |
age: 24, |
| 194 |
}, |
| 195 |
DecodeValue: struct { |
| 196 |
Name string |
| 197 |
age int |
| 198 |
}{ |
| 199 |
Name: "Dustin", |
| 200 |
}, |
| 201 |
Documents: map[int][]byte{ |
| 202 |
OpenStepFormat: []byte(`{Name=Dustin;}`), |
| 203 |
GNUStepFormat: []byte(`{Name=Dustin;}`), |
| 204 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>Name</key><string>Dustin</string></dict></plist>`), |
| 205 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 209, 1, 2, 84, 78, 97, 109, 101, 86, 68, 117, 115, 116, 105, 110, 8, 11, 16, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23}, |
| 206 |
}, |
| 207 |
}, |
| 208 |
{ |
| 209 |
Name: "Basic Structure with omitted fields", |
| 210 |
Value: struct { |
| 211 |
Name string |
| 212 |
Age int `plist:"-"` |
| 213 |
}{ |
| 214 |
Name: "Dustin", |
| 215 |
Age: 24, |
| 216 |
}, |
| 217 |
DecodeValue: struct { |
| 218 |
Name string |
| 219 |
Age int `plist:"-"` |
| 220 |
}{ |
| 221 |
Name: "Dustin", |
| 222 |
}, |
| 223 |
Documents: map[int][]byte{ |
| 224 |
OpenStepFormat: []byte(`{Name=Dustin;}`), |
| 225 |
GNUStepFormat: []byte(`{Name=Dustin;}`), |
| 226 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>Name</key><string>Dustin</string></dict></plist>`), |
| 227 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 209, 1, 2, 84, 78, 97, 109, 101, 86, 68, 117, 115, 116, 105, 110, 8, 11, 16, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23}, |
| 228 |
}, |
| 229 |
}, |
| 230 |
{ |
| 231 |
Name: "Basic Structure with empty omitempty fields", |
| 232 |
Value: struct { |
| 233 |
Name string |
| 234 |
Age int `plist:"age,omitempty"` |
| 235 |
Slice []int `plist:",omitempty"` |
| 236 |
Bool bool `plist:",omitempty"` |
| 237 |
Uint uint `plist:",omitempty"` |
| 238 |
Float32 float32 `plist:",omitempty"` |
| 239 |
Float64 float64 `plist:",omitempty"` |
| 240 |
Stringptr *string `plist:",omitempty"` |
| 241 |
Notempty uint `plist:",omitempty"` |
| 242 |
}{ |
| 243 |
Name: "Dustin", |
| 244 |
Notempty: 10, |
| 245 |
}, |
| 246 |
DecodeValue: struct { |
| 247 |
Name string |
| 248 |
Age int `plist:"age,omitempty"` |
| 249 |
Slice []int `plist:",omitempty"` |
| 250 |
Bool bool `plist:",omitempty"` |
| 251 |
Uint uint `plist:",omitempty"` |
| 252 |
Float32 float32 `plist:",omitempty"` |
| 253 |
Float64 float64 `plist:",omitempty"` |
| 254 |
Stringptr *string `plist:",omitempty"` |
| 255 |
Notempty uint `plist:",omitempty"` |
| 256 |
}{ |
| 257 |
Name: "Dustin", |
| 258 |
Notempty: 10, |
| 259 |
}, |
| 260 |
Documents: map[int][]byte{ |
| 261 |
OpenStepFormat: []byte(`{Name=Dustin;Notempty=10;}`), |
| 262 |
GNUStepFormat: []byte(`{Name=Dustin;Notempty=<*I10>;}`), |
| 263 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>Name</key><string>Dustin</string><key>Notempty</key><integer>10</integer></dict></plist>`), |
| 264 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd2, 0x1, 0x2, 0x3, 0x4, 0x54, 0x4e, 0x61, 0x6d, 0x65, 0x58, 0x4e, 0x6f, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x56, 0x44, 0x75, 0x73, 0x74, 0x69, 0x6e, 0x10, 0xa, 0x8, 0xd, 0x12, 0x1b, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24}, |
| 265 |
}, |
| 266 |
}, |
| 267 |
{ |
| 268 |
Name: "Structure with Anonymous Embeds", |
| 269 |
Value: EmbedA{ |
| 270 |
EmbedC: EmbedC{ |
| 271 |
FieldA1: "", |
| 272 |
FieldA2: "", |
| 273 |
FieldB: "A.C.B", |
| 274 |
FieldC: "A.C.C", |
| 275 |
}, |
| 276 |
EmbedB: EmbedB{ |
| 277 |
FieldB: "A.B.B", |
| 278 |
EmbedC: &EmbedC{ |
| 279 |
FieldA1: "A.B.C.A1", |
| 280 |
FieldA2: "A.B.C.A2", |
| 281 |
FieldB: "", |
| 282 |
FieldC: "A.B.C.C", |
| 283 |
}, |
| 284 |
}, |
| 285 |
FieldA: "A.A", |
| 286 |
}, |
| 287 |
Documents: map[int][]byte{ |
| 288 |
OpenStepFormat: []byte(`{EmbedB={FieldA="A.B.C.A1";FieldA2="A.B.C.A2";FieldB="A.B.B";FieldC="A.B.C.C";};FieldA="A.A";FieldA2="";FieldB="A.C.B";FieldC="A.C.C";}`), |
| 289 |
GNUStepFormat: []byte(`{EmbedB={FieldA=A.B.C.A1;FieldA2=A.B.C.A2;FieldB=A.B.B;FieldC=A.B.C.C;};FieldA=A.A;FieldA2="";FieldB=A.C.B;FieldC=A.C.C;}`), |
| 290 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>EmbedB</key><dict><key>FieldA</key><string>A.B.C.A1</string><key>FieldA2</key><string>A.B.C.A2</string><key>FieldB</key><string>A.B.B</string><key>FieldC</key><string>A.B.C.C</string></dict><key>FieldA</key><string>A.A</string><key>FieldA2</key><string/><key>FieldB</key><string>A.C.B</string><key>FieldC</key><string>A.C.C</string></dict></plist>`), |
| 291 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd5, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0xb, 0xc, 0xd, 0xe, 0x56, 0x45, 0x6d, 0x62, 0x65, 0x64, 0x42, 0x56, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x41, 0x57, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x41, 0x32, 0x56, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x56, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0xd4, 0x2, 0x3, 0x4, 0x5, 0x7, 0x8, 0x9, 0xa, 0x58, 0x41, 0x2e, 0x42, 0x2e, 0x43, 0x2e, 0x41, 0x31, 0x58, 0x41, 0x2e, 0x42, 0x2e, 0x43, 0x2e, 0x41, 0x32, 0x55, 0x41, 0x2e, 0x42, 0x2e, 0x42, 0x57, 0x41, 0x2e, 0x42, 0x2e, 0x43, 0x2e, 0x43, 0x53, 0x41, 0x2e, 0x41, 0x50, 0x55, 0x41, 0x2e, 0x43, 0x2e, 0x42, 0x55, 0x41, 0x2e, 0x43, 0x2e, 0x43, 0x8, 0x13, 0x1a, 0x21, 0x29, 0x30, 0x37, 0x40, 0x49, 0x52, 0x58, 0x60, 0x64, 0x65, 0x6b, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x71}, |
| 292 |
}, |
| 293 |
}, |
| 294 |
{ |
| 295 |
Name: "Arbitrary Byte Data", |
| 296 |
Value: []byte{'h', 'e', 'l', 'l', 'o'}, |
| 297 |
Documents: map[int][]byte{ |
| 298 |
OpenStepFormat: []byte(`<68656c6c 6f>`), |
| 299 |
GNUStepFormat: []byte(`<[aGVsbG8=]>`), |
| 300 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><data>aGVsbG8=</data></plist>`), |
| 301 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 69, 104, 101, 108, 108, 111, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14}, |
| 302 |
}, |
| 303 |
|
| 304 |
SkipEncode: map[int]bool{GNUStepFormat: true}, |
| 305 |
}, |
| 306 |
{ |
| 307 |
Name: "Arbitrary Byte Data (array)", |
| 308 |
Value: [5]byte{'h', 'e', 'l', 'l', 'o'}, |
| 309 |
Documents: map[int][]byte{ |
| 310 |
OpenStepFormat: []byte(`<68656c6c 6f>`), |
| 311 |
GNUStepFormat: []byte(`<[aGVsbG8=]>`), |
| 312 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><data>aGVsbG8=</data></plist>`), |
| 313 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 69, 104, 101, 108, 108, 111, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14}, |
| 314 |
}, |
| 315 |
|
| 316 |
SkipEncode: map[int]bool{GNUStepFormat: true}, |
| 317 |
}, |
| 318 |
{ |
| 319 |
Name: "Arbitrary Integer Slice", |
| 320 |
Value: []int{'h', 'e', 'l', 'l', 'o'}, |
| 321 |
Documents: map[int][]byte{ |
| 322 |
OpenStepFormat: []byte(`(104,101,108,108,111,)`), |
| 323 |
GNUStepFormat: []byte(`(<*I104>,<*I101>,<*I108>,<*I108>,<*I111>,)`), |
| 324 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>104</integer><integer>101</integer><integer>108</integer><integer>108</integer><integer>111</integer></array></plist>`), |
| 325 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 165, 1, 2, 3, 3, 4, 16, 104, 16, 101, 16, 108, 16, 111, 8, 14, 16, 18, 20, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22}, |
| 326 |
}, |
| 327 |
}, |
| 328 |
{ |
| 329 |
Name: "Arbitrary Integer Array", |
| 330 |
Value: [3]int{'h', 'i', '!'}, |
| 331 |
Documents: map[int][]byte{ |
| 332 |
OpenStepFormat: []byte(`(104,105,33,)`), |
| 333 |
GNUStepFormat: []byte(`(<*I104>,<*I105>,<*I33>,)`), |
| 334 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>104</integer><integer>105</integer><integer>33</integer></array></plist>`), |
| 335 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 163, 1, 2, 3, 16, 104, 16, 105, 16, 33, 8, 12, 14, 16, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}, |
| 336 |
}, |
| 337 |
}, |
| 338 |
{ |
| 339 |
Name: "Unsigned Integers of Increasing Size", |
| 340 |
Value: []uint64{0xff, 0xfff, 0xffff, 0xfffff, 0xffffff, 0xfffffff, 0xffffffff, 0x7fffffffffffffff, 0xdeadbeeffacecafe}, |
| 341 |
Documents: map[int][]byte{ |
| 342 |
OpenStepFormat: []byte(`(255,4095,65535,1048575,16777215,268435455,4294967295,9223372036854775807,16045690985305262846,)`), |
| 343 |
GNUStepFormat: []byte(`(<*I255>,<*I4095>,<*I65535>,<*I1048575>,<*I16777215>,<*I268435455>,<*I4294967295>,<*I9223372036854775807>,<*I16045690985305262846>,)`), |
| 344 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>255</integer><integer>4095</integer><integer>65535</integer><integer>1048575</integer><integer>16777215</integer><integer>268435455</integer><integer>4294967295</integer><integer>9223372036854775807</integer><integer>16045690985305262846</integer></array></plist>`), |
| 345 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xa9, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0xff, 0x11, 0x0f, 0xff, 0x11, 0xff, 0xff, 0x12, 0x00, 0x0f, 0xff, 0xff, 0x12, 0x00, 0xff, 0xff, 0xff, 0x12, 0x0f, 0xff, 0xff, 0xff, 0x12, 0xff, 0xff, 0xff, 0xff, 0x13, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xad, 0xbe, 0xef, 0xfa, 0xce, 0xca, 0xfe, 0x08, 0x12, 0x14, 0x17, 0x1a, 0x1f, 0x24, 0x29, 0x2e, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48}, |
| 346 |
}, |
| 347 |
}, |
| 348 |
{ |
| 349 |
Name: "Hexadecimal Integers", |
| 350 |
Value: []int{'h', 'e', 'x', 'i', 'n', 't', -42}, |
| 351 |
Documents: map[int][]byte{ |
| 352 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>0x68</integer><integer>0X65</integer><integer>0x78</integer><integer>0X69</integer><integer>0x6e</integer><integer>0X74</integer><integer>-0x2a</integer></array></plist>`), |
| 353 |
}, |
| 354 |
SkipEncode: map[int]bool{XMLFormat: true}, |
| 355 |
}, |
| 356 |
{ |
| 357 |
Name: "Octal Integers (treated as Decimal)", |
| 358 |
Value: []int{'o', 'c', 't', 'i', 'n', 't', -42}, |
| 359 |
Documents: map[int][]byte{ |
| 360 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>0111</integer><integer>099</integer><integer>0116</integer><integer>0105</integer><integer>0110</integer><integer>0116</integer><integer>-042</integer></array></plist>`), |
| 361 |
}, |
| 362 |
SkipEncode: map[int]bool{XMLFormat: true}, |
| 363 |
}, |
| 364 |
{ |
| 365 |
Name: "Floats of Increasing Bitness", |
| 366 |
Value: []interface{}{float32(math.MaxFloat32), float64(math.MaxFloat64)}, |
| 367 |
Documents: map[int][]byte{ |
| 368 |
OpenStepFormat: []byte(`(3.4028234663852886e+38,1.7976931348623157e+308,)`), |
| 369 |
GNUStepFormat: []byte(`(<*R3.4028234663852886e+38>,<*R1.7976931348623157e+308>,)`), |
| 370 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><real>3.4028234663852886e+38</real><real>1.7976931348623157e+308</real></array></plist>`), |
| 371 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 162, 1, 2, 34, 127, 127, 255, 255, 35, 127, 239, 255, 255, 255, 255, 255, 255, 8, 11, 16, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25}, |
| 372 |
}, |
| 373 |
|
| 374 |
SkipDecode: map[int]bool{XMLFormat: true, OpenStepFormat: true, GNUStepFormat: true}, |
| 375 |
}, |
| 376 |
{ |
| 377 |
Name: "Boolean True", |
| 378 |
Value: true, |
| 379 |
Documents: map[int][]byte{ |
| 380 |
OpenStepFormat: []byte(`1`), |
| 381 |
GNUStepFormat: []byte(`<*BY>`), |
| 382 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><true/></plist>`), |
| 383 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 9, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9}, |
| 384 |
}, |
| 385 |
}, |
| 386 |
{ |
| 387 |
Name: "Floating-Point Value", |
| 388 |
Value: 3.14159265358979323846264338327950288, |
| 389 |
Documents: map[int][]byte{ |
| 390 |
OpenStepFormat: []byte(`3.141592653589793`), |
| 391 |
GNUStepFormat: []byte(`<*R3.141592653589793>`), |
| 392 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><real>3.141592653589793</real></plist>`), |
| 393 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 64, 9, 33, 251, 84, 68, 45, 24, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 394 |
}, |
| 395 |
}, |
| 396 |
{ |
| 397 |
Name: "Map (containing arbitrary types)", |
| 398 |
Value: map[string]interface{}{ |
| 399 |
"float": 1.0, |
| 400 |
"uint64": uint64(1), |
| 401 |
}, |
| 402 |
Documents: map[int][]byte{ |
| 403 |
OpenStepFormat: []byte(`{float=1;uint64=1;}`), |
| 404 |
GNUStepFormat: []byte(`{float=<*R1>;uint64=<*I1>;}`), |
| 405 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>float</key><real>1</real><key>uint64</key><integer>1</integer></dict></plist>`), |
| 406 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd2, 0x1, 0x2, 0x3, 0x4, 0x55, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x23, 0x3f, 0xf0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x1, 0x8, 0xd, 0x13, 0x1a, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x25}, |
| 407 |
}, |
| 408 |
|
| 409 |
SkipDecode: map[int]bool{OpenStepFormat: true}, |
| 410 |
}, |
| 411 |
{ |
| 412 |
Name: "Map (containing all variations of all types)", |
| 413 |
Value: interface{}(map[string]interface{}{ |
| 414 |
"intarray": []interface{}{ |
| 415 |
int(1), |
| 416 |
int8(8), |
| 417 |
int16(16), |
| 418 |
int32(32), |
| 419 |
int64(64), |
| 420 |
uint(2), |
| 421 |
uint8(9), |
| 422 |
uint16(17), |
| 423 |
uint32(33), |
| 424 |
uint64(65), |
| 425 |
}, |
| 426 |
"floats": []interface{}{ |
| 427 |
float32(32.0), |
| 428 |
float64(64.0), |
| 429 |
}, |
| 430 |
"booleans": []bool{ |
| 431 |
true, |
| 432 |
false, |
| 433 |
}, |
| 434 |
"strings": []string{ |
| 435 |
"Hello, ASCII", |
| 436 |
"Hello, 世界", |
| 437 |
}, |
| 438 |
"data": []byte{1, 2, 3, 4}, |
| 439 |
"date": time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC), |
| 440 |
}), |
| 441 |
Documents: map[int][]byte{ |
| 442 |
OpenStepFormat: []byte(`{booleans=(1,0,);data=<01020304>;date="2013-11-27 00:34:00 +0000";floats=(32,64,);intarray=(1,8,16,32,64,2,9,17,33,65,);strings=("Hello, ASCII","Hello, \U4e16\U754c",);}`), |
| 443 |
GNUStepFormat: []byte(`{booleans=(<*BY>,<*BN>,);data=<01020304>;date=<*D2013-11-27 00:34:00 +0000>;floats=(<*R32>,<*R64>,);intarray=(<*I1>,<*I8>,<*I16>,<*I32>,<*I64>,<*I2>,<*I9>,<*I17>,<*I33>,<*I65>,);strings=("Hello, ASCII","Hello, \U4e16\U754c",);}`), |
| 444 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>booleans</key><array><true/><false/></array><key>data</key><data>AQIDBA==</data><key>date</key><date>2013-11-27T00:34:00Z</date><key>floats</key><array><real>32</real><real>64</real></array><key>intarray</key><array><integer>1</integer><integer>8</integer><integer>16</integer><integer>32</integer><integer>64</integer><integer>2</integer><integer>9</integer><integer>17</integer><integer>33</integer><integer>65</integer></array><key>strings</key><array><string>Hello, ASCII</string><string>Hello, 世界</string></array></dict></plist>`), |
| 445 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd6, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xa, 0xb, 0xc, 0xf, 0x1a, 0x58, 0x62, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x73, 0x54, 0x64, 0x61, 0x74, 0x61, 0x54, 0x64, 0x61, 0x74, 0x65, 0x56, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x73, 0x58, 0x69, 0x6e, 0x74, 0x61, 0x72, 0x72, 0x61, 0x79, 0x57, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0xa2, 0x8, 0x9, 0x9, 0x8, 0x44, 0x1, 0x2, 0x3, 0x4, 0x33, 0x41, 0xb8, 0x45, 0x75, 0x78, 0x0, 0x0, 0x0, 0xa2, 0xd, 0xe, 0x22, 0x42, 0x0, 0x0, 0x0, 0x23, 0x40, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaa, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x10, 0x1, 0x10, 0x8, 0x10, 0x10, 0x10, 0x20, 0x10, 0x40, 0x10, 0x2, 0x10, 0x9, 0x10, 0x11, 0x10, 0x21, 0x10, 0x41, 0xa2, 0x1b, 0x1c, 0x5c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x41, 0x53, 0x43, 0x49, 0x49, 0x69, 0x0, 0x48, 0x0, 0x65, 0x0, 0x6c, 0x0, 0x6c, 0x0, 0x6f, 0x0, 0x2c, 0x0, 0x20, 0x4e, 0x16, 0x75, 0x4c, 0x8, 0x15, 0x1e, 0x23, 0x28, 0x2f, 0x38, 0x40, 0x43, 0x44, 0x45, 0x4a, 0x53, 0x56, 0x5b, 0x64, 0x6f, 0x71, 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d, 0x7f, 0x81, 0x83, 0x86, 0x93, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa6}, |
| 446 |
}, |
| 447 |
SkipDecode: map[int]bool{OpenStepFormat: true, GNUStepFormat: true, XMLFormat: true, BinaryFormat: true}, |
| 448 |
}, |
| 449 |
{ |
| 450 |
Name: "Map (containing nil)", |
| 451 |
Value: map[string]interface{}{ |
| 452 |
"float": 1.5, |
| 453 |
"uint64": uint64(1), |
| 454 |
"nil": nil, |
| 455 |
}, |
| 456 |
DecodeValue: map[string]interface{}{ |
| 457 |
"float": 1.5, |
| 458 |
"uint64": uint64(1), |
| 459 |
}, |
| 460 |
Documents: map[int][]byte{ |
| 461 |
OpenStepFormat: []byte(`{float=1.5;uint64=1;}`), |
| 462 |
GNUStepFormat: []byte(`{float=<*R1.5>;uint64=<*I1>;}`), |
| 463 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>float</key><real>1.5</real><key>uint64</key><integer>1</integer></dict></plist>`), |
| 464 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd2, 0x1, 0x2, 0x3, 0x4, 0x55, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x23, 0x3f, 0xf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x1, 0x8, 0xd, 0x13, 0x1a, 0x23, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x25}, |
| 465 |
}, |
| 466 |
|
| 467 |
SkipDecode: map[int]bool{OpenStepFormat: true}, |
| 468 |
}, |
| 469 |
{ |
| 470 |
Name: "Pointer to structure with plist tags", |
| 471 |
Value: &SparseBundleHeader{ |
| 472 |
InfoDictionaryVersion: "6.0", |
| 473 |
BandSize: 8388608, |
| 474 |
Size: 4 * 1048576 * 1024 * 1024, |
| 475 |
DiskImageBundleType: "com.apple.diskimage.sparsebundle", |
| 476 |
BackingStoreVersion: 1, |
| 477 |
}, |
| 478 |
Documents: map[int][]byte{ |
| 479 |
OpenStepFormat: []byte(`{CFBundleInfoDictionaryVersion="6.0";"band-size"=8388608;"bundle-backingstore-version"=1;"diskimage-bundle-type"="com.apple.diskimage.sparsebundle";size=4398046511104;}`), |
| 480 |
GNUStepFormat: []byte(`{CFBundleInfoDictionaryVersion=6.0;band-size=<*I8388608>;bundle-backingstore-version=<*I1>;diskimage-bundle-type=com.apple.diskimage.sparsebundle;size=<*I4398046511104>;}`), |
| 481 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>CFBundleInfoDictionaryVersion</key><string>6.0</string><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></dict></plist>`), |
| 482 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd5, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0x5f, 0x10, 0x1d, 0x43, 0x46, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x69, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x72, 0x79, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x59, 0x62, 0x61, 0x6e, 0x64, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x10, 0x1b, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2d, 0x62, 0x61, 0x63, 0x6b, 0x69, 0x6e, 0x67, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x10, 0x15, 0x64, 0x69, 0x73, 0x6b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2d, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x54, 0x73, 0x69, 0x7a, 0x65, 0x53, 0x36, 0x2e, 0x30, 0x12, 0x0, 0x80, 0x0, 0x0, 0x10, 0x1, 0x5f, 0x10, 0x20, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2e, 0x64, 0x69, 0x73, 0x6b, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x70, 0x61, 0x72, 0x73, 0x65, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x13, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x13, 0x33, 0x3d, 0x5b, 0x73, 0x78, 0x7c, 0x81, 0x83, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xaf}, |
| 483 |
}, |
| 484 |
SkipDecode: map[int]bool{OpenStepFormat: true}, |
| 485 |
}, |
| 486 |
{ |
| 487 |
Name: "Array of byte arrays", |
| 488 |
Value: [][]byte{ |
| 489 |
[]byte("Hello"), |
| 490 |
[]byte("World"), |
| 491 |
}, |
| 492 |
Documents: map[int][]byte{ |
| 493 |
OpenStepFormat: []byte(`(<48656c6c 6f>,<576f726c 64>,)`), |
| 494 |
GNUStepFormat: []byte(`(<48656c6c 6f>,<576f726c 64>,)`), |
| 495 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><data>SGVsbG8=</data><data>V29ybGQ=</data></array></plist>`), |
| 496 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 162, 1, 2, 69, 72, 101, 108, 108, 111, 69, 87, 111, 114, 108, 100, 8, 11, 17, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23}, |
| 497 |
}, |
| 498 |
}, |
| 499 |
{ |
| 500 |
Name: "Date", |
| 501 |
Value: time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC), |
| 502 |
Documents: map[int][]byte{ |
| 503 |
OpenStepFormat: []byte(`"2013-11-27 00:34:00 +0000"`), |
| 504 |
GNUStepFormat: []byte(`<*D2013-11-27 00:34:00 +0000>`), |
| 505 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><date>2013-11-27T00:34:00Z</date></plist>`), |
| 506 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 51, 65, 184, 69, 117, 120, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 507 |
}, |
| 508 |
}, |
| 509 |
{ |
| 510 |
Name: "Floating-Point NaN", |
| 511 |
Value: math.NaN(), |
| 512 |
Documents: map[int][]byte{ |
| 513 |
OpenStepFormat: []byte(`NaN`), |
| 514 |
GNUStepFormat: []byte(`<*RNaN>`), |
| 515 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><real>nan</real></plist>`), |
| 516 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 127, 248, 0, 0, 0, 0, 0, 1, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 517 |
}, |
| 518 |
SkipDecode: map[int]bool{OpenStepFormat: true, GNUStepFormat: true, XMLFormat: true, BinaryFormat: true}, |
| 519 |
}, |
| 520 |
{ |
| 521 |
Name: "Floating-Point Infinity", |
| 522 |
Value: math.Inf(1), |
| 523 |
Documents: map[int][]byte{ |
| 524 |
OpenStepFormat: []byte(`+Inf`), |
| 525 |
GNUStepFormat: []byte(`<*R+Inf>`), |
| 526 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><real>inf</real></plist>`), |
| 527 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 127, 240, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 528 |
}, |
| 529 |
}, |
| 530 |
{ |
| 531 |
Name: "Floating-Point Negative Infinity", |
| 532 |
Value: math.Inf(-1), |
| 533 |
Documents: map[int][]byte{ |
| 534 |
OpenStepFormat: []byte(`-Inf`), |
| 535 |
GNUStepFormat: []byte(`<*R-Inf>`), |
| 536 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><real>-inf</real></plist>`), |
| 537 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 35, 255, 240, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 538 |
}, |
| 539 |
}, |
| 540 |
{ |
| 541 |
Name: "UTF-8 string", |
| 542 |
Value: []string{"Hello, ASCII", "Hello, 世界"}, |
| 543 |
Documents: map[int][]byte{ |
| 544 |
OpenStepFormat: []byte(`("Hello, ASCII","Hello, \U4e16\U754c",)`), |
| 545 |
GNUStepFormat: []byte(`("Hello, ASCII","Hello, \U4e16\U754c",)`), |
| 546 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><string>Hello, ASCII</string><string>Hello, 世界</string></array></plist>`), |
| 547 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 162, 1, 2, 92, 72, 101, 108, 108, 111, 44, 32, 65, 83, 67, 73, 73, 105, 0, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 44, 0, 32, 78, 22, 117, 76, 8, 11, 24, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43}, |
| 548 |
}, |
| 549 |
}, |
| 550 |
{ |
| 551 |
Name: "An array containing more than fifteen items", |
| 552 |
Value: []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, |
| 553 |
Documents: map[int][]byte{ |
| 554 |
OpenStepFormat: []byte(`(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,)`), |
| 555 |
GNUStepFormat: []byte(`(<*I1>,<*I2>,<*I3>,<*I4>,<*I5>,<*I6>,<*I7>,<*I8>,<*I9>,<*I10>,<*I11>,<*I12>,<*I13>,<*I14>,<*I15>,<*I16>,)`), |
| 556 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>1</integer><integer>2</integer><integer>3</integer><integer>4</integer><integer>5</integer><integer>6</integer><integer>7</integer><integer>8</integer><integer>9</integer><integer>10</integer><integer>11</integer><integer>12</integer><integer>13</integer><integer>14</integer><integer>15</integer><integer>16</integer></array></plist>`), |
| 557 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 175, 16, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 1, 16, 2, 16, 3, 16, 4, 16, 5, 16, 6, 16, 7, 16, 8, 16, 9, 16, 10, 16, 11, 16, 12, 16, 13, 16, 14, 16, 15, 16, 16, 8, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59}, |
| 558 |
}, |
| 559 |
}, |
| 560 |
{ |
| 561 |
Name: "TextMarshaler/TextUnmarshaler", |
| 562 |
Value: TextMarshalingBool{true}, |
| 563 |
Documents: map[int][]byte{ |
| 564 |
OpenStepFormat: []byte(`truthful`), |
| 565 |
GNUStepFormat: []byte(`truthful`), |
| 566 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><string>truthful</string></plist>`), |
| 567 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 88, 116, 114, 117, 116, 104, 102, 117, 108, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17}, |
| 568 |
}, |
| 569 |
|
| 570 |
}, |
| 571 |
{ |
| 572 |
Name: "TextMarshaler/TextUnmarshaler via Pointer", |
| 573 |
Value: &TextMarshalingBoolViaPointer{false}, |
| 574 |
Documents: map[int][]byte{ |
| 575 |
OpenStepFormat: []byte(`unimaginable`), |
| 576 |
GNUStepFormat: []byte(`unimaginable`), |
| 577 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><string>unimaginable</string></plist>`), |
| 578 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 92, 117, 110, 105, 109, 97, 103, 105, 110, 97, 98, 108, 101, 8, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21}, |
| 579 |
}, |
| 580 |
DecodeValue: TextMarshalingBoolViaPointer{false}, |
| 581 |
}, |
| 582 |
{ |
| 583 |
Name: "Duplicated Values", |
| 584 |
Value: []interface{}{ |
| 585 |
"Hello", |
| 586 |
float32(32.0), |
| 587 |
float64(32.0), |
| 588 |
[]byte("data"), |
| 589 |
float32(64.0), |
| 590 |
float64(64.0), |
| 591 |
uint64(100), |
| 592 |
float32(32.0), |
| 593 |
time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC), |
| 594 |
float64(32.0), |
| 595 |
float32(64.0), |
| 596 |
float64(64.0), |
| 597 |
"Hello", |
| 598 |
[]byte("data"), |
| 599 |
uint64(100), |
| 600 |
time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC), |
| 601 |
}, |
| 602 |
Documents: map[int][]byte{ |
| 603 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xaf, 0x10, 0x10, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x2, 0x8, 0x3, 0x5, 0x6, 0x1, 0x4, 0x7, 0x8, 0x55, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x42, 0x0, 0x0, 0x0, 0x23, 0x40, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x44, 0x64, 0x61, 0x74, 0x61, 0x22, 0x42, 0x80, 0x0, 0x0, 0x23, 0x40, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x64, 0x33, 0x41, 0xb8, 0x45, 0x75, 0x78, 0x0, 0x0, 0x0, 0x8, 0x1b, 0x21, 0x26, 0x2f, 0x34, 0x39, 0x42, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4d}, |
| 604 |
}, |
| 605 |
}, |
| 606 |
{ |
| 607 |
Name: "Funny Characters", |
| 608 |
Value: map[string]string{ |
| 609 |
"\a": "\b", |
| 610 |
"\v": "\f", |
| 611 |
"\\": "\"", |
| 612 |
"\t\r": "\n", |
| 613 |
"\u00C8": "wat", |
| 614 |
"\u0100": "hundred", |
| 615 |
}, |
| 616 |
Documents: map[int][]byte{ |
| 617 |
OpenStepFormat: []byte(`{"\a"="\b";` + "\"\t\r\"=\"\n\";" + `"\v"="\f";"\\"="\"";"\310"=wat;"\U0100"=hundred;}`), |
| 618 |
GNUStepFormat: []byte(`{"\a"="\b";` + "\"\t\r\"=\"\n\";" + `"\v"="\f";"\\"="\"";"\310"=wat;"\U0100"=hundred;}`), |
| 619 |
}, |
| 620 |
}, |
| 621 |
{ |
| 622 |
Name: "Signed Integers", |
| 623 |
Value: []int64{-1, -127, -255, -32767, -65535, -9223372036854775808}, |
| 624 |
Documents: map[int][]byte{ |
| 625 |
OpenStepFormat: []byte(`(-1,-127,-255,-32767,-65535,-9223372036854775808,)`), |
| 626 |
GNUStepFormat: []byte(`(<*I-1>,<*I-127>,<*I-255>,<*I-32767>,<*I-65535>,<*I-9223372036854775808>,)`), |
| 627 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><integer>-1</integer><integer>-127</integer><integer>-255</integer><integer>-32767</integer><integer>-65535</integer><integer>-9223372036854775808</integer></array></plist>`), |
| 628 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xa6, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x01, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0x13, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0f, 0x18, 0x21, 0x2a, 0x33, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45}, |
| 629 |
}, |
| 630 |
}, |
| 631 |
{ |
| 632 |
Name: "A map with a blank key", |
| 633 |
Value: map[string]string{ |
| 634 |
"": "Hello", |
| 635 |
}, |
| 636 |
Documents: map[int][]byte{ |
| 637 |
OpenStepFormat: []byte(`{""=Hello;}`), |
| 638 |
GNUStepFormat: []byte(`{""=Hello;}`), |
| 639 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key/><string>Hello</string></dict></plist>`), |
| 640 |
BinaryFormat: []byte{98, 112, 108, 105, 115, 116, 48, 48, 209, 1, 2, 80, 85, 72, 101, 108, 108, 111, 8, 11, 12, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18}, |
| 641 |
}, |
| 642 |
}, |
| 643 |
{ |
| 644 |
Name: "CF Keyed Archiver UIDs (interface{})", |
| 645 |
Value: []UID{ |
| 646 |
0xff, |
| 647 |
0xffff, |
| 648 |
0xffffff, |
| 649 |
0xffffffff, |
| 650 |
0xffffffffff, |
| 651 |
}, |
| 652 |
Documents: map[int][]byte{ |
| 653 |
OpenStepFormat: []byte(`({CF$UID=255;},{CF$UID=65535;},{CF$UID=16777215;},{CF$UID=4294967295;},{CF$UID=1099511627775;},)`), |
| 654 |
GNUStepFormat: []byte(`({CF$UID=<*I255>;},{CF$UID=<*I65535>;},{CF$UID=<*I16777215>;},{CF$UID=<*I4294967295>;},{CF$UID=<*I1099511627775>;},)`), |
| 655 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><array><dict><key>CF$UID</key><integer>255</integer></dict><dict><key>CF$UID</key><integer>65535</integer></dict><dict><key>CF$UID</key><integer>16777215</integer></dict><dict><key>CF$UID</key><integer>4294967295</integer></dict><dict><key>CF$UID</key><integer>1099511627775</integer></dict></array></plist>`), |
| 656 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xa5, 0x01, 0x02, 0x03, 0x04, 0x05, 0x80, 0xff, 0x81, 0xff, 0xff, 0x83, 0x00, 0xff, 0xff, 0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0x87, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x0e, 0x10, 0x13, 0x18, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26}, |
| 657 |
}, |
| 658 |
}, |
| 659 |
{ |
| 660 |
Name: "CF Keyed Archiver UID (struct)", |
| 661 |
Value: struct { |
| 662 |
U UID `plist:"identifier"` |
| 663 |
}{ |
| 664 |
U: 1024, |
| 665 |
}, |
| 666 |
Documents: map[int][]byte{ |
| 667 |
OpenStepFormat: []byte(`{identifier={CF$UID=1024;};}`), |
| 668 |
GNUStepFormat: []byte(`{identifier={CF$UID=<*I1024>;};}`), |
| 669 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>identifier</key><dict><key>CF$UID</key><integer>1024</integer></dict></dict></plist>`), |
| 670 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd1, 0x01, 0x02, 0x5a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x81, 0x04, 0x00, 0x08, 0x0b, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19}, |
| 671 |
}, |
| 672 |
}, |
| 673 |
{ |
| 674 |
Name: "CF Keyed Archiver UID as Legacy Int", |
| 675 |
Value: struct { |
| 676 |
U UID `plist:"identifier"` |
| 677 |
}{ |
| 678 |
U: 1024, |
| 679 |
}, |
| 680 |
Documents: map[int][]byte{ |
| 681 |
OpenStepFormat: []byte(`{identifier={CF$UID=1024;};}`), |
| 682 |
GNUStepFormat: []byte(`{identifier={CF$UID=<*I1024>;};}`), |
| 683 |
XMLFormat: []byte(xmlPreamble + `<plist version="1.0"><dict><key>identifier</key><dict><key>CF$UID</key><integer>1024</integer></dict></dict></plist>`), |
| 684 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xd1, 0x01, 0x02, 0x5a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x81, 0x04, 0x00, 0x08, 0x0b, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19}, |
| 685 |
}, |
| 686 |
DecodeValue: struct { |
| 687 |
U uint64 `plist:"identifier"` |
| 688 |
}{ |
| 689 |
U: 1024, |
| 690 |
}, |
| 691 |
}, |
| 692 |
{ |
| 693 |
Name: "Custom Marshaller/Unmarshaller by Value", |
| 694 |
Value: []ArrayThatSerializesAsOneObject{ |
| 695 |
ArrayThatSerializesAsOneObject{[]uint64{100}}, |
| 696 |
ArrayThatSerializesAsOneObject{[]uint64{2, 4, 6, 8}}, |
| 697 |
}, |
| 698 |
Documents: map[int][]byte{ |
| 699 |
GNUStepFormat: []byte(`(<*I100>,(<*I2>,<*I4>,<*I6>,<*I8>,),)`), |
| 700 |
}, |
| 701 |
}, |
| 702 |
{ |
| 703 |
Name: "Custom Marshaller/Unmarshaller by Pointer", |
| 704 |
Value: &PlistMarshalingBoolByPointer{true}, |
| 705 |
Documents: map[int][]byte{ |
| 706 |
OpenStepFormat: []byte(`-1`), |
| 707 |
GNUStepFormat: []byte(`<*I-1>`), |
| 708 |
}, |
| 709 |
}, |
| 710 |
{ |
| 711 |
Name: "Type implementing both Text and Plist Marshaler", |
| 712 |
Value: &BothMarshaler{}, |
| 713 |
Documents: map[int][]byte{ |
| 714 |
GNUStepFormat: []byte(`{a=b;}`), |
| 715 |
}, |
| 716 |
}, |
| 717 |
{ |
| 718 |
Name: "Type implementing both Text and Plist Unmarshaler", |
| 719 |
Value: &BothUnmarshaler{int64(1024)}, |
| 720 |
Documents: map[int][]byte{ |
| 721 |
GNUStepFormat: []byte(`{blah=<*I1024>;}`), |
| 722 |
}, |
| 723 |
DecodeValue: &BothUnmarshaler{int64(0)}, |
| 724 |
}, |
| 725 |
{ |
| 726 |
Name: "Comments", |
| 727 |
Value: struct { |
| 728 |
A, B, C int |
| 729 |
S, S2 string |
| 730 |
}{ |
| 731 |
1, 2, 3, |
| 732 |
"/not/a/comment/", "/not*a/*comm*en/t", |
| 733 |
}, |
| 734 |
Documents: map[int][]byte{ |
| 735 |
OpenStepFormat: []byte(`{ |
| 736 |
A=1 /* A is 1 because it is the first letter */; |
| 737 |
B=2; // B is 2 because comment-to-end-of-line. |
| 738 |
C=3; |
| 739 |
S = /not/a/comment/; |
| 740 |
S2 = /not*a/*comm*en/t; |
| 741 |
}`), |
| 742 |
}, |
| 743 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 744 |
}, |
| 745 |
{ |
| 746 |
Name: "Escapes", |
| 747 |
Value: struct { |
| 748 |
W, A, B, V, F, T, R, N, Hex1, Unicode1, Unicode2, Octal1 string |
| 749 |
}{ |
| 750 |
"w", "\a", "\b", "\v", "\f", "\t", "\r", "\n", "\u00ab", "\u00ac", "\u00ad", "\033", |
| 751 |
}, |
| 752 |
Documents: map[int][]byte{ |
| 753 |
OpenStepFormat: []byte(`{ |
| 754 |
W="\w"; |
| 755 |
A="\a"; |
| 756 |
B="\b"; |
| 757 |
V="\v"; |
| 758 |
F="\f"; |
| 759 |
T="\t"; |
| 760 |
R="\r"; |
| 761 |
N="\n"; |
| 762 |
Hex1="\xAB"; |
| 763 |
Unicode1="\u00AC"; |
| 764 |
Unicode2="\U00AD"; |
| 765 |
Octal1="\033"; |
| 766 |
}`), |
| 767 |
}, |
| 768 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 769 |
}, |
| 770 |
{ |
| 771 |
Name: "Empty Strings in Arrays", |
| 772 |
Value: []string{"A"}, |
| 773 |
Documents: map[int][]byte{ |
| 774 |
OpenStepFormat: []byte(`(A,,,"",)`), |
| 775 |
}, |
| 776 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 777 |
}, |
| 778 |
{ |
| 779 |
Name: "Empty Data", |
| 780 |
Value: []byte{}, |
| 781 |
Documents: map[int][]byte{ |
| 782 |
OpenStepFormat: []byte(`<>`), |
| 783 |
}, |
| 784 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 785 |
}, |
| 786 |
{ |
| 787 |
Name: "UTF-8 with BOM", |
| 788 |
Value: "Hello", |
| 789 |
Documents: map[int][]byte{ |
| 790 |
OpenStepFormat: []byte("\uFEFFHello"), |
| 791 |
}, |
| 792 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 793 |
}, |
| 794 |
{ |
| 795 |
Name: "UTF-16LE with BOM", |
| 796 |
Value: "Hello", |
| 797 |
Documents: map[int][]byte{ |
| 798 |
OpenStepFormat: []byte{0xFF, 0xFE, 'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0}, |
| 799 |
}, |
| 800 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 801 |
}, |
| 802 |
{ |
| 803 |
Name: "UTF-16BE with BOM", |
| 804 |
Value: "Hello", |
| 805 |
Documents: map[int][]byte{ |
| 806 |
OpenStepFormat: []byte{0xFE, 0xFF, 0, 'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o'}, |
| 807 |
}, |
| 808 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 809 |
}, |
| 810 |
{ |
| 811 |
Name: "UTF-16LE without BOM", |
| 812 |
Value: "Hello", |
| 813 |
Documents: map[int][]byte{ |
| 814 |
OpenStepFormat: []byte{'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0}, |
| 815 |
}, |
| 816 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 817 |
}, |
| 818 |
{ |
| 819 |
Name: "UTF-16BE without BOM", |
| 820 |
Value: "Hello", |
| 821 |
Documents: map[int][]byte{ |
| 822 |
OpenStepFormat: []byte{0, 'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o'}, |
| 823 |
}, |
| 824 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 825 |
}, |
| 826 |
{ |
| 827 |
Name: "UTF-16BE with High Characters", |
| 828 |
Value: "Hello, 世界", |
| 829 |
Documents: map[int][]byte{ |
| 830 |
OpenStepFormat: []byte{0, '"', 0, 'H', 0, 'e', 0, 'l', 0, 'l', 0, 'o', 0, ',', 0, ' ', 0x4E, 0x16, 0x75, 0x4C, 0, '"'}, |
| 831 |
}, |
| 832 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 833 |
}, |
| 834 |
{ |
| 835 |
Name: "Legacy Strings File Format (No Dictionary)", |
| 836 |
Value: map[string]string{ |
| 837 |
"Key": "Value", |
| 838 |
"Key2": "Value2", |
| 839 |
}, |
| 840 |
Documents: map[int][]byte{ |
| 841 |
OpenStepFormat: []byte(`"Key" = "Value"; |
| 842 |
"Key2" = "Value2";`), |
| 843 |
}, |
| 844 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 845 |
}, |
| 846 |
{ |
| 847 |
Name: "Strings File Shortcut Format (No Values)", |
| 848 |
Value: map[string]string{ |
| 849 |
"Key": "Key", |
| 850 |
"Key2": "Key2", |
| 851 |
}, |
| 852 |
Documents: map[int][]byte{ |
| 853 |
OpenStepFormat: []byte(`"Key"; |
| 854 |
"Key2";`), |
| 855 |
}, |
| 856 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 857 |
}, |
| 858 |
{ |
| 859 |
Name: "Various Truncated Escapes", |
| 860 |
Value: "\x01\x02\x03\x04\x057", |
| 861 |
Documents: map[int][]byte{ |
| 862 |
OpenStepFormat: []byte(`"\x1\u02\U003\4\0057"`), |
| 863 |
}, |
| 864 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 865 |
}, |
| 866 |
{ |
| 867 |
Name: "Various Case-Insensitive Escapes", |
| 868 |
Value: "\u00AB\uCDEF", |
| 869 |
Documents: map[int][]byte{ |
| 870 |
OpenStepFormat: []byte(`"\xaB\uCdEf"`), |
| 871 |
}, |
| 872 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 873 |
}, |
| 874 |
{ |
| 875 |
Name: "Text data long enough to trigger implementation-specific reallocation", |
| 876 |
Value: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, |
| 877 |
Documents: map[int][]byte{ |
| 878 |
OpenStepFormat: []byte("<0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001>"), |
| 879 |
}, |
| 880 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 881 |
}, |
| 882 |
{ |
| 883 |
Name: "Empty Text Document", |
| 884 |
Value: map[string]interface{}{}, |
| 885 |
Documents: map[int][]byte{ |
| 886 |
OpenStepFormat: []byte{}, |
| 887 |
}, |
| 888 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 889 |
}, |
| 890 |
{ |
| 891 |
Name: "Text document consisting of only whitespace", |
| 892 |
Value: map[string]interface{}{}, |
| 893 |
Documents: map[int][]byte{ |
| 894 |
OpenStepFormat: []byte(" \n\t"), |
| 895 |
}, |
| 896 |
SkipEncode: map[int]bool{OpenStepFormat: true}, |
| 897 |
}, |
| 898 |
{ |
| 899 |
Name: "Sized integers at size boundaries", |
| 900 |
Value: []interface{}{ |
| 901 |
int8(-128), |
| 902 |
int8(127), |
| 903 |
int16(-32768), |
| 904 |
int16(32767), |
| 905 |
int32(-2147483648), |
| 906 |
int32(2147483647), |
| 907 |
int64(-9223372036854775808), |
| 908 |
int64(9223372036854775807), |
| 909 |
}, |
| 910 |
DecodeValue: []interface{}{ |
| 911 |
|
| 912 |
int64(-128), |
| 913 |
uint64(127), |
| 914 |
int64(-32768), |
| 915 |
uint64(32767), |
| 916 |
int64(-2147483648), |
| 917 |
uint64(2147483647), |
| 918 |
int64(-9223372036854775808), |
| 919 |
uint64(9223372036854775807), |
| 920 |
}, |
| 921 |
Documents: map[int][]byte{ |
| 922 |
BinaryFormat: []byte{0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xa8, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x10, 0x7f, 0x13, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x11, 0x7f, 0xff, 0x13, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x12, 0x7f, 0xff, 0xff, 0xff, 0x13, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x11, 0x1a, 0x1c, 0x25, 0x28, 0x31, 0x36, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48}, |
| 923 |
}, |
| 924 |
}, |
| 925 |
{ |
| 926 |
Name: "Duplicate Dictionary Keys", |
| 927 |
Value: map[string]interface{}{ |
| 928 |
"key": "second value", |
| 929 |
}, |
| 930 |
Documents: map[int][]byte{ |
| 931 |
XMLFormat: []byte(`<plist><dict><key>key</key><string>value</string><key>key</key><string>second value</string></dict></plist>`), |
| 932 |
OpenStepFormat: []byte(`{"key" = "value"; "key" = "second value";}`), |
| 933 |
GNUStepFormat: []byte(`{"key" = "value"; "key" = "second value";}`), |
| 934 |
BinaryFormat: []byte{ |
| 935 |
'b', 'p', 'l', 'i', 's', 't', '0', '0', |
| 936 |
|
| 937 |
0xD2, 0x01, 0x01, 0x02, 0x03, |
| 938 |
0x53, 'k', 'e', 'y', |
| 939 |
0x55, 'v', 'a', 'l', 'u', 'e', |
| 940 |
0x5C, 's', 'e', 'c', 'o', 'n', 'd', ' ', 'v', 'a', 'l', 'u', 'e', |
| 941 |
|
| 942 |
0x08, 0x0D, 0x11, 0x17, |
| 943 |
|
| 944 |
0x00, 0x00, 0x00, 0x00, 0x00, |
| 945 |
0x00, |
| 946 |
0x01, |
| 947 |
0x01, |
| 948 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, |
| 949 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 950 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, |
| 951 |
}, |
| 952 |
}, |
| 953 |
SkipEncode: map[int]bool{XMLFormat: true, OpenStepFormat: true, GNUStepFormat: true, BinaryFormat: true}, |
| 954 |
}, |
| 955 |
{ |
| 956 |
Name: "GNUStep base64 data ignoring invalid chars", |
| 957 |
Value: [][]byte{ |
| 958 |
{'h', 'e', 'l', 'l', 'o'}, |
| 959 |
{'h', 'e', 'l', 'l', 'o'}, |
| 960 |
}, |
| 961 |
Documents: map[int][]byte{ |
| 962 |
GNUStepFormat: []byte(`(<[aGVs^^bG8=]>,<[ a G V s b G 8 = ]>)`), |
| 963 |
}, |
| 964 |
|
| 965 |
SkipEncode: map[int]bool{GNUStepFormat: true}, |
| 966 |
}, |
| 967 |
{ |
| 968 |
Name: "Text document with quoted GNUstep values", |
| 969 |
Value: []interface{}{uint64(1048576), uint64(1234), true}, |
| 970 |
Documents: map[int][]byte{ |
| 971 |
GNUStepFormat: []byte(`(<*I"1048576">, <*I"1234>, <*B"Y>)`), |
| 972 |
}, |
| 973 |
SkipEncode: map[int]bool{GNUStepFormat: true}, |
| 974 |
}, |
| 975 |
} |
| 976 |
|
| 977 |
type EverythingTestData struct { |
| 978 |
Intarray []uint64 `plist:"intarray"` |
| 979 |
Floats []float64 `plist:"floats"` |
| 980 |
Booleans []bool `plist:"booleans"` |
| 981 |
Strings []string `plist:"strings"` |
| 982 |
Dat []byte `plist:"data"` |
| 983 |
Date time.Time `plist:"date"` |
| 984 |
} |
| 985 |
|
| 986 |
var plistValueTreeRawData = &EverythingTestData{ |
| 987 |
Intarray: []uint64{1, 8, 16, 32, 64, 2, 9, 17, 33, 65}, |
| 988 |
Floats: []float64{32.0, 64.0}, |
| 989 |
Booleans: []bool{true, false}, |
| 990 |
Strings: []string{"Hello, ASCII", "Hello, 世界"}, |
| 991 |
Dat: []byte{1, 2, 3, 4}, |
| 992 |
Date: time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC), |
| 993 |
} |
| 994 |
var plistValueTree cfValue |
| 995 |
var plistValueTreeAsBplist = []byte{98, 112, 108, 105, 115, 116, 48, 48, 214, 1, 13, 17, 21, 25, 27, 2, 14, 18, 22, 26, 28, 88, 105, 110, 116, 97, 114, 114, 97, 121, 170, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 16, 1, 16, 8, 16, 16, 16, 32, 16, 64, 16, 2, 16, 9, 16, 17, 16, 33, 16, 65, 86, 102, 108, 111, 97, 116, 115, 162, 15, 16, 34, 66, 0, 0, 0, 35, 64, 80, 0, 0, 0, 0, 0, 0, 88, 98, 111, 111, 108, 101, 97, 110, 115, 162, 19, 20, 9, 8, 87, 115, 116, 114, 105, 110, 103, 115, 162, 23, 24, 92, 72, 101, 108, 108, 111, 44, 32, 65, 83, 67, 73, 73, 105, 0, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 44, 0, 32, 78, 22, 117, 76, 84, 100, 97, 116, 97, 68, 1, 2, 3, 4, 84, 100, 97, 116, 101, 51, 65, 184, 69, 117, 120, 0, 0, 0, 8, 21, 30, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 68, 71, 76, 85, 94, 97, 98, 99, 107, 110, 123, 142, 147, 152, 157, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 166} |
| 996 |
var plistValueTreeAsXML = xmlPreamble + `<plist version="1.0"><dict><key>intarray</key><array><integer>1</integer><integer>8</integer><integer>16</integer><integer>32</integer><integer>64</integer><integer>2</integer><integer>9</integer><integer>17</integer><integer>33</integer><integer>65</integer></array><key>floats</key><array><real>32</real><real>64</real></array><key>booleans</key><array><true/><false/></array><key>strings</key><array><string>Hello, ASCII</string><string>Hello, 世界</string></array><key>data</key><data>AQIDBA==</data><key>date</key><date>2013-11-27T00:34:00Z</date></dict></plist>` |
| 997 |
var plistValueTreeAsOpenStep = `{booleans=(1,0,);data=<01020304>;date="2013-11-27 00:34:00 +0000";floats=(32,64,);intarray=(1,8,16,32,64,2,9,17,33,65,);strings=("Hello, ASCII","Hello, \U4e16\U754c",);}` |
| 998 |
var plistValueTreeAsGNUStep = `{booleans=(<*BY>,<*BN>,);data=<01020304>;date=<*D2013-11-27 00:34:00 +0000>;floats=(<*R32>,<*R64>,);intarray=(<*I1>,<*I8>,<*I16>,<*I32>,<*I64>,<*I2>,<*I9>,<*I17>,<*I33>,<*I65>,);strings=("Hello, ASCII","Hello, \U4e16\U754c",);}` |
| 999 |
|
| 1000 |
type LaxTestData struct { |
| 1001 |
I64 int64 |
| 1002 |
U64 uint64 |
| 1003 |
F64 float64 |
| 1004 |
B bool |
| 1005 |
D time.Time |
| 1006 |
} |
| 1007 |
|
| 1008 |
var laxTestData = LaxTestData{1, 2, 3.0, true, time.Date(2013, 11, 27, 0, 34, 0, 0, time.UTC)} |
| 1009 |
|
| 1010 |
func setupPlistValues() { |
| 1011 |
plistValueTree = &cfDictionary{ |
| 1012 |
keys: []string{ |
| 1013 |
"intarray", |
| 1014 |
"floats", |
| 1015 |
"booleans", |
| 1016 |
"strings", |
| 1017 |
"data", |
| 1018 |
"date", |
| 1019 |
}, |
| 1020 |
values: []cfValue{ |
| 1021 |
&cfArray{ |
| 1022 |
values: []cfValue{ |
| 1023 |
&cfNumber{value: 1}, |
| 1024 |
&cfNumber{value: 8}, |
| 1025 |
&cfNumber{value: 16}, |
| 1026 |
&cfNumber{value: 32}, |
| 1027 |
&cfNumber{value: 64}, |
| 1028 |
&cfNumber{value: 2}, |
| 1029 |
&cfNumber{value: 8}, |
| 1030 |
&cfNumber{value: 17}, |
| 1031 |
&cfNumber{value: 33}, |
| 1032 |
&cfNumber{value: 65}, |
| 1033 |
}, |
| 1034 |
}, |
| 1035 |
&cfArray{ |
| 1036 |
values: []cfValue{ |
| 1037 |
&cfReal{wide: false, value: 32.0}, |
| 1038 |
&cfReal{wide: true, value: 64.0}, |
| 1039 |
}, |
| 1040 |
}, |
| 1041 |
&cfArray{ |
| 1042 |
values: []cfValue{ |
| 1043 |
cfBoolean(true), |
| 1044 |
cfBoolean(false), |
| 1045 |
}, |
| 1046 |
}, |
| 1047 |
&cfArray{ |
| 1048 |
values: []cfValue{ |
| 1049 |
cfString("Hello, ASCII"), |
| 1050 |
cfString("Hello, 世界"), |
| 1051 |
}, |
| 1052 |
}, |
| 1053 |
cfData{1, 2, 3, 4}, |
| 1054 |
cfDate(time.Date(2013, 11, 27, 0, 32, 0, 0, time.UTC)), |
| 1055 |
}, |
| 1056 |
} |
| 1057 |
} |
| 1058 |
|
| 1059 |
func init() { |
| 1060 |
setupPlistValues() |
| 1061 |
|
| 1062 |
|
| 1063 |
getTypeInfo(reflect.ValueOf(plistValueTreeRawData).Type()) |
| 1064 |
} |