util_test.go 468 B

12345678910111213141516171819202122232425262728293031
  1. package util
  2. import (
  3. "testing"
  4. )
  5. func TestValidateEmail(t *testing.T) {
  6. tests := []struct {
  7. email string
  8. want bool
  9. }{
  10. {
  11. email: "t@gmail.com",
  12. want: true,
  13. },
  14. {
  15. email: "@qq.com",
  16. want: false,
  17. },
  18. {
  19. email: "1@gmail",
  20. want: true,
  21. },
  22. }
  23. for _, test := range tests {
  24. result := ValidateEmail(test.email)
  25. if result != test.want {
  26. t.Errorf("Validate Email %s: got result %v, want %v.", test.email, result, test.want)
  27. }
  28. }
  29. }