aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding/json/decode_test.go
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2012-02-03 11:15:06 +1100
committerDavid Symonds <dsymonds@golang.org>2012-02-03 11:15:06 +1100
commitbf89d58e738a492012ee67af0ab57b0a322dea0b (patch)
tree3c8cd00e36035d7a81c7e8639b3102ad44dc4eca /src/pkg/encoding/json/decode_test.go
parent102638cb53c0f34d5710ee7f5f13f27b95840640 (diff)
downloadgo-bf89d58e738a492012ee67af0ab57b0a322dea0b.tar.xz
encoding/json: call (*T).MarshalJSON for addressable T values.
Fixes #2170. R=golang-dev, cw, adg CC=golang-dev https://golang.org/cl/5618045
Diffstat (limited to 'src/pkg/encoding/json/decode_test.go')
-rw-r--r--src/pkg/encoding/json/decode_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/pkg/encoding/json/decode_test.go b/src/pkg/encoding/json/decode_test.go
index cc3103f032..775becfa7c 100644
--- a/src/pkg/encoding/json/decode_test.go
+++ b/src/pkg/encoding/json/decode_test.go
@@ -598,3 +598,24 @@ var pallValueIndent = `{
}`
var pallValueCompact = strings.Map(noSpace, pallValueIndent)
+
+func TestRefUnmarshal(t *testing.T) {
+ type S struct {
+ // Ref is defined in encode_test.go.
+ R0 Ref
+ R1 *Ref
+ }
+ want := S{
+ R0: 12,
+ R1: new(Ref),
+ }
+ *want.R1 = 12
+
+ var got S
+ if err := Unmarshal([]byte(`{"R0":"ref","R1":"ref"}`), &got); err != nil {
+ t.Fatalf("Unmarshal: %v", err)
+ }
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("got %+v, want %+v", got, want)
+ }
+}