2 Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ssa_reader.h"
24 #include <boost/test/unit_test.hpp>
25 #include <boost/filesystem.hpp>
26 #include <boost/foreach.hpp>
34 BOOST_AUTO_TEST_CASE (ssa_reader_test)
36 boost::filesystem::path p = private_test / "example.ssa";
37 FILE* f = fopen (p.string().c_str(), "r");
38 sub::SSAReader reader (f);
40 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
42 list<sub::Subtitle>::iterator i = subs.begin ();
44 BOOST_REQUIRE (i != subs.end ());
45 BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 40, 650));
46 BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 41, 790));
47 list<sub::Line>::iterator j = i->lines.begin();
48 BOOST_REQUIRE (j != i->lines.end ());
49 BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
50 sub::Block b = j->blocks.front ();
51 BOOST_CHECK_EQUAL (b.text, "Et les enregistrements de ses ondes delta ?");
52 BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain");
53 BOOST_CHECK_EQUAL (b.font_size.points().get(), 56);
54 BOOST_CHECK_EQUAL (b.bold, false);
55 BOOST_CHECK_EQUAL (b.italic, false);
56 BOOST_CHECK_EQUAL (b.underline, false);
59 BOOST_REQUIRE (i != subs.end ());
60 BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 42, 420));
61 BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 44, 150));
63 BOOST_REQUIRE (j != i->lines.end ());
64 BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
65 b = j->blocks.front ();
66 BOOST_CHECK_EQUAL (b.text, "Toujours rien.");
67 BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain");
68 BOOST_CHECK_EQUAL (b.font_size.points().get(), 56);
69 BOOST_CHECK_EQUAL (b.bold, false);
70 BOOST_CHECK_EQUAL (b.italic, false);
71 BOOST_CHECK_EQUAL (b.underline, false);
74 BOOST_CHECK (i == subs.end());
77 BOOST_AUTO_TEST_CASE (ssa_reader_line_test1)
79 sub::RawSubtitle base;
80 list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
82 "This is a line with some {\\i1}italics{\\i0} and then\\nthere is a new line.",
86 list<sub::RawSubtitle>::const_iterator i = r.begin ();
87 BOOST_CHECK_EQUAL (i->text, "This is a line with some ");
88 BOOST_CHECK_EQUAL (i->italic, false);
90 BOOST_REQUIRE (i != r.end ());
92 BOOST_CHECK_EQUAL (i->text, "italics");
93 BOOST_CHECK_EQUAL (i->italic, true);
95 BOOST_REQUIRE (i != r.end ());
97 BOOST_CHECK_EQUAL (i->text, " and then");
98 BOOST_CHECK_EQUAL (i->italic, false);
100 BOOST_REQUIRE (i != r.end ());
102 BOOST_CHECK_EQUAL (i->text, "there is a new line.");
104 BOOST_REQUIRE (i == r.end ());
107 BOOST_AUTO_TEST_CASE (ssa_reader_line_test2)
109 sub::RawSubtitle base;
110 list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
112 "{\\i1}It's all just italics{\\i0}",
116 list<sub::RawSubtitle>::const_iterator i = r.begin ();
117 BOOST_CHECK_EQUAL (i->text, "It's all just italics");
118 BOOST_CHECK_EQUAL (i->italic, true);
120 BOOST_REQUIRE (i == r.end ());
122 r = sub::SSAReader::parse_line (
124 "{\\i1}Italic{\\i0}\\Nand new line",
129 BOOST_CHECK_EQUAL (i->text, "Italic");
130 BOOST_CHECK_EQUAL (i->italic, true);
131 BOOST_CHECK (fabs ((72.0 * 1.2 / 792) - i->vertical_position.proportional.get()) < 1e-5);
133 BOOST_CHECK_EQUAL (i->text, "and new line");
134 BOOST_CHECK_EQUAL (i->italic, false);
135 BOOST_CHECK (i->vertical_position.proportional.get() < 1e-5);
139 test (boost::filesystem::path p)
141 p = private_test / p;
142 FILE* f = fopen (p.string().c_str(), "r");
144 sub::SSAReader r (f);
148 /** Test of reading some typical .ssa files */
149 BOOST_AUTO_TEST_CASE (ssa_reader_test2)
151 test ("DKH_UT_EN20160601def.ssa");
152 test ("dcpsubtest-en.ssa");
155 #define SUB_START(f, t) \
156 BOOST_REQUIRE (i != subs.end ()); \
157 BOOST_CHECK_EQUAL (i->from, f); \
158 BOOST_CHECK_EQUAL (i->to, t); \
159 j = i->lines.begin ();
161 #define LINE(vp, vr, hp, hr) \
162 BOOST_REQUIRE (j != i->lines.end ()); \
163 BOOST_CHECK (j->vertical_position.proportional); \
164 BOOST_CHECK (fabs (j->vertical_position.proportional.get() - vp) < 1e-5); \
165 BOOST_CHECK (j->vertical_position.reference); \
166 BOOST_CHECK_EQUAL (j->vertical_position.reference.get(), vr); \
167 BOOST_CHECK (fabs (j->horizontal_position.proportional - hp) < 1e-5); \
168 BOOST_CHECK_EQUAL (j->horizontal_position.reference, hr); \
169 k = j->blocks.begin (); \
172 #define BLOCK(t, f, s, b, i, u) \
173 BOOST_REQUIRE (k != j->blocks.end ()); \
174 BOOST_CHECK_EQUAL (k->text, t); \
175 BOOST_CHECK_EQUAL (k->font.get(), f); \
176 BOOST_CHECK_EQUAL (k->font_size.points().get(), s); \
177 BOOST_CHECK_EQUAL (k->bold, b); \
178 BOOST_CHECK_EQUAL (k->italic, i); \
179 BOOST_CHECK_EQUAL (k->underline, u); \
185 /** Test reading of a file within the libsub tree which exercises the parser */
186 BOOST_AUTO_TEST_CASE (ssa_reader_test3)
188 boost::filesystem::path p = "test/data/test.ssa";
189 FILE* f = fopen (p.string().c_str(), "r");
190 sub::SSAReader reader (f);
192 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
194 list<sub::Subtitle>::iterator i = subs.begin ();
195 list<sub::Line>::iterator j;
196 list<sub::Block>::iterator k;
199 SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550));
200 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
201 BLOCK ("Hello world", "Arial", 20, false, false, false);
204 /* This is vertically moved\nand has two lines. */
205 SUB_START (sub::Time::from_hms (0, 0, 5, 740), sub::Time::from_hms (0, 0, 11, 0));
206 /* The first line should be 900 pixels and one line (20
207 points, 1.2 times spaced, as a proportion of the total
208 screen height 729 points) up.
210 LINE((900.0 / 1080) - (20.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
211 BLOCK("This is vertically moved", "Arial", 20, false, false, false);
212 LINE((900.0 / 1080), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
213 BLOCK("and has two lines.", "Arial", 20, false, false, false);
216 /* Some {\i1}italics{\i} are here. */
217 SUB_START (sub::Time::from_hms (0, 0, 7, 740), sub::Time::from_hms (0, 0, 9, 0));
218 LINE(0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
219 BLOCK("Some ", "Arial", 20, false, false, false);
220 BLOCK("italics", "Arial", 20, false, true, false);
221 BLOCK(" are here.", "Arial", 20, false, false, false);
226 SUB_START (sub::Time::from_hms (0, 0, 9, 230), sub::Time::from_hms (0, 0, 11, 560));
227 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
228 BLOCK("bottom left", "Arial", 20, false, false, false);
231 SUB_START (sub::Time::from_hms (0, 0, 9, 240), sub::Time::from_hms (0, 0, 11, 560));
232 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
233 BLOCK("bottom centre", "Arial", 20, false, false, false);
236 SUB_START (sub::Time::from_hms (0, 0, 9, 250), sub::Time::from_hms (0, 0, 11, 560));
237 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
238 BLOCK("bottom right", "Arial", 20, false, false, false);
241 SUB_START (sub::Time::from_hms (0, 0, 9, 260), sub::Time::from_hms (0, 0, 11, 560));
242 LINE (0, sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
243 BLOCK("middle left", "Arial", 20, false, false, false);
246 SUB_START (sub::Time::from_hms (0, 0, 9, 270), sub::Time::from_hms (0, 0, 11, 560));
247 LINE (0, sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
248 BLOCK("middle centre", "Arial", 20, false, false, false);
251 SUB_START (sub::Time::from_hms (0, 0, 9, 280), sub::Time::from_hms (0, 0, 11, 560));
252 LINE (0, sub::VERTICAL_CENTRE_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
253 BLOCK("middle right", "Arial", 20, false, false, false);
256 SUB_START (sub::Time::from_hms (0, 0, 9, 290), sub::Time::from_hms (0, 0, 11, 560));
257 LINE (0, sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
258 BLOCK("top left", "Arial", 20, false, false, false);
261 SUB_START (sub::Time::from_hms (0, 0, 9, 300), sub::Time::from_hms (0, 0, 11, 560));
262 LINE (0, sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
263 BLOCK("top centre", "Arial", 20, false, false, false);
266 SUB_START (sub::Time::from_hms (0, 0, 9, 310), sub::Time::from_hms (0, 0, 11, 560));
267 LINE (0, sub::TOP_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
268 BLOCK("top right", "Arial", 20, false, false, false);
271 BOOST_REQUIRE (i == subs.end ());
274 /** Test reading of a file within the libsub-test-private tree which exercises the parser */
275 BOOST_AUTO_TEST_CASE (ssa_reader_test4)
277 boost::filesystem::path p = private_test / "dcpsubtest2-en.ssa";
278 FILE* f = fopen (p.string().c_str(), "r");
279 sub::SSAReader reader (f);
281 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
283 list<sub::Subtitle>::iterator i = subs.begin ();
284 list<sub::Line>::iterator j;
285 list<sub::Block>::iterator k;
287 BOOST_REQUIRE (i != subs.end ());
289 SUB_START (sub::Time::from_hms (0, 0, 1, 0), sub::Time::from_hms (0, 0, 3, 0));
290 /* The first line should be one line (50 points, 1.2 times
291 spaced, as a proportion of the total screen height 729
294 LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
295 BLOCK ("1st line: This is normal", "Verdana", 50, false, false, false);
296 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
297 BLOCK ("2d line: this is bold", "Verdana", 50, true, false, false);
300 SUB_START (sub::Time::from_hms (0, 0, 3, 100), sub::Time::from_hms (0, 0, 5, 100));
301 LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
302 BLOCK ("1st line: this is bold", "Verdana", 50, true, false, false);
303 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
304 BLOCK ("2nd line: This is normal", "Verdana", 50, false, false, false);
307 SUB_START (sub::Time::from_hms (0, 0, 5, 200), sub::Time::from_hms (0, 0, 7, 200));
308 LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
309 BLOCK ("1st line: this is bold", "Verdana", 50, true, false, false);
310 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
311 BLOCK ("2nd line: this is italics", "Verdana", 50, false, true, false);
314 SUB_START (sub::Time::from_hms (0, 0, 7, 300), sub::Time::from_hms (0, 0, 9, 300));
315 LINE ((50.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
316 BLOCK ("1st line: this is italics", "Verdana", 50, false, true, false);
317 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
318 BLOCK ("2nd line: this is bold", "Verdana", 50, true, false, false);
322 /** Test reading of a .ass file */
323 BOOST_AUTO_TEST_CASE (ssa_reader_test5)
325 boost::filesystem::path p = private_test / "dcpsubtest-en.ass";
326 FILE* f = fopen (p.string().c_str(), "r");
327 sub::SSAReader reader (f);
329 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
331 list<sub::Subtitle>::iterator i = subs.begin ();
332 list<sub::Line>::iterator j;
333 list<sub::Block>::iterator k;
335 BOOST_REQUIRE (i != subs.end ());
337 SUB_START (sub::Time::from_hms (0, 0, 1, 0), sub::Time::from_hms (0, 0, 3, 0));
338 /* The first line should be one line (26 points, 1.2 times
339 spaced, as a proportion of the total screen height 729
342 LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
343 BLOCK ("1st subtitle, 1st line", "arial", 26, true, false, false);
344 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
345 BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false);
348 SUB_START (sub::Time::from_hms (0, 0, 3, 100), sub::Time::from_hms (0, 0, 5, 100));
349 LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
350 BLOCK ("2nd subtitle, 1st line", "arial", 26, true, false, false);
351 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
352 BLOCK ("2nd subtitle, 2nd line", "arial", 26, true, false, false);
355 SUB_START (sub::Time::from_hms (0, 0, 5, 200), sub::Time::from_hms (0, 0, 7, 200));
356 LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
357 BLOCK ("3rd subtitle, 1st line", "arial", 26, true, false, false);
358 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
359 BLOCK ("3rd subtitle, 2nd line", "arial", 26, true, false, false);
362 SUB_START (sub::Time::from_hms (0, 0, 7, 300), sub::Time::from_hms (0, 0, 9, 300));
363 LINE ((26.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
364 BLOCK ("4th subtitle, 1st line", "arial", 26, true, false, false);
365 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
366 BLOCK ("4th subtitle, 2nd line", "arial", 26, true, false, false);
370 /** Test reading of another .ass file */
371 BOOST_AUTO_TEST_CASE (ssa_reader_test6)
373 boost::filesystem::path p = private_test / "DCP-o-matic_test_subs_1.ass";
374 FILE* f = fopen (p.string().c_str(), "r");
376 sub::SSAReader reader (f);
378 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
380 list<sub::Subtitle>::iterator i = subs.begin ();
381 list<sub::Line>::iterator j;
382 list<sub::Block>::iterator k;
384 BOOST_REQUIRE (i != subs.end ());
386 SUB_START (sub::Time::from_hms (0, 0, 0, 70), sub::Time::from_hms (0, 0, 1, 110));
387 /* The first line should be one line (30 points, 1.2 times
388 spaced, as a proportion of the total screen height 729
391 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
392 BLOCK ("This line is normal", "Arial", 30, false, false, false);
393 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
394 BLOCK ("This line is bold", "Arial", 30, true, false, false);
397 SUB_START (sub::Time::from_hms (0, 0, 1, 200), sub::Time::from_hms (0, 0, 2, 240));
398 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
399 BLOCK ("This line is bold", "Arial", 30, true, false, false);
400 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
401 BLOCK ("This line is normal", "Arial", 30, false, false, false);
404 SUB_START (sub::Time::from_hms (0, 0, 2, 300), sub::Time::from_hms (0, 0, 3, 380));
405 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
406 BLOCK ("This line is bold", "Arial", 30, true, false, false);
407 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
408 BLOCK ("This line is italic", "Arial", 30, false, true, false);
411 SUB_START (sub::Time::from_hms (0, 0, 3, 400), sub::Time::from_hms (0, 0, 4, 480));
412 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
413 BLOCK ("This line is italic", "Arial", 30, false, true, false);
414 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
415 BLOCK ("This line is bold", "Arial", 30, true, false, false);
418 SUB_START (sub::Time::from_hms (0, 0, 4, 510), sub::Time::from_hms (0, 0, 5, 600));
419 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
420 BLOCK ("Last three words are ", "Arial", 30, false, false, false);
421 BLOCK ("bold AND italic", "Arial", 30, true, true, false);
422 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
423 BLOCK ("Last three words are ", "Arial", 30, false, false, false);
424 BLOCK ("italic AND bold", "Arial", 30, true, true, false);
427 SUB_START (sub::Time::from_hms (0, 0, 5, 620), sub::Time::from_hms (0, 0, 6, 710));
428 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
429 BLOCK ("Last three words are ", "Arial", 30, false, false, false);
430 BLOCK ("bold AND italic", "Arial", 30, true, true, false);
431 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
432 BLOCK ("First three words", "Arial", 30, true, true, false);
433 BLOCK (" are italic AND bold", "Arial", 30, false, false, false);
436 SUB_START (sub::Time::from_hms (0, 0, 6, 730), sub::Time::from_hms (0, 0, 8, 30));
437 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
438 BLOCK ("Last three words are ", "Arial", 30, false, false, false);
439 BLOCK ("bold AND italic", "Arial", 30, true, true, false);
440 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
441 BLOCK ("This line is normal", "Arial", 30, false, false, false);
444 SUB_START (sub::Time::from_hms (0, 0, 8, 90), sub::Time::from_hms (0, 0, 9, 210));
445 LINE ((30.0 * 1.2 / 792), sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
446 BLOCK ("Both lines are bold AND italic", "Arial", 30, true, true, false);
447 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
448 BLOCK ("Both lines are bold AND italic", "Arial", 30, true, true, false);
453 BOOST_AUTO_TEST_CASE (ssa_reader_pos)
455 boost::filesystem::path p = "test/data/test2.ssa";
456 FILE* f = fopen (p.string().c_str(), "r");
457 sub::SSAReader reader (f);
459 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
461 list<sub::Subtitle>::iterator i = subs.begin ();
462 list<sub::Line>::iterator j;
463 list<sub::Block>::iterator k;
466 SUB_START (sub::Time::from_hms (0, 0, 1, 230), sub::Time::from_hms (0, 0, 4, 550));
467 LINE (0, sub::BOTTOM_OF_SCREEN, 0, sub::HORIZONTAL_CENTRE_OF_SCREEN);
468 BLOCK ("Hello world this is ", "Arial", 20, false, false, false);
469 LINE (300.0 / 1080, sub::TOP_OF_SCREEN, 400.0 / 1920, sub::LEFT_OF_SCREEN);
470 BLOCK ("positioning.", "Arial", 20, false, false, false);
475 BOOST_AUTO_TEST_CASE (ssa_reader_fs)
477 sub::RawSubtitle base;
478 list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
480 "This is a line with some {\\fs64}font sizing.",
484 list<sub::RawSubtitle>::const_iterator i = r.begin ();
485 BOOST_CHECK_EQUAL (i->text, "This is a line with some ");
487 BOOST_REQUIRE (i != r.end ());
489 BOOST_CHECK_EQUAL (i->text, "font sizing.");
490 BOOST_CHECK (i->font_size.points());
491 BOOST_CHECK_EQUAL (i->font_size.points().get(), 64);
493 BOOST_REQUIRE (i == r.end ());