diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-29 16:42:55 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-29 16:42:55 +0000 |
| commit | d0869653a0bdfa010da0b1b00f83ea89f3abbdb1 (patch) | |
| tree | 45ba336b5396875731c1acbe9be97d80e84a7958 /test | |
| parent | c8c3db36a4593e396681b4acd5e9d318a28b1648 (diff) | |
Various developments.
Diffstat (limited to 'test')
| -rw-r--r-- | test/data/test1.xml | 27 | ||||
| -rwxr-xr-x | test/data/test2.xml | 82 | ||||
| -rw-r--r-- | test/dcp_reader_test.cc | 477 | ||||
| -rw-r--r-- | test/stl_reader_test.cc | 54 | ||||
| -rw-r--r-- | test/stl_writer_test.cc | 53 | ||||
| -rw-r--r-- | test/wscript | 1 |
6 files changed, 640 insertions, 54 deletions
diff --git a/test/data/test1.xml b/test/data/test1.xml new file mode 100644 index 0000000..515dd9f --- /dev/null +++ b/test/data/test1.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<DCSubtitle Version="1.0"> + <SubtitleID>cab5c268-222b-41d2-88ae-6d6999441b17</SubtitleID> + <MovieTitle>Movie Title</MovieTitle> + <ReelNumber>1</ReelNumber> + <Language>French</Language> + <LoadFont Id="theFontId" URI="arial.ttf"/> + <Font Id="theFontId" Color="FFFFFFFF" Effect="border" EffectColor="FF000000" Italic="no" Size="39" Script="normal" Underlined="no" Weight="normal"> + <Subtitle SpotNumber="1" TimeIn="00:00:05:198" TimeOut="00:00:07:115" FadeUpTime="1" FadeDownTime="1"> + <Text VAlign="bottom" VPosition="15.0">My jacket was Idi Amin's</Text> + </Subtitle> + <Font Italic="yes"> + <Subtitle SpotNumber="2" TimeIn="00:00:07:177" TimeOut="00:00:11:031" FadeUpTime="1" FadeDownTime="1"> + <Text VAlign="bottom" VPosition="21.0">My corset was H.M. The Queen's</Text> + <Font Italic="no"> + <Text VAlign="bottom" VPosition="15.0">My large wonderbra</Text> + </Font> + </Subtitle> + </Font> + <Subtitle SpotNumber="3" TimeIn="00:00:11:094" TimeOut="00:00:13:063" FadeUpTime="1" FadeDownTime="1"> + <Text VAlign="bottom" VPosition="15.0">Once belonged to the Shah</Text> + </Subtitle> + <Subtitle SpotNumber="4" TimeIn="00:00:13:104" TimeOut="00:00:15:177" FadeUpTime="1" FadeDownTime="1"> + <Text VAlign="bottom" VPosition="15.0">And these are Roy Hattersley's jeans</Text> + </Subtitle> + </Font> +</DCSubtitle> diff --git a/test/data/test2.xml b/test/data/test2.xml new file mode 100755 index 0000000..c0001b0 --- /dev/null +++ b/test/data/test2.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<DCSubtitle Version="1.0"> + <SubtitleID>notusedforthstest</SubtitleID> + <Language>notusedforthistest</Language> + <MovieTitle>subs2 test</MovieTitle> + <ReelNumber>1</ReelNumber> + <LoadFont Id="theFont" URI="arial.ttf"/> + <Font Id="theFont" Italic="no" Color="FFFFFFFF" Effect="border" EffectColor="FF000000" Size="42"> + <Subtitle SpotNumber="1" TimeIn="00:00:41:062" TimeOut="00:00:43:052" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">At afternoon tea with John Peel</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">I enquired if his accent was real</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="2" TimeIn="00:00:50:042" TimeOut="00:00:52:021" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">He said "out of the house</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">I'm incredibly scouse</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="3" TimeIn="00:01:02:208" TimeOut="00:01:04:010" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">At home it depends how I feel."</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">I spent a long weekend in Brighton</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="4" TimeIn="00:01:15:042" TimeOut="00:01:16:042" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">With the legendary Miss Enid Blyton</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">She said "you be Noddy</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="5" TimeIn="00:01:20:219" TimeOut="00:01:22:073" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">and I'll show you my body"</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">But Big Ears kept turning the light on.</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="6" TimeIn="00:01:27:115" TimeOut="00:01:28:208" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">That curious creature the Sphinx</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">Is smarter than anyone thinks</Text> + </Font> + </Subtitle> + <Subtitle SpotNumber="7" TimeIn="00:01:42:229" TimeOut="00:01:45:062" FadeUpTime="0" FadeDownTime="0"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">It sits there and smirks</Text> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">And you don't think it works</Text> + </Subtitle> + <Subtitle SpotNumber="8" TimeIn="00:01:45:146" TimeOut="00:01:47:094" FadeUpTime="0" FadeDownTime="0"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">Then when you're not looking, it winks.</Text> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">When it snows you will find Sister Sledge</Text> + </Subtitle> + <Subtitle SpotNumber="9" TimeIn="00:01:47:146" TimeOut="00:01:48:167" FadeUpTime="0" FadeDownTime="0"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">Out mooning, at night, on the ledge</Text> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">One storey down</Text> + </Subtitle> + <Subtitle SpotNumber="10" TimeIn="00:01:53:021" TimeOut="00:01:56:010" FadeUpTime="0" FadeDownTime="0"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="-0.5">Is the maestro, James Brown</Text> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="-0.5">Displaying his meat and two veg.</Text> + </Subtitle> + <Subtitle SpotNumber="15" TimeIn="00:02:05:208" TimeOut="00:02:07:031" FadeUpTime="0" FadeDownTime="0"> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="89" ZPosition="0.5">HELLO</Text> + </Font> + <Font Italic="yes"> + <Text HAlign="center" HPosition="0" VAlign="top" VPosition="95" ZPosition="0.5">WORLD</Text> + </Font> + </Subtitle> + </Font> + </DCSubtitle> diff --git a/test/dcp_reader_test.cc b/test/dcp_reader_test.cc new file mode 100644 index 0000000..0029d16 --- /dev/null +++ b/test/dcp_reader_test.cc @@ -0,0 +1,477 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "dcp_reader.h" +#include <boost/test/unit_test.hpp> +#include <fstream> + +using std::list; +using std::cout; +using std::ifstream; +using boost::shared_ptr; + +/* Test reading of a DCP XML file */ +BOOST_AUTO_TEST_CASE (dcp_reader_test1) +{ + ifstream file ("test/data/test1.xml"); + sub::DCPReader reader (file); + list<sub::Subtitle> subs = reader.subtitles (); + + list<sub::Subtitle>::iterator i = subs.begin (); + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (39) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 5, 198 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 7, 115 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.15, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::BOTTOM); + BOOST_CHECK_EQUAL (i->text, "My jacket was Idi Amin's"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 4)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 4)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (39) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 7, 177 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 11, 31 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.21, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::BOTTOM); + BOOST_CHECK_EQUAL (i->text, "My corset was H.M. The Queen's"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 4)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 4)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (39) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 7, 177 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 11, 31 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.15, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::BOTTOM); + BOOST_CHECK_EQUAL (i->text, "My large wonderbra"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 4)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 4)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (39) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 11, 94 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 13, 63 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.15, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::BOTTOM); + BOOST_CHECK_EQUAL (i->text, "Once belonged to the Shah"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 4)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 4)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (39) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 13, 104 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 15, 177 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.15, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::BOTTOM); + BOOST_CHECK_EQUAL (i->text, "And these are Roy Hattersley's jeans"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 4)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 4)); +} + +/* And another one */ +BOOST_AUTO_TEST_CASE (dcp_reader_test2) +{ + ifstream file ("test/data/test2.xml"); + sub::DCPReader reader (file); + list<sub::Subtitle> subs = reader.subtitles (); + + list<sub::Subtitle>::iterator i = subs.begin (); + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 41, 62 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 43, 52 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "At afternoon tea with John Peel"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 41, 62 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 43, 52 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "I enquired if his accent was real"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 50, 42 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 52, 21 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "He said \"out of the house"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric, sub::MetricTime (0, 0, 50, 42 * 4)); + BOOST_CHECK_EQUAL (i->to.metric, sub::MetricTime (0, 0, 52, 21 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "I'm incredibly scouse"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 2, 208 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 04, 10 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "At home it depends how I feel.\""); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 2, 208 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 4, 10 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "I spent a long weekend in Brighton"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 15, 42 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 16, 42 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "With the legendary Miss Enid Blyton"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 15, 42 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 16, 42 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "She said \"you be Noddy"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 20, 219 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 22, 73 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "and I'll show you my body\""); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 20, 219 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 22, 73 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "But Big Ears kept turning the light on."); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 27, 115 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 28, 208 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "That curious creature the Sphinx"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 27, 115 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 28, 208 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "Is smarter than anyone thinks"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 42, 229 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 45, 62 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "It sits there and smirks"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 42, 229 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 45, 62 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "And you don't think it works"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 45, 146 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 47, 94 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "Then when you're not looking, it winks."); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 45, 146 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 47, 94 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "When it snows you will find Sister Sledge"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 47, 146 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 48, 167 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "Out mooning, at night, on the ledge"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 47, 146 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 48, 167 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "One storey down"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 53, 21 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 56, 10 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "Is the maestro, James Brown"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 1, 53, 21 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 1, 56, 10 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "Displaying his meat and two veg."); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 2, 5, 208 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 2, 7, 31 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.89, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "HELLO"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK (i->colour == sub::Colour (1, 1, 1)); + BOOST_CHECK_EQUAL (i->font_size.proportional.get(), float (42) / (72 * 11)); + BOOST_CHECK_EQUAL (i->from.metric.get(), sub::MetricTime (0, 2, 5, 208 * 4)); + BOOST_CHECK_EQUAL (i->to.metric.get(), sub::MetricTime (0, 2, 7, 31 * 4)); + BOOST_CHECK_CLOSE (i->vertical_position.proportional.get(), 0.95, 1); + BOOST_CHECK_EQUAL (i->vertical_position.reference.get(), sub::TOP); + BOOST_CHECK_EQUAL (i->text, "WORLD"); + BOOST_CHECK_EQUAL (i->effect, sub::BORDER); + BOOST_CHECK (i->effect_colour.get() == sub::Colour (0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_up.get(), sub::MetricTime (0, 0, 0, 0)); + BOOST_CHECK_EQUAL (i->fade_down.get(), sub::MetricTime (0, 0, 0, 0)); +} diff --git a/test/stl_reader_test.cc b/test/stl_reader_test.cc index 7481ecf..07e1616 100644 --- a/test/stl_reader_test.cc +++ b/test/stl_reader_test.cc @@ -37,56 +37,56 @@ BOOST_AUTO_TEST_CASE (stl_reader_test) BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, " This is a subtitle "); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); BOOST_CHECK_EQUAL (i->line, 0); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 0, 41, 9)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 0, 42, 21)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 0, 41, 9)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 0, 42, 21)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, " and that's a line break"); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); BOOST_CHECK_EQUAL (i->line, 1); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 0, 41, 9)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 0, 42, 21)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 0, 41, 9)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 0, 42, 21)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, " This is some "); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); BOOST_CHECK_EQUAL (i->line, 0); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, "bold"); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, true); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, " and some "); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); @@ -96,47 +96,47 @@ BOOST_AUTO_TEST_CASE (stl_reader_test) BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, "bold italic"); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, true); BOOST_CHECK_EQUAL (i->italic, true); BOOST_CHECK_EQUAL (i->underline, false); BOOST_CHECK_EQUAL (i->line, 0); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, " and some "); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK (i != subs.end ()); BOOST_CHECK_EQUAL (i->text, "underlined"); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, true); BOOST_CHECK_EQUAL (i->line, 0); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK_EQUAL (i->text, "."); BOOST_CHECK_EQUAL (i->font, "Arial"); - BOOST_CHECK_EQUAL (i->font_size, 42); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); BOOST_CHECK_EQUAL (i->bold, false); BOOST_CHECK_EQUAL (i->italic, false); BOOST_CHECK_EQUAL (i->underline, false); BOOST_CHECK_EQUAL (i->line, 0); - BOOST_CHECK_EQUAL (i->frame_from, sub::FrameTime (0, 1, 1, 1)); - BOOST_CHECK_EQUAL (i->frame_to, sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); ++i; BOOST_CHECK (i == subs.end ()); diff --git a/test/stl_writer_test.cc b/test/stl_writer_test.cc index 5d12169..a9b06e1 100644 --- a/test/stl_writer_test.cc +++ b/test/stl_writer_test.cc @@ -24,40 +24,39 @@ #include "test.h" using std::list; +using std::string; using std::ifstream; using std::ofstream; +static sub::Subtitle +make (string text, bool bold, bool italic, bool underline, int line, sub::FrameTime from, sub::FrameTime to) +{ + sub::Subtitle s; + s.text = text; + s.font = "Arial"; + s.font_size.points = 42; + s.bold = bold; + s.italic = italic; + s.underline = underline; + s.line = line; + s.from.frame = from; + s.to.frame = to; + return s; +} + /* Test writing of an STL file */ BOOST_AUTO_TEST_CASE (stl_writer_test) { list<sub::Subtitle> subs; - subs.push_back ( - sub::Subtitle (" This is a subtitle ", "Arial", 42, false, false, false, 0, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21)) - ); - subs.push_back ( - sub::Subtitle (" and that's a line break", "Arial", 42, false, false, false, 1, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21)) - ); - subs.push_back ( - sub::Subtitle (" This is some ", "Arial", 42, false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle ("bold", "Arial", 42, true, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle (" and some ", "Arial", 42, false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle ("bold italic", "Arial", 42, true, true, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle (" and some ", "Arial", 42, false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle ("underlined", "Arial", 42, false, false, true, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); - subs.push_back ( - sub::Subtitle (".", "Arial", 42, false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)) - ); + subs.push_back (make (" This is a subtitle ", false, false, false, 0, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21))); + subs.push_back (make (" and that's a line break", false, false, false, 1, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21))); + subs.push_back (make (" This is some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make ("bold", true, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make (" and some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make ("bold italic", true, true, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make (" and some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make ("underlined", false, false, true, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); + subs.push_back (make (".", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10))); ofstream f ("build/test/test.stl"); sub::STLWriter writer (subs, f); diff --git a/test/wscript b/test/wscript index 8de63f8..2954352 100644 --- a/test/wscript +++ b/test/wscript @@ -16,6 +16,7 @@ def build(bld): obj.uselib = 'BOOST_TEST' obj.use = 'libsub' obj.source = """ + dcp_reader_test.cc stl_reader_test.cc stl_writer_test.cc test.cc |
