summaryrefslogtreecommitdiff
path: root/compat/json
diff options
context:
space:
mode:
Diffstat (limited to 'compat/json')
-rw-r--r--compat/json/borrowed_decode_test.go39
-rw-r--r--compat/json/borrowed_encode_test.go29
-rw-r--r--compat/json/borrowed_number_test.go1
-rw-r--r--compat/json/borrowed_scanner_test.go12
-rw-r--r--compat/json/borrowed_stream_test.go9
-rw-r--r--compat/json/borrowed_tagkey_test.go1
-rw-r--r--compat/json/borrowed_tags_test.go1
7 files changed, 92 insertions, 0 deletions
diff --git a/compat/json/borrowed_decode_test.go b/compat/json/borrowed_decode_test.go
index 38e2a1d..e08fa0a 100644
--- a/compat/json/borrowed_decode_test.go
+++ b/compat/json/borrowed_decode_test.go
@@ -985,6 +985,7 @@ var unmarshalTests = []unmarshalTest{
}
func TestMarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
b, err := Marshal(allValue)
if err != nil {
t.Fatalf("Marshal allValue: %v", err)
@@ -1018,6 +1019,7 @@ var badUTF8 = []struct {
}
func TestMarshalBadUTF8(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range badUTF8 {
b, err := Marshal(tt.in)
if string(b) != tt.out || err != nil {
@@ -1027,6 +1029,7 @@ func TestMarshalBadUTF8(t *testing.T) {
}
func TestMarshalNumberZeroVal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var n Number
out, err := Marshal(n)
if err != nil {
@@ -1039,6 +1042,7 @@ func TestMarshalNumberZeroVal(t *testing.T) {
}
func TestMarshalEmbeds(t *testing.T) {
+ t.Parallel() // MODIFIED: added
top := &Top{
Level0: 1,
Embed0: Embed0{
@@ -1091,6 +1095,7 @@ func equalError(a, b error) bool {
}
func TestUnmarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for i, tt := range unmarshalTests {
var scan scanner
in := []byte(tt.in)
@@ -1183,6 +1188,7 @@ func TestUnmarshal(t *testing.T) {
}
func TestUnmarshalMarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
initBig()
var v any
if err := Unmarshal(jsonBig, &v); err != nil {
@@ -1213,6 +1219,7 @@ var numberTests = []struct {
// Independent of Decode, basic coverage of the accessors in Number
func TestNumberAccessors(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range numberTests {
n := Number(tt.in)
if s := n.String(); s != tt.in {
@@ -1232,6 +1239,7 @@ func TestNumberAccessors(t *testing.T) {
}
func TestLargeByteSlice(t *testing.T) {
+ t.Parallel() // MODIFIED: added
s0 := make([]byte, 2000)
for i := range s0 {
s0[i] = byte(i)
@@ -1255,6 +1263,7 @@ type Xint struct {
}
func TestUnmarshalInterface(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var xint Xint
var i any = &xint
if err := Unmarshal([]byte(`{"X":1}`), &i); err != nil {
@@ -1266,6 +1275,7 @@ func TestUnmarshalInterface(t *testing.T) {
}
func TestUnmarshalPtrPtr(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var xint Xint
pxint := &xint
if err := Unmarshal([]byte(`{"X":1}`), &pxint); err != nil {
@@ -1277,6 +1287,7 @@ func TestUnmarshalPtrPtr(t *testing.T) {
}
func TestEscape(t *testing.T) {
+ t.Parallel() // MODIFIED: added
const input = `"foobar"<html>` + " [\u2028 \u2029]"
const expected = `"\"foobar\"\u003chtml\u003e [\u2028 \u2029]"`
b, err := Marshal(input)
@@ -1309,6 +1320,7 @@ var wrongStringTests = []wrongStringTest{
// If people misuse the ,string modifier, the error message should be
// helpful, telling the user that they're doing it wrong.
func TestErrorMessageFromMisusedString(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for n, tt := range wrongStringTests {
r := strings.NewReader(tt.in)
var s WrongString
@@ -1646,6 +1658,7 @@ var pallValueIndent = `{
var pallValueCompact = strings.Map(noSpace, pallValueIndent)
func TestRefUnmarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type S struct {
// Ref is defined in encode_test.go.
R0 Ref
@@ -1674,6 +1687,7 @@ func TestRefUnmarshal(t *testing.T) {
// Test that the empty string doesn't panic decoding when ,string is specified
// Issue 3450
func TestEmptyString(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type T2 struct {
Number1 int `json:",string"`
Number2 int `json:",string"`
@@ -1693,6 +1707,7 @@ func TestEmptyString(t *testing.T) {
// Test that a null for ,string is not replaced with the previous quoted string (issue 7046).
// It should also not be an error (issue 2540, issue 8587).
func TestNullString(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type T struct {
A int `json:",string"`
B int `json:",string"`
@@ -1745,6 +1760,7 @@ var interfaceSetTests = []struct {
}
func TestInterfaceSet(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range interfaceSetTests {
b := struct{ X any }{tt.pre}
blob := `{"X":` + tt.json + `}`
@@ -1796,6 +1812,7 @@ type NullTest struct {
// JSON null values should be ignored for primitives and string values instead of resulting in an error.
// Issue 2540
func TestUnmarshalNulls(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// Unmarshal docs:
// The JSON null value unmarshals into an interface, map, pointer, or slice
// by setting that Go value to nil. Because null is often used in JSON to mean
@@ -1931,6 +1948,7 @@ func (x MustNotUnmarshalText) UnmarshalText(text []byte) error {
}
func TestStringKind(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type stringKind string
var m1, m2 map[stringKind]int
@@ -1957,6 +1975,7 @@ func TestStringKind(t *testing.T) {
// and then unmarshaled.
// Issue 8962.
func TestByteKind(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type byteKind []byte
a := byteKind("hello")
@@ -1981,6 +2000,7 @@ func TestByteKind(t *testing.T) {
// The fix for issue 8962 introduced a regression.
// Issue 12921.
func TestSliceOfCustomByte(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type Uint8 uint8
a := []Uint8("hello")
@@ -2015,6 +2035,7 @@ var decodeTypeErrorTests = []struct {
}
func TestUnmarshalTypeError(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, item := range decodeTypeErrorTests {
err := Unmarshal([]byte(item.src), item.dest)
if _, ok := err.(*UnmarshalTypeError); !ok {
@@ -2036,6 +2057,7 @@ var unmarshalSyntaxTests = []string{
}
func TestUnmarshalSyntax(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var x any
for _, src := range unmarshalSyntaxTests {
err := Unmarshal([]byte(src), &x)
@@ -2056,6 +2078,7 @@ type unexportedFields struct {
}
func TestUnmarshalUnexported(t *testing.T) {
+ t.Parallel() // MODIFIED: added
input := `{"Name": "Bob", "m": {"x": 123}, "m2": {"y": 456}, "abcd": {"z": 789}, "s": [2, 3]}`
want := &unexportedFields{Name: "Bob"}
@@ -2086,6 +2109,7 @@ func (t *Time3339) UnmarshalJSON(b []byte) error {
}
func TestUnmarshalJSONLiteralError(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var t3 Time3339
err := Unmarshal([]byte(`"0000-00-00T00:00:00Z"`), &t3)
if err == nil {
@@ -2100,6 +2124,7 @@ func TestUnmarshalJSONLiteralError(t *testing.T) {
// "data changing underfoot" error.
// Issue 3717
func TestSkipArrayObjects(t *testing.T) {
+ t.Parallel() // MODIFIED: added
json := `[{}]`
var dest [0]any
@@ -2113,6 +2138,7 @@ func TestSkipArrayObjects(t *testing.T) {
// slices, and arrays.
// Issues 4900 and 8837, among others.
func TestPrefilled(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// Values here change, cannot reuse table across runs.
var prefillTests = []struct {
in string
@@ -2173,6 +2199,7 @@ var invalidUnmarshalTests = []struct {
}
func TestInvalidUnmarshal(t *testing.T) {
+ t.Parallel() // MODIFIED: added
buf := []byte(`{"a":"1"}`)
for _, tt := range invalidUnmarshalTests {
err := Unmarshal(buf, tt.v)
@@ -2197,6 +2224,7 @@ var invalidUnmarshalTextTests = []struct {
}
func TestInvalidUnmarshalText(t *testing.T) {
+ t.Parallel() // MODIFIED: added
buf := []byte(`123`)
for _, tt := range invalidUnmarshalTextTests {
err := Unmarshal(buf, tt.v)
@@ -2213,6 +2241,7 @@ func TestInvalidUnmarshalText(t *testing.T) {
// Test that string option is ignored for invalid types.
// Issue 9812.
func TestInvalidStringOption(t *testing.T) {
+ t.Parallel() // MODIFIED: added
num := 0
item := struct {
T time.Time `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
@@ -2245,6 +2274,7 @@ func TestInvalidStringOption(t *testing.T) {
// (Issue 28145) If the embedded struct is given an explicit name and has
// exported methods, don't cause a panic trying to get its value.
func TestUnmarshalEmbeddedUnexported(t *testing.T) {
+ t.Parallel() // MODIFIED: added
type (
embed1 struct{ Q int }
embed2 struct{ Q int }
@@ -2366,6 +2396,7 @@ func TestUnmarshalEmbeddedUnexported(t *testing.T) {
}
func TestUnmarshalErrorAfterMultipleJSON(t *testing.T) {
+ t.Parallel() // MODIFIED: added
tests := []struct {
in string
err error
@@ -2405,6 +2436,7 @@ type unmarshalPanic struct{}
func (unmarshalPanic) UnmarshalJSON([]byte) error { panic(0xdead) }
func TestUnmarshalPanic(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)
@@ -2417,6 +2449,7 @@ func TestUnmarshalPanic(t *testing.T) {
// The decoder used to hang if decoding into an interface pointing to its own address.
// See golang.org/issues/31740.
func TestUnmarshalRecursivePointer(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var v any
v = &v
data := []byte(`{"a": "b"}`)
@@ -2436,6 +2469,7 @@ func (m *textUnmarshalerString) UnmarshalText(text []byte) error {
// Test unmarshal to a map, where the map key is a user defined type.
// See golang.org/issues/34437.
func TestUnmarshalMapWithTextUnmarshalerStringKey(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var p map[textUnmarshalerString]string
if err := Unmarshal([]byte(`{"FOO": "1"}`), &p); err != nil {
t.Fatalf("Unmarshal unexpected error: %v", err)
@@ -2447,6 +2481,7 @@ func TestUnmarshalMapWithTextUnmarshalerStringKey(t *testing.T) {
}
func TestUnmarshalRescanLiteralMangledUnquote(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// See golang.org/issues/38105.
var p map[textUnmarshalerString]string
if err := Unmarshal([]byte(`{"开源":"12345开源"}`), &p); err != nil {
@@ -2492,6 +2527,7 @@ func TestUnmarshalRescanLiteralMangledUnquote(t *testing.T) {
}
func TestUnmarshalMaxDepth(t *testing.T) {
+ t.Parallel() // MODIFIED: added
testcases := []struct {
name string
data string
@@ -2568,8 +2604,11 @@ func TestUnmarshalMaxDepth(t *testing.T) {
}
for _, tc := range testcases {
+ tc := tc // MODIFIED: added
for _, target := range targets {
+ target := target // MODIFIED: added
t.Run(target.name+"-"+tc.name, func(t *testing.T) {
+ t.Parallel() // MODIFIED: added
err := Unmarshal([]byte(tc.data), target.newValue())
if !tc.errMaxDepth {
if err != nil {
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"
diff --git a/compat/json/borrowed_number_test.go b/compat/json/borrowed_number_test.go
index f18f74e..e7819c6 100644
--- a/compat/json/borrowed_number_test.go
+++ b/compat/json/borrowed_number_test.go
@@ -12,6 +12,7 @@ import (
)
func TestNumberIsValid(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// From: https://stackoverflow.com/a/13340826
var jsonNumberRegexp = regexp.MustCompile(`^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$`)
diff --git a/compat/json/borrowed_scanner_test.go b/compat/json/borrowed_scanner_test.go
index 64d3318..c68fd8f 100644
--- a/compat/json/borrowed_scanner_test.go
+++ b/compat/json/borrowed_scanner_test.go
@@ -11,6 +11,7 @@ import (
"math"
"math/rand"
"reflect"
+ "sync" // MODIFIED: added
"testing"
)
@@ -27,6 +28,7 @@ var validTests = []struct {
}
func TestValid(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range validTests {
if ok := Valid([]byte(tt.data)); ok != tt.ok {
t.Errorf("Valid(%#q) = %v, want %v", tt.data, ok, tt.ok)
@@ -67,6 +69,7 @@ var ex1i = `[
]`
func TestCompact(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var buf bytes.Buffer
for _, tt := range examples {
buf.Reset()
@@ -87,6 +90,7 @@ func TestCompact(t *testing.T) {
}
func TestCompactSeparators(t *testing.T) {
+ t.Parallel() // MODIFIED: added
// U+2028 and U+2029 should be escaped inside strings.
// They should not appear outside strings.
tests := []struct {
@@ -106,6 +110,7 @@ func TestCompactSeparators(t *testing.T) {
}
func TestIndent(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var buf bytes.Buffer
for _, tt := range examples {
buf.Reset()
@@ -128,6 +133,7 @@ func TestIndent(t *testing.T) {
// Tests of a large random structure.
func TestCompactBig(t *testing.T) {
+ t.Parallel() // MODIFIED: added
initBig()
var buf bytes.Buffer
if err := Compact(&buf, jsonBig); err != nil {
@@ -191,6 +197,7 @@ var indentErrorTests = []indentErrorTest{
}
func TestIndentErrors(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for i, tt := range indentErrorTests {
slice := make([]uint8, 0)
buf := bytes.NewBuffer(slice)
@@ -227,7 +234,12 @@ func trim(b []byte) []byte {
var jsonBig []byte
+var jsonBigOnce sync.Once
+
func initBig() {
+ jsonBigOnce.Do(realInitBig) // MODIFIED: added
+} // MODIFIED: added
+func realInitBig() { // MODIFIED: added
n := 10000
if testing.Short() {
n = 100
diff --git a/compat/json/borrowed_stream_test.go b/compat/json/borrowed_stream_test.go
index 80f6f03..6c3a403 100644
--- a/compat/json/borrowed_stream_test.go
+++ b/compat/json/borrowed_stream_test.go
@@ -41,6 +41,7 @@ false
`
func TestEncoder(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for i := 0; i <= len(streamTest); i++ {
var buf bytes.Buffer
enc := NewEncoder(&buf)
@@ -78,6 +79,7 @@ false
`
func TestEncoderIndent(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var buf bytes.Buffer
enc := NewEncoder(&buf)
enc.SetIndent(">", ".")
@@ -105,6 +107,7 @@ func (s *strPtrMarshaler) MarshalJSON() ([]byte, error) {
}
func TestEncoderSetEscapeHTML(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var c C
var ct CText
var tagStruct struct {
@@ -173,6 +176,7 @@ func TestEncoderSetEscapeHTML(t *testing.T) {
}
func TestDecoder(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for i := 0; i <= len(streamTest); i++ {
// Use stream without newlines as input,
// just to stress the decoder even more.
@@ -205,6 +209,7 @@ func TestDecoder(t *testing.T) {
}
func TestDecoderBuffered(t *testing.T) {
+ t.Parallel() // MODIFIED: added
r := strings.NewReader(`{"Name": "Gopher"} extra `)
var m struct {
Name string
@@ -241,6 +246,7 @@ func nlines(s string, n int) string {
}
func TestRawMessage(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var data struct {
X float64
Id RawMessage
@@ -265,6 +271,7 @@ func TestRawMessage(t *testing.T) {
}
func TestNullRawMessage(t *testing.T) {
+ t.Parallel() // MODIFIED: added
var data struct {
X float64
Id RawMessage
@@ -297,6 +304,7 @@ var blockingTests = []string{
}
func TestBlocking(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, enc := range blockingTests {
r, w := net.Pipe()
ch := make(chan error) // MODIFIED: added
@@ -451,6 +459,7 @@ func TestDecodeInStream(t *testing.T) {
// Test from golang.org/issue/11893
func TestHTTPDecoding(t *testing.T) {
+ t.Parallel() // MODIFIED: added
const raw = `{ "foo": "bar" }`
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/compat/json/borrowed_tagkey_test.go b/compat/json/borrowed_tagkey_test.go
index d48cc67..07139cf 100644
--- a/compat/json/borrowed_tagkey_test.go
+++ b/compat/json/borrowed_tagkey_test.go
@@ -99,6 +99,7 @@ var structTagObjectKeyTests = []struct {
}
func TestStructTagObjectKey(t *testing.T) {
+ t.Parallel() // MODIFIED: added
for _, tt := range structTagObjectKeyTests {
b, err := Marshal(tt.raw)
if err != nil {
diff --git a/compat/json/borrowed_tags_test.go b/compat/json/borrowed_tags_test.go
index 71d26e1..e48df0a 100644
--- a/compat/json/borrowed_tags_test.go
+++ b/compat/json/borrowed_tags_test.go
@@ -11,6 +11,7 @@ import (
)
func TestTagParsing(t *testing.T) {
+ t.Parallel() // MODIFIED: added
name, opts := parseTag("field,foobar,foo")
if name != "field" {
t.Fatalf("name = %q, want field", name)