forked from 3d0c/gmf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_test.go
56 lines (46 loc) · 1012 Bytes
/
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
package gmf
import (
"log"
"testing"
)
func TestCodec(t *testing.T) {
dec, enc, notfound := 0, 0, 0
for _, codec := range Codecs {
if codec.IsEncoder {
encById, err := FindEncoder(codec.Id())
if err != nil {
// log.Println(err)
notfound++
continue
}
encByName, err := FindEncoder(codec.Name())
if err != nil {
// log.Println(err)
notfound++
continue
}
if encById.Id() != encByName.Id() {
t.Fatal("different id. should be equal:", encById.Id(), encByName.Id())
}
enc++
} else {
decById, err := FindDecoder(codec.Id())
if err != nil {
// log.Println(err)
notfound++
continue
}
decByName, err := FindDecoder(codec.Name())
if err != nil {
// log.Println(err)
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)
}