File tree 5 files changed +49
-0
lines changed
5 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,17 @@ package adler32
6
6
7
7
import (
8
8
"encoding"
9
+ "hash"
10
+ "internal/testhash"
9
11
"io"
10
12
"strings"
11
13
"testing"
12
14
)
13
15
16
+ func TestHashInterface (t * testing.T ) {
17
+ testhash .TestHash (t , func () hash.Hash { return New () })
18
+ }
19
+
14
20
var golden = []struct {
15
21
out uint32
16
22
in string
Original file line number Diff line number Diff line change 8
8
"encoding"
9
9
"fmt"
10
10
"hash"
11
+ "internal/testhash"
11
12
"io"
12
13
"math/rand"
13
14
"testing"
@@ -23,6 +24,10 @@ func TestCastagnoliRace(t *testing.T) {
23
24
ieee .Write ([]byte ("hello" ))
24
25
}
25
26
27
+ func TestHashInterface (t * testing.T ) {
28
+ testhash .TestHash (t , func () hash.Hash { return NewIEEE () })
29
+ }
30
+
26
31
type test struct {
27
32
ieee , castagnoli uint32
28
33
in string
Original file line number Diff line number Diff line change @@ -6,10 +6,16 @@ package crc64
6
6
7
7
import (
8
8
"encoding"
9
+ "hash"
10
+ "internal/testhash"
9
11
"io"
10
12
"testing"
11
13
)
12
14
15
+ func TestCRC64Hash (t * testing.T ) {
16
+ testhash .TestHash (t , func () hash.Hash { return New (MakeTable (ISO )) })
17
+ }
18
+
13
19
type test struct {
14
20
outISO uint64
15
21
outECMA uint64
Original file line number Diff line number Diff line change @@ -9,10 +9,37 @@ import (
9
9
"encoding"
10
10
"encoding/binary"
11
11
"hash"
12
+ "internal/testhash"
12
13
"io"
13
14
"testing"
14
15
)
15
16
17
+ func TestHashInterface (t * testing.T ) {
18
+ type test struct {
19
+ name string
20
+ fn func () hash.Hash
21
+ }
22
+ fn32 := func (fn func () hash.Hash32 ) func () hash.Hash {
23
+ return func () hash.Hash { return fn () }
24
+ }
25
+ fn64 := func (fn func () hash.Hash64 ) func () hash.Hash {
26
+ return func () hash.Hash { return fn () }
27
+ }
28
+ tests := []test {
29
+ {"32" , fn32 (New32 )},
30
+ {"32a" , fn32 (New32a )},
31
+ {"64" , fn64 (New64 )},
32
+ {"64a" , fn64 (New64a )},
33
+ {"128" , New128 },
34
+ {"128a" , New128a },
35
+ }
36
+ for _ , test := range tests {
37
+ t .Run (test .name , func (t * testing.T ) {
38
+ testhash .TestHash (t , test .fn )
39
+ })
40
+ }
41
+ }
42
+
16
43
type golden struct {
17
44
out []byte
18
45
in string
Original file line number Diff line number Diff line change 9
9
"fmt"
10
10
"hash"
11
11
"internal/asan"
12
+ "internal/testhash"
12
13
"math"
13
14
"reflect"
14
15
"strings"
@@ -455,6 +456,10 @@ func TestComparableAllocations(t *testing.T) {
455
456
var _ hash.Hash = & Hash {}
456
457
var _ hash.Hash64 = & Hash {}
457
458
459
+ func TestHashInterface (t * testing.T ) {
460
+ testhash .TestHash (t , func () hash.Hash { return new (Hash ) })
461
+ }
462
+
458
463
func benchmarkSize (b * testing.B , size int ) {
459
464
h := & Hash {}
460
465
buf := make ([]byte , size )
You can’t perform that action at this time.
0 commit comments