-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlangutil_test.go
58 lines (55 loc) · 1.41 KB
/
langutil_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
package span
import "testing"
func TestDetectLang3(t *testing.T) {
var cases = []struct {
in string
out string
err error
}{
// Hits.
{"", "", nil},
{"indivisible, with liberty and justice for all", "eng", nil},
{"in Hoffnung den Grund und die rechte Tieffe darinnen zu finden", "deu", nil},
{"uomo di cultura e appassionato di astronomia", "ita", nil},
{"С Востока свет, с Востока силы!", "rus", nil},
{"Tiam drako estis simbolo de la supernatura", "epo", nil},
{"Le long du vieux faubourg, où pendent aux masures", "fra", nil},
{"Hello World: Eine Einführung", "deu", nil},
{"Reflections on Gestalt therapy", "eng", nil},
// Misses.
{"Hello World", "nld", nil},
{"Samedi soir", "nno", nil},
{"Samedi soir, je viendrai dîner avec mon amie.", "nno", nil},
}
for _, c := range cases {
result, err := DetectLang3(c.in)
if result != c.out {
t.Fatalf("got %v, want %v", result, c.out)
}
if err != c.err {
t.Fatalf("got %v, want %v", err, c.err)
}
}
}
func TestLanguageIdentifier(t *testing.T) {
var cases = []struct {
in string
out string
}{
// Hits.
{"German", "deu"},
{"de", "deu"},
{"ger", "deu"},
{"serbo-croatian", "hbs"},
{"Albanian", "sqi"},
// Misses.
{"Deutsch", ""},
{"de_DE", ""},
}
for _, c := range cases {
result := LanguageIdentifier(c.in)
if result != c.out {
t.Fatalf("got %v, want %v", result, c.out)
}
}
}