go implementation of CodeDweller/mishmash.hpp/cpp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mishmash_test.go 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package mishmash
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestMishmash(t *testing.T) {
  7. want := "1b309ba0"
  8. if got := fmt.Sprintf("%08x", Mishmash("google.com")); want != got {
  9. t.Error("TestMishmash() = got", got, "want", want)
  10. } else {
  11. fmt.Println("TestMishmash Passed")
  12. }
  13. }
  14. func TestSecondHash(t *testing.T) {
  15. want := "1ce66335"
  16. if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(Mishmash("google.com")))); want != got {
  17. t.Error("TestSecondHash() = got", got, "want", want)
  18. } else {
  19. fmt.Println("TestSecondHash Passed")
  20. }
  21. }
  22. func TestSeedOne(t *testing.T) {
  23. want := "5839f5f3"
  24. if got := fmt.Sprintf("%08x", Mishmash("google.com", uint64(1))); want != got {
  25. t.Error("TestSeedOne() = got", got, "want", want)
  26. } else {
  27. fmt.Println("TestSeedOne Passed")
  28. }
  29. }
  30. func TestEngineAndAccumulator(t *testing.T) {
  31. want := "a3bbaee4"
  32. test := "google.com"
  33. accum := Engine(test, len(test), 0)
  34. if got := fmt.Sprintf("%08x", Mishmash(test, accum)); want != got {
  35. t.Error("TestEngineAndAccumulator() = got", got, "want", want)
  36. } else {
  37. fmt.Println("TestEngineAndAccumulator Passed")
  38. }
  39. }
  40. func BenchmarkHashGeneration(b *testing.B) {
  41. test := "google.com"
  42. for i := 0; i < b.N; i++ {
  43. Mishmash(test, 0)
  44. }
  45. }