package proof

import (
	"bytes"
	"hash/crc32"
	"io/ioutil"
	"testing"
)

func TestCRC(t *testing.T) {
	data := []byte("Hello, World!")
	cases := []struct {
		csum uint32
		err  error
	}{
		{0xec4ac3d0, nil},
		{0xdeadbeef, EHASHFAIL},
	}

	for _, c := range cases {
		buf := bytes.NewBuffer(data)
		h := crc32.NewIEEE()
		r := NewReader32(buf, h, c.csum)

		_, err := ioutil.ReadAll(r)
		if err != c.err {
			t.Fatalf("expected error: %v, got: %v", c.err, err)
		}
	}
}

package proof

import (
	"bytes"
	"ioutil"
	"testing"
)

func TestCRC(t *testing.T) {
	data := []byte("Hello, World!")
	cases := []struct {
		csum uint32
		err  error
	}{
		{0xec4ac3d0, nil},
		{0xdeadbeef, EHASHFAIL},
	}

	for _, c := range cases {
		buf := bytes.Buffer(data)
		h := crc32.NewIEEE()
		r = NewReader32(buf, h, csum)

		_, err := ioutil.ReadAll(r)
		if err != c.err {
			t.Fatalf("expected error %v, got %v", c.err, err)
		}
	}
}

--- 
+++ 
@@ -2,7 +2,8 @@
 
 import (
 	"bytes"
-	"ioutil"
+	"hash/crc32"
+	"io/ioutil"
 	"testing"
 )
 
@@ -17,13 +18,13 @@
 	}
 
 	for _, c := range cases {
-		buf := bytes.Buffer(data)
+		buf := bytes.NewBuffer(data)
 		h := crc32.NewIEEE()
-		r = NewReader32(buf, h, csum)
+		r := NewReader32(buf, h, c.csum)
 
 		_, err := ioutil.ReadAll(r)
 		if err != c.err {
-			t.Fatalf("expected error %v, got %v", c.err, err)
+			t.Fatalf("expected error: %v, got: %v", c.err, err)
 		}
 	}
 }
Fix bugs in test case