forked from hyperjiang/php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
similar_text_test.go
76 lines (73 loc) · 933 Bytes
/
similar_text_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package php_test
import (
"github.com/hyperjiang/php"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("SimilarText", func() {
type args struct {
first string
second string
}
tests := []struct {
args args
wantCount int
wantPercent float32
}{
{
args{
"Hello world",
"Hallo world",
},
10,
90.90909,
},
{
args{
"",
"Hello world",
},
0,
0,
},
{
args{
"",
"",
},
0,
0,
},
{
args{
"",
"",
},
0,
0,
},
{
args{
"abc",
"ABC",
},
0,
0,
},
{
args{
"我爱Golang",
"Golang爱我",
},
6,
75,
},
}
It("should match the expected values", func() {
for _, t := range tests {
gotCount, gotPercent := php.SimilarText(t.args.first, t.args.second)
Expect(gotCount).To(Equal(t.wantCount))
Expect(gotPercent).To(Equal(t.wantPercent))
}
})
})