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
|
/*
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 <boost/test/unit_test.hpp>
#include <fstream>
#include "stl_reader.h"
#include "subtitle.h"
using std::list;
using std::ifstream;
/* Test reading of an STL file */
BOOST_AUTO_TEST_CASE (stl_reader_test)
{
ifstream file ("test/data/test.stl");
sub::STLReader reader (file);
list<sub::Subtitle> subs = reader.subtitles ();
list<sub::Subtitle>::iterator i = subs.begin ();
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 0, 41, 9));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 0, 42, 21));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, " This is a subtitle ");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 0, 41, 9));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 0, 42, 21));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, " and that's a line break");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, " This is some ");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, true);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, "bold");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, " and some ");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, true);
BOOST_CHECK_EQUAL (i->italic, true);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, "bold italic");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, " and some ");
++i;
BOOST_CHECK (i != subs.end ());
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, true);
BOOST_CHECK_EQUAL (i->text, "underlined");
++i;
BOOST_CHECK_EQUAL (i->from, sub::Time (0, 1, 1, 1));
BOOST_CHECK_EQUAL (i->to, sub::Time (0, 1, 2, 10));
BOOST_CHECK_EQUAL (i->bold, false);
BOOST_CHECK_EQUAL (i->italic, false);
BOOST_CHECK_EQUAL (i->underline, false);
BOOST_CHECK_EQUAL (i->text, ".");
++i;
BOOST_CHECK (i == subs.end ());
}
|