package mishmash import ( "fmt" "testing" ) func TestMishmash(t *testing.T) { want := "9d923077" if got := fmt.Sprintf("%08x", Mishmash("google.com")); want != got { t.Error("Parse() = got", got, "want", want) } else { fmt.Println("TestMishmash Passed") } } func TestSecondHash(t *testing.T) { want := "3fbdb348" hash := Mishmash("google.com") if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(hash))); want != got { t.Error("Parse() = got", got, "want", want) } else { fmt.Println("TestSecondHash Passed") } } func TestSeedOne(t *testing.T) { want := "cebf5691" if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(1))); want != got { t.Error("Parse() = got", got, "want", want) } else { fmt.Println("TestSeedOne Passed") } } func TestEngineAndAccumulator(t *testing.T) { want := "65df1304" test := "google.com" accum := Engine(test, len(test), 0) if got := fmt.Sprintf("%08x", Mishmash(test, accum)); want != got { t.Error("Parse() = got", got, "want", want) } else { fmt.Println("TestEngineAndAccumulator Passed") } } func BenchmarkHashGeneration(b *testing.B) { test := "google.com" for i := 0; i < b.N; i++ { accum := uint64(Mishmash(test, 0))<<32 | uint64(Mishmash(test, 1)) fmt.Printf("%016x\n", accum) } }