Merge pull request #90 from goccy/feature/coverage

Add test cases for unsigned integer types
This commit is contained in:
Masaaki Goshima 2021-01-19 15:03:10 +09:00 committed by GitHub
commit 8578b68bf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 16875 additions and 1372 deletions

View File

@ -1,5 +1,10 @@
package json_test
import (
"bytes"
stdjson "encoding/json"
)
func intptr(v int) *int { return &v }
func int8ptr(v int8) *int8 { return &v }
func int16ptr(v int16) *int16 { return &v }
@ -13,3 +18,14 @@ func uint64ptr(v uint64) *uint64 { return &v }
func float32ptr(v float32) *float32 { return &v }
func float64ptr(v float64) *float64 { return &v }
func stringptr(v string) *string { return &v }
func encodeByEncodingJSON(data interface{}, indent, escape bool) string {
var buf bytes.Buffer
enc := stdjson.NewEncoder(&buf)
enc.SetEscapeHTML(escape)
if indent {
enc.SetIndent("", " ")
}
enc.Encode(data)
return buf.String()
}

View File

@ -2922,6 +2922,10 @@ null
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
if indent {
got := "\n" + buf.String()
if got != test.indentExpected {

View File

@ -2922,6 +2922,10 @@ null
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
if indent {
got := "\n" + buf.String()
if got != test.indentExpected {

View File

@ -2922,6 +2922,10 @@ null
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
if indent {
got := "\n" + buf.String()
if got != test.indentExpected {

View File

@ -2922,6 +2922,10 @@ null
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
if indent {
got := "\n" + buf.String()
if got != test.indentExpected {

View File

@ -2922,6 +2922,10 @@ null
if err := enc.Encode(test.data); err != nil {
t.Fatalf("%s(htmlEscape:%T): %s: %s", test.name, htmlEscape, test.expected, err)
}
stdresult := encodeByEncodingJSON(test.data, indent, htmlEscape)
if buf.String() != stdresult {
t.Errorf("%s(htmlEscape:%T): doesn't compatible with encoding/json. expected %q but got %q", test.name, htmlEscape, stdresult, buf.String())
}
if indent {
got := "\n" + buf.String()
if got != test.indentExpected {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff