-
Notifications
You must be signed in to change notification settings - Fork 0
/
emailcorrector_test.go
60 lines (52 loc) · 1.2 KB
/
emailcorrector_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package emailcorrector
import (
"fmt"
"testing"
)
func TestValidateEmail(t *testing.T) {
validEmails := []string{
}
for _, email := range validEmails {
if err := ValidateEmail(email); err != nil {
t.Errorf("expected valid email, got error: %v", err)
}
}
invalidEmails := []string{
"invalidemail.com",
"user@",
"@example.com",
}
for _, email := range invalidEmails {
if err := ValidateEmail(email); err == nil {
t.Errorf("expected error for invalid email, got none")
}
}
}
func TestSuggestDomainCorrection(t *testing.T) {
tests := map[string]string{
"gmial.com": "gmail.com",
"yaho.com": "yahoo.com",
"outlok.com": "outlook.com",
}
for input, expected := range tests {
result := SuggestDomainCorrection(input)
fmt.Println(result)
if result != expected {
t.Errorf("expected %s, got %s", expected, result)
}
}
}
func TestCorrectEmail(t *testing.T) {
email := "[email protected]"
corrected, err := CorrectEmail(email)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
fmt.Println(corrected)
expected := "[email protected]"
if corrected != expected {
t.Errorf("expected %s but got %s", expected, corrected)
}
}