forked from mind1949/googletrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
googletrans_test.go
40 lines (36 loc) · 989 Bytes
/
googletrans_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
package googletrans
import (
"testing"
)
func TestDo(t *testing.T) {
params := TranslateParams{
Src: "auto",
Dest: "zh-CN",
Text: "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. ",
}
transData, err := defaultTranslator.do(params)
if err != nil {
t.Error(err)
}
t.Logf("%+v\n", transData)
}
func TestTranslate(t *testing.T) {
params := TranslateParams{
Src: "auto",
Dest: "zh-CN",
Text: "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. ",
}
translated, err := defaultTranslator.Translate(params)
if err != nil {
t.Error(err)
}
t.Logf("%+v\n", translated)
}
func TestDetect(t *testing.T) {
text := "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. "
detected, err := defaultTranslator.Detect(text)
if err != nil {
t.Error(err)
}
t.Logf("%+v\n", detected)
}