Commit 4d06dbda authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: reduce alloc-heavy init

Moves test cases into the test where they're used, to remove
distractions when profiling unrelated tests.

Also this is my style preference, to remove globals and reduce the
scope of variables.

Change-Id: Ie9cd41b16aad9acf5e210f1fb6f19a7fce52180d
Reviewed-on: https://go-review.googlesource.com/20996Reviewed-by: 's avatarAndrew Gerrand <adg@golang.org>
parent 9d8ef8d7
...@@ -326,28 +326,28 @@ func randString(n int) string { ...@@ -326,28 +326,28 @@ func randString(n int) string {
return string(b) return string(b)
} }
var bodyTests = []struct {
body string
noContentLen bool
}{
{body: "some message"},
{body: "some message", noContentLen: true},
{body: ""},
{body: "", noContentLen: true},
{body: strings.Repeat("a", 1<<20), noContentLen: true},
{body: strings.Repeat("a", 1<<20)},
{body: randString(16<<10 - 1)},
{body: randString(16 << 10)},
{body: randString(16<<10 + 1)},
{body: randString(512<<10 - 1)},
{body: randString(512 << 10)},
{body: randString(512<<10 + 1)},
{body: randString(1<<20 - 1)},
{body: randString(1 << 20)},
{body: randString(1<<20 + 2)},
}
func TestTransportBody(t *testing.T) { func TestTransportBody(t *testing.T) {
bodyTests := []struct {
body string
noContentLen bool
}{
{body: "some message"},
{body: "some message", noContentLen: true},
{body: ""},
{body: "", noContentLen: true},
{body: strings.Repeat("a", 1<<20), noContentLen: true},
{body: strings.Repeat("a", 1<<20)},
{body: randString(16<<10 - 1)},
{body: randString(16 << 10)},
{body: randString(16<<10 + 1)},
{body: randString(512<<10 - 1)},
{body: randString(512 << 10)},
{body: randString(512<<10 + 1)},
{body: randString(1<<20 - 1)},
{body: randString(1 << 20)},
{body: randString(1<<20 + 2)},
}
type reqInfo struct { type reqInfo struct {
req *http.Request req *http.Request
slurp []byte slurp []byte
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment