From adb9d60cd1f6ff88628bbe6124969faa4f51d346 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Tue, 26 Mar 2013 16:20:17 +1100 Subject: [PATCH] image/gif: make test repeatable Fixes issue with go test -cpu=1,1 R=minux.ma, bradfitz, nigeltao CC=golang-dev https://golang.org/cl/7808045 --- src/pkg/image/gif/reader_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pkg/image/gif/reader_test.go b/src/pkg/image/gif/reader_test.go index a035ef1ea5..dcc6c6dd3e 100644 --- a/src/pkg/image/gif/reader_test.go +++ b/src/pkg/image/gif/reader_test.go @@ -114,22 +114,25 @@ func try(t *testing.T, b []byte, want string) { } func TestBounds(t *testing.T) { + // make a local copy of testGIF + gif := make([]byte, len(testGIF)) + copy(gif, testGIF) // Make the bounds too big, just by one. - testGIF[32] = 2 + gif[32] = 2 want := "gif: frame bounds larger than image bounds" - try(t, testGIF, want) + try(t, gif, want) // Make the bounds too small; does not trigger bounds // check, but now there's too much data. - testGIF[32] = 0 + gif[32] = 0 want = "gif: too much image data" - try(t, testGIF, want) - testGIF[32] = 1 + try(t, gif, want) + gif[32] = 1 // Make the bounds really big, expect an error. want = "gif: frame bounds larger than image bounds" for i := 0; i < 4; i++ { - testGIF[32+i] = 0xff + gif[32+i] = 0xff } - try(t, testGIF, want) + try(t, gif, want) } -- 2.50.0