diff options
Diffstat (limited to 'compat/json/borrowed_scanner_test.go')
-rw-r--r-- | compat/json/borrowed_scanner_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
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 |