123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 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++ {
- Mishmash(test, 0)
- }
- }
|