Fix int overflow in test on 32-bit.
On 32-bit systems, the random array indexes were sometimes negative as a result of converting an int64 to int. Fixes #7.
This commit is contained in:
parent
71eb68cc46
commit
ed0fd64940
|
@ -308,7 +308,7 @@ func TestQuality(t *testing.T) {
|
|||
func TestDecodeFuzz(t *testing.T) {
|
||||
// Test that the decoder terminates with corrupted input.
|
||||
content := bytes.Repeat([]byte("hello world!"), 100)
|
||||
src := rand.NewSource(0)
|
||||
rnd := rand.New(rand.NewSource(0))
|
||||
encoded, err := Encode(content, WriterOptions{Quality: 5})
|
||||
if err != nil {
|
||||
t.Fatalf("Encode(<%d bytes>, _) = _, %s", len(content), err)
|
||||
|
@ -319,7 +319,7 @@ func TestDecodeFuzz(t *testing.T) {
|
|||
for i := 0; i < 100; i++ {
|
||||
enc := append([]byte{}, encoded...)
|
||||
for j := 0; j < 5; j++ {
|
||||
enc[int(src.Int63())%len(enc)] = byte(src.Int63() % 256)
|
||||
enc[rnd.Intn(len(enc))] = byte(rnd.Intn(256))
|
||||
}
|
||||
Decode(enc)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue