- package mishmash
-
- import (
- "fmt"
- "testing"
- )
-
- func TestMishmash(t *testing.T) {
- want := "1b309ba0"
- if got := fmt.Sprintf("%08x", Mishmash("google.com")); want != got {
- t.Error("TestMishmash() = got", got, "want", want)
- } else {
- fmt.Println("TestMishmash Passed")
- }
- }
-
- func TestSecondHash(t *testing.T) {
- want := "1ce66335"
- if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(Mishmash("google.com")))); want != got {
- t.Error("TestSecondHash() = got", got, "want", want)
- } else {
- fmt.Println("TestSecondHash Passed")
- }
- }
-
- func TestSeedOne(t *testing.T) {
- want := "5839f5f3"
- if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(1))); want != got {
- t.Error("TestSeedOne() = got", got, "want", want)
- } else {
- fmt.Println("TestSeedOne Passed")
- }
- }
-
- func TestEngineAndAccumulator(t *testing.T) {
- want := "a3bbaee4"
- test := "google.com"
- accum := Engine(test, len(test), 0)
- if got := fmt.Sprintf("%08x", Mishmash(test, accum)); want != got {
- t.Error("TestEngineAndAccumulator() = got", got, "want", want)
- } else {
- fmt.Println("TestEngineAndAccumulator Passed")
- }
- }
-
- func BenchmarkHashGeneration(b *testing.B) {
- test := "google.com"
- for i := 0; i < b.N; i++ {
- Mishmash(test, 0)
- }
- }
|