-
Notifications
You must be signed in to change notification settings - Fork 3
/
vad_test.go
45 lines (40 loc) · 969 Bytes
/
vad_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
package webrtcvad
import (
"testing"
)
func TestSetMode(t *testing.T) {
vadInst := Create()
defer Free(vadInst)
Init(vadInst)
for i := 0; i < 4; i++ {
err := SetMode(vadInst, i)
if err != nil {
t.Errorf("mode = %v, expected = %v", i, err)
}
}
}
func TestProcess(t *testing.T) {
vadInst := Create()
defer Free(vadInst)
Init(vadInst)
rates := []int{8000, 16000, 32000, 48000}
for _, rate := range rates {
length := rate / 1000 * 10
frame := make([]byte, length)
active, _ := Process(vadInst, rate, frame, length)
if active {
t.Errorf("rate = %v, length = %v, expected = process fail", rate, length)
}
}
}
func TestValidRateAndFrameLength(t *testing.T) {
rates := []int{8000, 16000, 32000, 48000}
for _, rate := range rates {
for i := 10; i < 40; i = i + 10 {
length := rate / 1000 * i
if !ValidRateAndFrameLength(rate, length) {
t.Errorf("rate = %v, length = %v, expected = validate fail", rate, length)
}
}
}
}