-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
qgram_test.go
35 lines (32 loc) · 1.04 KB
/
qgram_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
package edlib
import (
"testing"
)
func TestQgramDistance(t *testing.T) {
type args struct {
str1 string
str2 string
splitLength int
}
tests := []struct {
name string
args args
want int
}{
{"Qgram sim 1", args{"Radiohead", "Radiohead", 2}, 0.0},
{"Qgram sim 2", args{"ABCD", "ABCE", 2}, 2.0},
{"Qgram sim 3", args{"Radiohead", "Carly Rae Jepsen", 2}, 21.0},
{"Qgram sim 4", args{"I love horror movies", "Lights out is a horror movie", 2}, 22.0},
{"Qgram sim 5", args{"love horror movies", "Lights out horror movie", 2}, 15.0},
{"Qgram sim 6", args{"私の名前はジョンです", "私の名前はジョン・ドゥです", 2}, 5},
{"Qgram sim 7", args{"🙂😄🙂😄 😄🙂😄", "🙂😄🙂😄 😄🙂😄 🙂😄🙂", 2}, 4},
{"Qgram sim 8", args{"", "", 2}, 0.0},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := QgramDistance(tt.args.str1, tt.args.str2, tt.args.splitLength); got != tt.want {
t.Errorf("QgramDistance() = %v, want %v", got, tt.want)
}
})
}
}