mirror of https://github.com/goccy/go-json.git
Fix test code for debug
This commit is contained in:
parent
75d7b8e673
commit
e0812246ef
|
@ -1786,15 +1786,16 @@ func equalError(a, b error) bool {
|
|||
|
||||
func TestUnmarshal(t *testing.T) {
|
||||
for i, tt := range unmarshalTests {
|
||||
t.Run(fmt.Sprintf("%d_%q", i, tt.in), func(t *testing.T) {
|
||||
in := []byte(tt.in)
|
||||
if tt.ptr == nil {
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
typ := reflect.TypeOf(tt.ptr)
|
||||
if typ.Kind() != reflect.Ptr {
|
||||
t.Errorf("#%d: unmarshalTest.ptr %T is not a pointer type", i, tt.ptr)
|
||||
continue
|
||||
return
|
||||
}
|
||||
typ = typ.Elem()
|
||||
|
||||
|
@ -1809,7 +1810,7 @@ func TestUnmarshal(t *testing.T) {
|
|||
// what they should. To test decoding into existing
|
||||
// data, see TestPrefilled.
|
||||
t.Errorf("#%d: unmarshalTest.ptr %#v is not a pointer to a zero value", i, tt.ptr)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(in))
|
||||
|
@ -1821,9 +1822,9 @@ func TestUnmarshal(t *testing.T) {
|
|||
}
|
||||
if err := dec.Decode(v.Interface()); !equalError(err, tt.err) {
|
||||
t.Errorf("#%d: %v, want %v", i, err, tt.err)
|
||||
continue
|
||||
return
|
||||
} else if err != nil {
|
||||
continue
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(v.Elem().Interface(), tt.out) {
|
||||
t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.Elem().Interface(), tt.out)
|
||||
|
@ -1831,7 +1832,7 @@ func TestUnmarshal(t *testing.T) {
|
|||
println(string(data))
|
||||
data, _ = json.Marshal(tt.out)
|
||||
println(string(data))
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
// Check round trip also decodes correctly.
|
||||
|
@ -1839,7 +1840,7 @@ func TestUnmarshal(t *testing.T) {
|
|||
enc, err := json.Marshal(v.Interface())
|
||||
if err != nil {
|
||||
t.Errorf("#%d: error re-marshaling: %v", i, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
if tt.golden && !bytes.Equal(enc, in) {
|
||||
t.Errorf("#%d: remarshal mismatch:\nhave: %s\nwant: %s", i, enc, in)
|
||||
|
@ -1851,15 +1852,16 @@ func TestUnmarshal(t *testing.T) {
|
|||
}
|
||||
if err := dec.Decode(vv.Interface()); err != nil {
|
||||
t.Errorf("#%d: error re-unmarshaling %#q: %v", i, enc, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(v.Elem().Interface(), vv.Elem().Interface()) {
|
||||
t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.Elem().Interface(), vv.Elem().Interface())
|
||||
t.Errorf(" In: %q", strings.Map(noSpace, string(in)))
|
||||
t.Errorf("Marshal: %q", strings.Map(noSpace, string(enc)))
|
||||
continue
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue