Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(388)

Unified Diff: src/pkg/encoding/json/decode_test.go

Issue 6938045: code review 6938045: encoding/json: fix type assertion in error path (Closed)
Patch Set: diff -r 7e135713451d https://code.google.com/p/go Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/encoding/json/decode.go ('k') | src/pkg/encoding/json/encode.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/encoding/json/decode_test.go
===================================================================
--- a/src/pkg/encoding/json/decode_test.go
+++ b/src/pkg/encoding/json/decode_test.go
@@ -6,6 +6,7 @@
import (
"bytes"
+ "errors"
"fmt"
"image"
"reflect"
@@ -547,6 +548,22 @@
}
}
+// issue 4222
+func TestDecodeErrorTypeAssertion(t *testing.T) {
+ err := errors.New("boom")
+ err_json, e0 := Marshal(err)
+ if e0 != nil {
+ t.Error(e0)
+ }
+ var err2 error
+ if e1 := Unmarshal(err_json, &err2); e1 == nil {
+ t.Errorf("expected %s, received: %v",
+ "reflect.Set: value of type map[string]interface {} is not assignable to type error",
+ e1,
+ )
+ }
+}
+
func noSpace(c rune) rune {
if isSpace(c) {
return -1
« no previous file with comments | « src/pkg/encoding/json/decode.go ('k') | src/pkg/encoding/json/encode.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b