Add test suite.
[srt2vtt.git] / tests / webvtt.scm
1 ;;; srt2vtt --- SRT to WebVTT converter
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;;
4 ;;; srt2vtt is free software; you can redistribute it and/or modify it
5 ;;; under the terms of the GNU General Public License as published by
6 ;;; the Free Software Foundation; either version 3 of the License, or
7 ;;; (at your option) any later version.
8 ;;;
9 ;;; srt2vtt is distributed in the hope that it will be useful, but
10 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ;;; General Public License for more details.
13 ;;;
14 ;;; You should have received a copy of the GNU General Public License
15 ;;; along with srt2vtt.  If not, see <http://www.gnu.org/licenses/>.
16
17 (define-module (tests webvtt)
18   #:use-module (srfi srfi-64)
19   #:use-module (tests utils)
20   #:use-module (srt2vtt)
21   #:use-module (srt2vtt webvtt))
22
23 (test-begin "webvtt")
24
25 (test-equal "write-webvtt"
26   "1
27 01:02:03.004 --> 05:06:07.008
28 foo
29
30 "
31   (call-with-output-string
32    (lambda (port)
33      (let ((sub (make-subtitle 1
34                                '(1 2 3 4)
35                                '(5 6 7 8)
36                                '("foo"))))
37        (write-webvtt sub port)))))
38
39 (test-equal "write-webvtts"
40   "WEBVTT
41
42 1
43 01:02:03.004 --> 05:06:07.008
44 foo
45
46 2
47 09:10:11.012 --> 13:14:15.016
48 bar
49 baz
50
51 "
52   (pk 'subs(call-with-output-string
53     (lambda (port)
54       (let ((subs (list
55                    (make-subtitle 1
56                                   '(1 2 3 4)
57                                   '(5 6 7 8)
58                                   '("foo"))
59                    (make-subtitle 2
60                                   '(9 10 11 12)
61                                   '(13 14 15 16)
62                                   '("bar" "baz")))))
63         (write-webvtts subs port))))))
64
65 (test-end "webvtt")
66
67 (test-exit)