Skip to content

Commit a56f5a0

Browse files
klauspostbradfitz
authored andcommitted
compress/flate: improve short writer error test
This improves the short version of the writer test. First of all, it has a much quicker setup. Previously that could take up towards 0.5 second. Secondly, it will test all compression levels in short mode as well. Execution time is 1.7s/0.03s for normal/short mode. Change-Id: I275a21f712daff6f7125cc6a493415e86439cb19 Reviewed-on: https://go-review.googlesource.com/21800 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent f20b180 commit a56f5a0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/compress/flate/writer_test.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@ func (e *errorWriter) Write(b []byte) (int, error) {
8686
// Test if errors from the underlying writer is passed upwards.
8787
func TestWriteError(t *testing.T) {
8888
buf := new(bytes.Buffer)
89-
for i := 0; i < 1024*1024; i++ {
89+
n := 65536
90+
if !testing.Short() {
91+
n *= 4
92+
}
93+
for i := 0; i < n; i++ {
9094
buf.WriteString(fmt.Sprintf("asdasfasf%d%dfghfgujyut%dyutyu\n", i, i, i))
9195
}
9296
in := buf.Bytes()
9397
// We create our own buffer to control number of writes.
94-
copyBuffer := make([]byte, 1024)
98+
copyBuffer := make([]byte, 128)
9599
for l := 0; l < 10; l++ {
96-
for fail := 1; fail <= 512; fail *= 2 {
100+
for fail := 1; fail <= 256; fail *= 2 {
97101
// Fail after 'fail' writes
98102
ew := &errorWriter{N: fail}
99103
w, err := NewWriter(ew, l)

0 commit comments

Comments
 (0)