diff options
author | Adam Langley <agl@golang.org> | 2009-11-13 11:29:13 -0800 |
---|---|---|
committer | Adam Langley <agl@golang.org> | 2009-11-13 11:29:13 -0800 |
commit | 94b229c9b08b41907e3382f7112bea30574b197c (patch) | |
tree | 2e3e31007e604c56fa114ae503dc5fc86f8d1755 /src/pkg/json/struct_test.go | |
parent | 6462f9307491d37af52007ae41f72c5fc411e769 (diff) | |
download | golang-94b229c9b08b41907e3382f7112bea30574b197c.tar.gz |
json: fix addressing of slice indexes that are multiples of 8.
Fixes issue 147.
R=rsc
CC=golang-dev
http://codereview.appspot.com/152123
Diffstat (limited to 'src/pkg/json/struct_test.go')
-rw-r--r-- | src/pkg/json/struct_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pkg/json/struct_test.go b/src/pkg/json/struct_test.go index 95a3eb2a4..15446961a 100644 --- a/src/pkg/json/struct_test.go +++ b/src/pkg/json/struct_test.go @@ -6,6 +6,7 @@ package json import ( "reflect"; + "strconv"; "testing"; ) @@ -101,3 +102,33 @@ func TestUnmarshal(t *testing.T) { check(t, reflect.DeepEqual(m.MapStruct, decodedMapStruct), "mapstruct", m.MapStruct); check(t, reflect.DeepEqual(m.MapPtrStruct, decodedMapPtrStruct), "mapptrstruct", m.MapPtrStruct); } + +type Issue147Text struct { + Text string; +} + +type Issue147 struct { + Test []Issue147Text; +} + +const issue147Input = `{"test": [{"text":"0"},{"text":"1"},{"text":"2"}, +{"text":"3"},{"text":"4"},{"text":"5"}, +{"text":"6"},{"text":"7"},{"text":"8"}, +{"text":"9"},{"text":"10"},{"text":"11"}, +{"text":"12"},{"text":"13"},{"text":"14"}, +{"text":"15"},{"text":"16"},{"text":"17"}, +{"text":"18"},{"text":"19"},{"text":"20"}, +{"text":"21"},{"text":"22"},{"text":"23"}, +{"text":"24"},{"text":"25"},{"text":"26"}, +{"text":"27"},{"text":"28"},{"text":"29"}]}` + +func TestIssue147(t *testing.T) { + var timeline Issue147; + Unmarshal(issue147Input, &timeline); + + for i, e := range timeline.Test { + if e.Text != strconv.Itoa(i) { + t.Errorf("index: %d got: %s want: %d", i, e.Text, i) + } + } +} |