hash_test.go 460 B

123456789101112131415161718
  1. package main
  2. import "testing"
  3. func TestGetHash(t *testing.T) {
  4. for _, tc := range []struct{ link, want string }{
  5. {"", "00000000"},
  6. {"https://example.com", "96248650"},
  7. {"https://example.com/69897/4885590609", "2be9aa73"},
  8. {"https://example.com/105844/11202952336", "2be9aa73"},
  9. } {
  10. t.Run(tc.link, func(t *testing.T) {
  11. if got := getHash(tc.link); got != tc.want {
  12. t.Fatalf("getHash(%q) = %q, want %q", tc.link, got, tc.want)
  13. }
  14. })
  15. }
  16. }