aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/encoding
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2014-02-12 21:50:58 +0400
committerDmitriy Vyukov <dvyukov@google.com>2014-02-12 21:50:58 +0400
commit3b85f9b7e184be17c411152f6b010aa279a85dcf (patch)
tree3f32c59988c4800a5b168070a246bfe9fc983bdf /src/pkg/encoding
parent384f4380e8a4fee35ac5ba8449b9fd5cf0865069 (diff)
downloadgo-3b85f9b7e184be17c411152f6b010aa279a85dcf.tar.xz
encoding/json: fix test failure
$ go test -cpu=1,1,1,1,1,1,1,1,1 encoding/json --- FAIL: TestIndentBig (0.00 seconds) scanner_test.go:131: Indent(jsonBig) did not get bigger On 4-th run initBig generates an empty array. LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/49930051
Diffstat (limited to 'src/pkg/encoding')
-rw-r--r--src/pkg/encoding/json/scanner_test.go22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/pkg/encoding/json/scanner_test.go b/src/pkg/encoding/json/scanner_test.go
index 90e45ff036..7880342902 100644
--- a/src/pkg/encoding/json/scanner_test.go
+++ b/src/pkg/encoding/json/scanner_test.go
@@ -239,23 +239,16 @@ func trim(b []byte) []byte {
var jsonBig []byte
-const (
- big = 10000
- small = 100
-)
-
func initBig() {
- n := big
+ n := 10000
if testing.Short() {
- n = small
+ n = 100
}
- if len(jsonBig) != n {
- b, err := Marshal(genValue(n))
- if err != nil {
- panic(err)
- }
- jsonBig = b
+ b, err := Marshal(genValue(n))
+ if err != nil {
+ panic(err)
}
+ jsonBig = b
}
func genValue(n int) interface{} {
@@ -296,6 +289,9 @@ func genArray(n int) []interface{} {
if f > n {
f = n
}
+ if f < 1 {
+ f = 1
+ }
x := make([]interface{}, f)
for i := range x {
x[i] = genValue(((i+1)*n)/f - (i*n)/f)