package mishmash import ( "fmt" "testing" ) func TestMishmash(t *testing.T) { want := "59dadb24" 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 := "5ba2a3f1" 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 := "eb734861" 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 := "a189111f" 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++ { accum := uint64(Mishmash(test, 0))<<32 | uint64(Mishmash(test, 1)) fmt.Printf("%016x\n", accum) } }