-
Notifications
You must be signed in to change notification settings - Fork 15
/
time_test.go
33 lines (27 loc) · 918 Bytes
/
time_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
package subtitles
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseSrtTime(t *testing.T) {
t1, _ := parseSrtTime("18:40:22.110")
t2, _ := parseSrtTime("18:40:22,110")
t3, _ := parseSrtTime("18:40:22:110")
t4, _ := parseSrtTime("18:40:22")
t5, _ := parseSrtTime("00:00:0,500")
t6, _ := parseSrtTime("00:00:2,00")
t7, _ := parseSrtTime("00:14:52.12")
assert.Equal(t, makeTime(18, 40, 22, 110), t1)
assert.Equal(t, makeTime(18, 40, 22, 110), t2)
assert.Equal(t, makeTime(18, 40, 22, 110), t3)
assert.Equal(t, makeTime(18, 40, 22, 0), t4)
assert.Equal(t, makeTime(0, 0, 0, 500), t5)
assert.Equal(t, makeTime(0, 0, 2, 0), t6)
assert.Equal(t, makeTime(0, 14, 52, 12), t7)
}
func TestParseVttTime(t *testing.T) {
t1, _ := parseVttTime("00:00:10.840")
t2, _ := parseVttTime("00:13.000")
assert.Equal(t, makeTime(0, 0, 13, 0), t2)
assert.Equal(t, makeTime(0, 0, 10, 840), t1)
}