-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdeepl_test.go
48 lines (44 loc) · 1.26 KB
/
deepl_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
package deepl
import "testing"
func TestTranslate(t *testing.T) {
translate, err := Translate("", "zh", "I love Go programming language")
if err != nil {
t.Fatal(err)
}
t.Log(translate.Result.Texts[0].Text)
t.Log(len(translate.Result.Texts[0].Alternatives))
}
func TestTranslateWithProSession(t *testing.T) {
options := []Option{
WithDeeplProSession("fa.xxxxx-xxxx-xxxxx-xxxx-xxxxxxx"),
}
translate, err := Translate("", "zh", "I am the apple of my father's eyes", options...)
if err != nil {
t.Fatal(err)
}
t.Log(translate.Result.Texts[0].Text)
t.Log(len(translate.Result.Texts[0].Alternatives))
}
func TestTranslateWithHttpProxy(t *testing.T) {
options := []Option{
WithHttpProxy("http://127.0.0.1:10808"),
}
translate, err := Translate("", "zh", "I love Go programming language", options...,
)
if err != nil {
t.Fatal(err)
}
t.Log(translate.Result.Texts[0].Text)
t.Log(len(translate.Result.Texts[0].Alternatives))
}
func TestTranslateWithSocket5Proxy(t *testing.T) {
options := []Option{
WithSocket5Proxy("127.0.0.1:10808", "", ""),
}
translate, err := Translate("", "zh", "I love Go programming language", options...)
if err != nil {
t.Fatal(err)
}
t.Log(translate.Result.Texts[0].Text)
t.Log(len(translate.Result.Texts[0].Alternatives))
}