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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package mishmash
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestMishmash(t *testing.T) {
  7. want := "9d923077"
  8. if got := fmt.Sprintf("%08x", Mishmash([]byte("google.com"))); want != got {
  9. t.Error("Parse() = got", got, "want", want)
  10. } else {
  11. fmt.Println("TestMishmash Passed")
  12. }
  13. }
  14. func TestSecondHash(t *testing.T) {
  15. want := "3fbdb348"
  16. hash := Mishmash([]byte("google.com"))
  17. if got := fmt.Sprintf("%08x", Mishmash([]byte("google.com"), uint64(hash))); want != got {
  18. t.Error("Parse() = got", got, "want", want)
  19. } else {
  20. fmt.Println("TestSecondHash Passed")
  21. }
  22. }
  23. func TestSeedOne(t *testing.T) {
  24. want := "cebf5691"
  25. if got := fmt.Sprintf("%08x", Mishmash([]byte("google.com"), uint64(1))); want != got {
  26. t.Error("Parse() = got", got, "want", want)
  27. } else {
  28. fmt.Println("TestSeedOne Passed")
  29. }
  30. }
  31. func TestEngineAndAccumulator(t *testing.T) {
  32. want := "65df1304"
  33. test := []byte("google.com")
  34. accum := Engine(test, len(test), 0)
  35. if got := fmt.Sprintf("%08x", Mishmash(test, accum)); want != got {
  36. t.Error("Parse() = got", got, "want", want)
  37. } else {
  38. fmt.Println("TestEngineAndAccumulator Passed")
  39. }
  40. }