summaryrefslogtreecommitdiff
path: root/compat/json/borrowed_encode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'compat/json/borrowed_encode_test.go')
-rw-r--r--compat/json/borrowed_encode_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/compat/json/borrowed_encode_test.go b/compat/json/borrowed_encode_test.go
index 2b14032..3d5d675 100644
--- a/compat/json/borrowed_encode_test.go
+++ b/compat/json/borrowed_encode_test.go
@@ -59,6 +59,7 @@ var optionalsExpected = `{
}`
func TestOmitEmpty(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var o Optionals
o.Sw = "something"
o.Mr = map[string]any{}
@@ -82,6 +83,7 @@ type StringTag struct {
}
func TestRoundtripStringTag(t *testing.T) {
+ t.Parallel() // MODIFIED: added
tests := []struct {
name string
in StringTag
@@ -121,7 +123,9 @@ func TestRoundtripStringTag(t *testing.T) {
},
}
for _, test := range tests {
+ test := test // MODIFIED: added
t.Run(test.name, func(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// Indent with a tab prefix to make the multi-line string
// literals in the table nicer to read.
got, err := MarshalIndent(&test.in, "\t\t\t", "\t")
@@ -150,6 +154,7 @@ type renamedByteSlice []byte
type renamedRenamedByteSlice []renamedByte
func TestEncodeRenamedByteSlice(t *testing.T) {
+ t.Parallel() // MODIFIED: added
s := renamedByteSlice("abc")
result, err := Marshal(s)
if err != nil {
@@ -213,12 +218,14 @@ func init() {
}
func TestSamePointerNoCycle(t *testing.T) {
+ t.Parallel() // MODIFIED: added
if _, err := Marshal(samePointerNoCycle); err != nil {
t.Fatalf("unexpected error: %v", err)
}
}
func TestSliceNoCycle(t *testing.T) {
+ t.Parallel() // MODIFIED: added
if _, err := Marshal(sliceNoCycle); err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -236,6 +243,7 @@ var unsupportedValues = []any{
}
func TestUnsupportedValues(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, v := range unsupportedValues {
if _, err := Marshal(v); err != nil {
if _, ok := err.(*UnsupportedValueError); !ok {
@@ -249,6 +257,7 @@ func TestUnsupportedValues(t *testing.T) {
// Issue 43207
func TestMarshalTextFloatMap(t *testing.T) {
+ t.Parallel() // MODIFIED: added
m := map[textfloat]string{
textfloat(math.NaN()): "1",
textfloat(math.NaN()): "1",
@@ -302,6 +311,7 @@ func (ValText) MarshalText() ([]byte, error) {
}
func TestRefValMarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var s = struct {
R0 Ref
R1 *Ref
@@ -346,6 +356,7 @@ func (CText) MarshalText() ([]byte, error) {
}
func TestMarshalerEscaping(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var c C
want := `"\u003c\u0026\u003e"`
b, err := Marshal(c)
@@ -368,6 +379,7 @@ func TestMarshalerEscaping(t *testing.T) {
}
func TestAnonymousFields(t *testing.T) {
+ t.Parallel() // MODIFIED: added
tests := []struct {
label string // Test name
makeInput func() any // Function to create input value
@@ -532,7 +544,9 @@ func TestAnonymousFields(t *testing.T) {
}}
for _, tt := range tests {
+ tt := tt // MODIFIED: added
t.Run(tt.label, func(t *testing.T) {
+ t.Parallel() // MODIFIED: added
b, err := Marshal(tt.makeInput())
if err != nil {
t.Fatalf("Marshal() = %v, want nil error", err)
@@ -590,6 +604,7 @@ func (nm *nilTextMarshaler) MarshalText() ([]byte, error) {
// See golang.org/issue/16042 and golang.org/issue/34235.
func TestNilMarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
testCases := []struct {
v any
want string
@@ -620,6 +635,7 @@ func TestNilMarshal(t *testing.T) {
// Issue 5245.
func TestEmbeddedBug(t *testing.T) {
+ t.Parallel() // MODIFIED: added
v := BugB{
BugA{"A"},
"B",
@@ -660,6 +676,7 @@ type BugY struct {
// Test that a field with a tag dominates untagged fields.
func TestTaggedFieldDominates(t *testing.T) {
+ t.Parallel() // MODIFIED: added
v := BugY{
BugA{"BugA"},
BugD{"BugD"},
@@ -683,6 +700,7 @@ type BugZ struct {
}
func TestDuplicatedFieldDisappears(t *testing.T) {
+ t.Parallel() // MODIFIED: added
v := BugZ{
BugA{"BugA"},
BugC{"BugC"},
@@ -751,6 +769,7 @@ func TestStringBytes(t *testing.T) {
}
func TestIssue10281(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type Foo struct {
N Number
}
@@ -763,6 +782,7 @@ func TestIssue10281(t *testing.T) {
}
func TestHTMLEscape(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var b, want bytes.Buffer
m := `{"M":"<html>foo &` + "\xe2\x80\xa8 \xe2\x80\xa9" + `</html>"}`
want.Write([]byte(`{"M":"\u003chtml\u003efoo \u0026\u2028 \u2029\u003c/html\u003e"}`))
@@ -774,6 +794,7 @@ func TestHTMLEscape(t *testing.T) {
// golang.org/issue/8582
func TestEncodePointerString(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type stringPointer struct {
N *int64 `json:"n,string"`
}
@@ -837,6 +858,7 @@ var encodeStringTests = []struct {
}
func TestEncodeString(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range encodeStringTests {
b, err := Marshal(tt.in)
if err != nil {
@@ -878,6 +900,7 @@ func (f textfloat) MarshalText() ([]byte, error) { return tenc(`TF:%0.2f`, f) }
// Issue 13783
func TestEncodeBytekind(t *testing.T) {
+ t.Parallel() // MODIFIED: added
testdata := []struct {
data any
want string
@@ -910,6 +933,7 @@ func TestEncodeBytekind(t *testing.T) {
}
func TestTextMarshalerMapKeysAreSorted(t *testing.T) {
+ t.Parallel() // MODIFIED: added
b, err := Marshal(map[unmarshalerText]int{
{"x", "y"}: 1,
{"y", "x"}: 2,
@@ -927,6 +951,7 @@ func TestTextMarshalerMapKeysAreSorted(t *testing.T) {
// https://golang.org/issue/33675
func TestNilMarshalerTextMapKey(t *testing.T) {
+ t.Parallel() // MODIFIED: added
b, err := Marshal(map[*unmarshalerText]int{
(*unmarshalerText)(nil): 1,
{"A", "B"}: 2,
@@ -1048,6 +1073,7 @@ func TestMarshalFloat(t *testing.T) {
}
func TestMarshalRawMessageValue(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type (
T1 struct {
M RawMessage `json:",omitempty"`
@@ -1153,6 +1179,7 @@ type marshalPanic struct{}
func (marshalPanic) MarshalJSON() ([]byte, error) { panic(0xdead) }
func TestMarshalPanic(t *testing.T) {
+ t.Parallel() // MODIFIED: added
defer func() {
if got := recover(); !reflect.DeepEqual(got, 0xdead) {
t.Errorf("panic() = (%T)(%v), want 0xdead", got, got)
@@ -1163,6 +1190,7 @@ func TestMarshalPanic(t *testing.T) {
}
func TestMarshalUncommonFieldNames(t *testing.T) {
+ t.Parallel() // MODIFIED: added
v := struct {
A0, À, Aβ int
}{}
@@ -1178,6 +1206,7 @@ func TestMarshalUncommonFieldNames(t *testing.T) {
}
func TestMarshalerError(t *testing.T) {
+ t.Parallel() // MODIFIED: added
s := "test variable"
st := reflect.TypeOf(s)
errText := "json: test error"