-
Notifications
You must be signed in to change notification settings - Fork 3
/
detect_test.go
42 lines (32 loc) · 936 Bytes
/
detect_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
package detectlanguage_test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDetect(t *testing.T) {
detections, err := client.Detect("labas rytas")
if assert.NoError(t, err) {
assert.Equal(t, "lt", detections[0].Language)
assert.True(t, detections[0].Reliable)
assert.Greater(t, detections[0].Confidence, float32(0))
}
}
func TestDetectCode(t *testing.T) {
code, err := client.DetectCode("labas rytas")
if assert.NoError(t, err) {
assert.Equal(t, "lt", code)
}
}
func TestDetectCodeFailure(t *testing.T) {
code, err := client.DetectCode("")
assert.EqualError(t, err, "Language not detected")
assert.Equal(t, code, "")
}
func TestDetectBatch(t *testing.T) {
query := []string{"labas rytas", "good morning"}
detections, err := client.DetectBatch(query)
if assert.NoError(t, err) {
assert.Equal(t, "lt", detections[0][0].Language)
assert.Equal(t, "en", detections[1][0].Language)
}
}