forked from client9/misspell
-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
notwords_test.go
45 lines (41 loc) · 1.46 KB
/
notwords_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
package misspell
import (
"testing"
)
func TestNotWords(t *testing.T) {
testCases := []struct {
word string
want string
}{
{word: " /foo/bar abc", want: " abc"},
{word: "X/foo/bar abc", want: "X/foo/bar abc"},
{word: "[/foo/bar] abc", want: "[ ] abc"},
{word: "/", want: "/"},
{word: "x [email protected] y", want: "x y"},
{word: "x fqdn.example.org. y", want: "x . y"},
{word: "x infinitie.net y", want: "x y"},
{word: "x infinitie.net ", want: "x "},
{word: "x infinitie.net", want: "x "},
{word: "x foo.example.com y", want: "x y"},
{word: "x foo.example.com ", want: "x "},
{word: "x foo.example.com", want: "x "},
{word: "foo.example.com y", want: " y"},
{word: "foo.example.com", want: " "},
{word: "(s.svc.GetObject(", want: "(s.svc.GetObject("},
{word: "defer file.Close()", want: "defer file.Close()"},
{word: "defer file.c()", want: "defer file.c()"},
{word: "defer file.cl()", want: "defer ()"}, // false negative
{word: "defer file.close()", want: "defer ()"}, // false negative
{word: "\\nto", want: " to"},
}
for _, test := range testCases {
test := test
t.Run(test.word, func(t *testing.T) {
t.Parallel()
got := RemoveNotWords(test.word)
if got != test.want {
t.Errorf("want %q got %q", test.want, got)
}
})
}
}