You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sync_user_test.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package flashduty
  2. import "testing"
  3. func TestPhoneIsSame(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. phone1 string
  7. phone2 string
  8. same bool
  9. }{
  10. {
  11. name: "blank",
  12. phone1: "",
  13. phone2: "",
  14. same: true,
  15. },
  16. {
  17. name: "China +86 prefix",
  18. phone1: "+8613812345678",
  19. phone2: "13812345678",
  20. same: true,
  21. },
  22. {
  23. name: "China +86 with spaces and hyphens",
  24. phone1: "+86 138-1234-5678",
  25. phone2: "13812345678",
  26. same: true,
  27. },
  28. {
  29. name: "USA +1 prefix",
  30. phone1: "+1 234-567-8900",
  31. phone2: "2345678900",
  32. same: true,
  33. },
  34. {
  35. name: "UK +44 prefix",
  36. phone1: "+442078765432",
  37. phone2: "2078765432",
  38. same: true,
  39. },
  40. {
  41. name: "India +91 prefix",
  42. phone1: "+919876543210",
  43. phone2: "9876543210",
  44. same: true,
  45. },
  46. {
  47. name: "Germany +49 prefix",
  48. phone1: "+4915123456789",
  49. phone2: "15123456789",
  50. same: true,
  51. },
  52. {
  53. name: "Different numbers",
  54. phone1: "+8613812345678",
  55. phone2: "13812345679",
  56. same: false,
  57. },
  58. }
  59. for _, tt := range tests {
  60. if got := PhoneIsSame(tt.phone1, tt.phone2); got != tt.same {
  61. t.Errorf("%s: expected %v, got %v", tt.name, tt.same, got)
  62. }
  63. }
  64. }