-
Notifications
You must be signed in to change notification settings - Fork 169
/
codec_test.go
66 lines (54 loc) · 1.25 KB
/
codec_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
59
60
61
62
63
64
65
66
package gmf_test
import (
"github.com/3d0c/gmf"
"log"
"testing"
)
func TestCodecEq(t *testing.T) {
dec, enc, notfound := 0, 0, 0
for _, codec := range gmf.Codecs {
if codec.IsEncoder {
encById, err := gmf.FindEncoder(codec.Id())
if err != nil {
log.Println("E", err, codec.Id())
notfound++
continue
}
encByName, err := gmf.FindEncoder(codec.Name())
if err != nil {
log.Println("E", err, codec.Id())
notfound++
continue
}
if encById.Id() != encByName.Id() {
t.Fatal("different id. should be equal:", encById.Id(), encByName.Id())
}
enc++
} else {
decById, err := gmf.FindDecoder(codec.Id())
if err != nil {
log.Println("D", err, codec.Id())
notfound++
continue
}
decByName, err := gmf.FindDecoder(codec.Name())
if err != nil {
log.Println("D", err, codec.Id())
notfound++
continue
}
if decById.Id() != decByName.Id() {
t.Fatal("different id. should be equal:", decById.Id(), decByName.Id())
}
dec++
}
}
log.Printf("%d encoders, %d decoders checked. %d not found", enc, dec, notfound)
}
func TestFindByName(t *testing.T) {
c, err := gmf.FindEncoder("libx264")
if err != nil {
t.Fatal(err)
}
log.Printf("Found %s, %s\n", c.Name(), c.LongName())
}