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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
settings, line
<link rel="help" href="https://w3c.github.io/webvtt/#collect-webvtt-cue-timings-and-settings">
assert_equals(cues.length, 46);
// Test starts with simple valid values
var valid_values = [
-1,
0,
0,
1,
100,
101,
65536,
4294967296,
18446744073709552000,
10000000000000000000000000000000000,
1.5,
Number.MAX_VALUE,
-1 * Number.MAX_VALUE,
Number.MIN_VALUE,
0, // Less than Number.MIN_VALUE
];
valid_values.forEach(function(valid, index) {
assert_equals(cues[index].line, valid, 'Failed with cue ' + index);
assert_true(cues[index].snapToLines, 'Failed with cue ' + index);
});
// Then a set of invalid ones
var invalid_length = 23;
for (var i = 0; i < invalid_length; i++) {
var index = valid_values.length + i;
assert_equals(cues[index].line, 'auto', 'Failed with cue ' + index);
assert_true(cues[index].snapToLines, 'Failed with cue ' + index);
}
// Then more specific tests
var index = valid_values.length + invalid_length;
assert_equals(cues[index].line, 0);
assert_false(cues[index].snapToLines);
assert_equals(cues[index + 1].line, 0);
assert_false(cues[index + 1].snapToLines);
assert_equals(cues[index + 2].line, 100);
assert_false(cues[index + 2].snapToLines);
assert_equals(cues[index + 2].lineAlign, 'start');
assert_equals(cues[index + 3].line, 100);
assert_false(cues[index + 3].snapToLines);
assert_equals(cues[index + 3].lineAlign, 'start');
assert_equals(cues[index + 4].line, 100);
assert_false(cues[index + 4].snapToLines);
assert_equals(cues[index + 4].lineAlign, 'center');
assert_equals(cues[index + 5].line, 100);
assert_false(cues[index + 5].snapToLines);
assert_equals(cues[index + 5].lineAlign, 'end');
assert_equals(cues[index + 6].line, Number.MIN_VALUE);
assert_false(cues[index + 6].snapToLines);
assert_equals(cues[index + 7].line, 0);
assert_false(cues[index + 7].snapToLines);
===
WEBVTT
NOTE valid
00:00:00.000 --> 00:00:01.000 line:-1
valid0
00:00:00.000 --> 00:00:01.000 line:0
valid1
00:00:00.000 --> 00:00:01.000 line:-0
valid2
00:00:00.000 --> 00:00:01.000 line:1
valid3
00:00:00.000 --> 00:00:01.000 line:100
valid4
00:00:00.000 --> 00:00:01.000 line:101
valid5
00:00:00.000 --> 00:00:01.000 line:65536
valid6
00:00:00.000 --> 00:00:01.000 line:4294967296
valid7
00:00:00.000 --> 00:00:01.000 line:18446744073709552000
valid8
00:00:00.000 --> 00:00:01.000 line:10000000000000000000000000000000000
valid9
00:00:00.000 --> 00:00:01.000 line:1.5
valid10
Number.MAX_VALUE
00:00:00.000 --> 00:00:01.000 line:179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
valid11
-1 * Number.MAX_VALUE
00:00:00.000 --> 00:00:01.000 line:-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
valid12
Number.MIN_VALUE
00:00:00.000 --> 00:00:01.000 line:0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005
valid13
Less than Number.MIN_VALUE
00:00:00.000 --> 00:00:01.000 line:0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
valid14
NOTE invalid
00:00:00.000 --> 00:00:01.000 line:65536%
invalid15
00:00:00.000 --> 00:00:01.000 line:4294967296%
invalid16
00:00:00.000 --> 00:00:01.000 line:18446744073709552000%
invalid17
00:00:00.000 --> 00:00:01.000 line:10000000000000000000000000000000000%
invalid18
00:00:00.000 --> 00:00:01.000 line:-0%
invalid19
00:00:00.000 --> 00:00:01.000 line:101%
invalid20
00:00:00.000 --> 00:00:01.000 line:1%-
invalid21
00:00:00.000 --> 00:00:01.000 line:1-
invalid22
00:00:00.000 --> 00:00:01.000 line:%1
invalid23
00:00:00.000 --> 00:00:01.000 line:1%%
invalid24
00:00:00.000 --> 00:00:01.000 line:0%0
invalid25
00:00:00.000 --> 00:00:01.000 line: 0%
invalid26
00:00:00.000 --> 00:00:01.000 line:0%x
invalid27
00:00:00.000 --> 00:00:01.000 line:-
invalid28
00:00:00.000 --> 00:00:01.000 line:%
invalid29
00:00:00.000 --> 00:00:01.000 line:1..5
invalid30
00:00:00.000 --> 00:00:01.000 line:.5
invalid31
00:00:00.000 --> 00:00:01.000 line:5.
invalid32
Greater than Number.MAX_VALUE
00:00:00.000 --> 00:00:01.000 line:179769313486231590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
invalid33
Less than -1 * Number.MAX_VALUE
00:00:00.000 --> 00:00:01.000 line:-179769313486231590000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
invalid34
exponential notation
00:00:00.000 --> 00:00:01.000 line:1e2
invalid35
00:00:00.000 --> 00:00:01.000 line:100%,middle
invalid36
00:00:00.000 --> 00:00:01.000 line:100%,
invalid37
NOTE extra
00:00:00.000 --> 00:00:01.000 line:0%
text38
00:00:00.000 --> 00:00:01.000 line:00%
text39
00:00:00.000 --> 00:00:01.000 line:100%
text40
00:00:00.000 --> 00:00:01.000 line:100%,start
text41
00:00:00.000 --> 00:00:01.000 line:100%,center
text42
00:00:00.000 --> 00:00:01.000 line:100%,end
text43
Number.MIN_VALUE %
00:00:00.000 --> 00:00:01.000 line:0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005%
text44
Less than Number.MIN_VALUE %
00:00:00.000 --> 00:00:01.000 line:0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002%
text45
|