forked from martinlindhe/subtitles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcsub_test.go
59 lines (48 loc) · 1.31 KB
/
dcsub_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
package subtitles
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewFromDCSubGood(t *testing.T) {
data, err := ioutil.ReadFile("./testdata/dcsub/good.xml")
assert.Equal(t, nil, err)
in := string(data)
expected := Subtitle{[]Caption{{
Seq: 1,
Start: makeTime(0, 1, 0, 0),
End: makeTime(0, 1, 3, 240),
Text: []string{"-Nej...", "-Vad är det?"},
}}}
res, err := NewFromDCSub(in)
assert.Equal(t, nil, err)
assert.Equal(t, expected, res)
}
func TestNewFromDCSubStyledText(t *testing.T) {
data, err := ioutil.ReadFile("./testdata/dcsub/styled_text.xml")
assert.Equal(t, nil, err)
in := string(data)
expected := Subtitle{[]Caption{{
Seq: 1,
Start: makeTime(0, 5, 40, 0),
End: makeTime(0, 5, 43, 0),
Text: []string{`<font italic="yes">Hanne!</font>`},
}}}
res, err := NewFromDCSub(in)
assert.Equal(t, nil, err)
assert.Equal(t, expected, res)
}
func TestNewFromDCSubEntitiesText(t *testing.T) {
data, err := ioutil.ReadFile("./testdata/dcsub/entities.xml")
assert.Equal(t, nil, err)
in := string(data)
expected := Subtitle{[]Caption{{
Seq: 1,
Start: makeTime(0, 1, 0, 0),
End: makeTime(0, 1, 3, 240),
Text: []string{`Eller så är det en "ähpar".`},
}}}
res, err := NewFromDCSub(in)
assert.Equal(t, nil, err)
assert.Equal(t, expected, res)
}