Skip to content

Commit d8e23c3

Browse files
authored
unmarshall map: multibyte example. Fixes #1 (#9)
Provided an example test for the specific case in issue #1.
1 parent c689c68 commit d8e23c3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

unserialize_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,21 @@ func TestUnmarshalArrayThatContainsInteger(t *testing.T) {
523523
t.Errorf("Expected:\n %#+v\nGot:\n %#+v", expected, result)
524524
}
525525
}
526+
527+
// https://github.com/elliotchance/phpserialize/issues/1
528+
func TestUnmarshalMultibyte(t *testing.T) {
529+
data := `a:3:{i:0;a:2:{i:0;s:6:"白色";i:1;s:6:"黑色";}i:1;a:3:{i:0;s:3:"大";i:1;s:3:"中";i:2;s:3:"小";}i:2;a:2:{i:0;s:3:"女";i:1;s:3:"男";}}`
530+
var result map[interface{}]interface{}
531+
err := phpserialize.Unmarshal([]byte(data), &result)
532+
expectErrorToNotHaveOccurred(t, err)
533+
534+
expected := map[interface{}]interface{}{
535+
int64(0): []interface{}{"白色", "黑色"},
536+
int64(1): []interface{}{"大", "中", "小"},
537+
int64(2): []interface{}{"女", "男"},
538+
}
539+
540+
if !reflect.DeepEqual(result, expected) {
541+
t.Errorf("Expected:\n %#+v\nGot:\n %#+v", expected, result)
542+
}
543+
}

0 commit comments

Comments
 (0)