1
0
mirror of https://github.com/golang/go synced 2024-11-06 10:36:13 -07:00

encoding/gob: delete out of memory test

Now that the library allows much larger data, it can kill
machines with less memory.

Fixes #28321

Change-Id: I98e1a5fdf812fd75adfb22bf01542423de405fe2
Reviewed-on: https://go-review.googlesource.com/c/143817
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Rob Pike 2018-10-23 07:01:35 +11:00
parent 553237aa67
commit 956af97880

View File

@ -10,7 +10,6 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"reflect" "reflect"
"runtime"
"strings" "strings"
"testing" "testing"
) )
@ -1128,24 +1127,3 @@ func TestBadData(t *testing.T) {
} }
} }
} }
// TestHugeWriteFails tests that enormous messages trigger an error.
func TestHugeWriteFails(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("out of memory on wasm")
}
if testing.Short() {
// Requires allocating a monster, so don't do this from all.bash.
t.Skip("skipping huge allocation in short mode")
}
huge := make([]byte, tooBig)
huge[0] = 7 // Make sure it's not all zeros.
buf := new(bytes.Buffer)
err := NewEncoder(buf).Encode(huge)
if err == nil {
t.Fatalf("expected error for huge slice")
}
if !strings.Contains(err.Error(), "message too big") {
t.Fatalf("expected 'too big' error; got %s\n", err.Error())
}
}