segmentio / fasthash

Go package porting the standard hashing algorithms to a more efficient implementation.
MIT License
286 stars 21 forks source link

Move testutils into a subpackage #6

Closed f2prateek closed 6 years ago

f2prateek commented 6 years ago

The public API currently looks like this:

package fasthash 

func BenchmarkHashString32(b *testing.B, name string, reference func(string) uint32, algorithm func(string) uint32)
func BenchmarkHashString64(b *testing.B, name string, reference func(string) uint64, algorithm func(string) uint64)
func HashString32(f func() hash.Hash32) func(string) uint32
func HashString64(f func() hash.Hash64) func(string) uint64
func HashUint32(f func() hash.Hash32) func(uint32) uint32
func HashUint64(f func() hash.Hash64) func(uint64) uint64
func TestHashString32(t *testing.T, name string, reference func(string) uint32, algorithm func(string) uint32)
func TestHashString64(t *testing.T, name string, reference func(string) uint64, algorithm func(string) uint64)
func TestHashUint32(t *testing.T, name string, reference func(uint32) uint32, algorithm func(uint32) uint32)
func TestHashUint64(t *testing.T, name string, reference func(uint64) uint64, algorithm func(uint64) uint64)

I think we should split the testing ones into a subpackage (like nettest) and simplify the core package a bit.

package fasthash

func HashString32(f func() hash.Hash32) func(string) uint32
func HashString64(f func() hash.Hash64) func(string) uint64
func HashUint32(f func() hash.Hash32) func(uint32) uint32
func HashUint64(f func() hash.Hash64) func(uint64) uint64
package fasthashtest

func BenchmarkHashString32(b *testing.B, name string, reference func(string) uint32, algorithm func(string) uint32)
func BenchmarkHashString64(b *testing.B, name string, reference func(string) uint64, algorithm func(string) uint64)
func TestHashString32(t *testing.T, name string, reference func(string) uint32, algorithm func(string) uint32)
func TestHashString64(t *testing.T, name string, reference func(string) uint64, algorithm func(string) uint64)
func TestHashUint32(t *testing.T, name string, reference func(uint32) uint32, algorithm func(uint32) uint32)
func TestHashUint64(t *testing.T, name string, reference func(uint64) uint64, algorithm func(uint64) uint64)
achille-roussel commented 6 years ago

Adding a fastashtest sub package is a good idea 👍

Are you taking it?

f2prateek commented 6 years ago

Yep I can do it!