forked from asticode/go-astisub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stl_test.go
39 lines (32 loc) · 895 Bytes
/
stl_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
package astisub_test
import (
"bytes"
"io/ioutil"
"testing"
"time"
"github.com/asticode/go-astisub"
"github.com/stretchr/testify/assert"
)
func TestSTL(t *testing.T) {
// Init
astisub.Now = func() (t time.Time) {
t, _ = time.Parse("060102", "170702")
return
}
// Open
s, err := astisub.OpenFile("./testdata/example-in.stl")
assert.NoError(t, err)
assertSubtitleItems(t, s)
// Metadata
assert.Equal(t, &astisub.Metadata{Framerate: 25, Language: astisub.LanguageFrench, STLPublisher: "Copyright test", Title: "Title test"}, s.Metadata)
// No subtitles to write
w := &bytes.Buffer{}
err = astisub.Subtitles{}.WriteToSTL(w)
assert.EqualError(t, err, astisub.ErrNoSubtitlesToWrite.Error())
// Write
c, err := ioutil.ReadFile("./testdata/example-out.stl")
assert.NoError(t, err)
err = s.WriteToSTL(w)
assert.NoError(t, err)
assert.Equal(t, string(c), w.String())
}