aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2016-04-10 10:16:41 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2016-10-26 21:03:00 +0000
commit1625da24106b610f89ff7a67a11581df95f8e234 (patch)
tree4d83320fd39a407c7cd8a4c28f62a9003b2b494f /src/encoding/json/encode_test.go
parent587b80322c6ce34ab115d7a837a56d7450aa913d (diff)
downloadgo-1625da24106b610f89ff7a67a11581df95f8e234.tar.xz
encoding/json: marshal the RawMessage value type the same as its pointer type
Fixes #14493 Updates #6458 (changes its behavior) Change-Id: I851a8113fd312dae3384e989ec2b70949dc22838 Reviewed-on: https://go-review.googlesource.com/21811 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Quentin Smith <quentin@golang.org>
Diffstat (limited to 'src/encoding/json/encode_test.go')
-rw-r--r--src/encoding/json/encode_test.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/encoding/json/encode_test.go b/src/encoding/json/encode_test.go
index 13e765afa3..507581feed 100644
--- a/src/encoding/json/encode_test.go
+++ b/src/encoding/json/encode_test.go
@@ -440,7 +440,9 @@ func TestIssue6458(t *testing.T) {
t.Fatal(err)
}
- if want := `{"M":"ImZvbyI="}`; string(b) != want {
+ // Until Go 1.8, this generated `{"M":"ImZvbyI="}`.
+ // See https://github.com/golang/go/issues/14493#issuecomment-255857318
+ if want := `{"M":"foo"}`; string(b) != want {
t.Errorf("Marshal(x) = %#q; want %#q", b, want)
}
}
@@ -717,3 +719,14 @@ func TestMarshalFloat(t *testing.T) {
test(0, 32)
test(math.Copysign(0, -1), 32)
}
+
+func TestMarshalRawMessageValue(t *testing.T) {
+ const val = "\"some value\""
+ b, err := Marshal(RawMessage(val))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if string(b) != val {
+ t.Errorf("got %q; want %q", b, val)
+ }
+}