Fix binary STL output with subs that are too big for a single TTI block.
[libsub.git] / test / vertical_position_test.cc
1 /*
2     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include "vertical_position.h"
21 #include <boost/test/unit_test.hpp>
22
23 using boost::optional;
24
25 /* Test operator< for VerticalPosition */
26 BOOST_AUTO_TEST_CASE (vertical_position_test)
27 {
28         sub::VerticalPosition a;
29         sub::VerticalPosition b;
30
31         /* Simple */
32
33         a.proportional = 0.3;
34         a.reference = sub::TOP_OF_SCREEN;
35         b.proportional = 0.4;
36         b.reference = sub::TOP_OF_SCREEN;
37         BOOST_CHECK (a < b);
38
39         a.proportional = 0.5;
40         a.reference = sub::TOP_OF_SCREEN;
41         b.proportional = 0.1;
42         b.reference = sub::TOP_OF_SCREEN;
43         BOOST_CHECK (b < a);
44
45         a.proportional = optional<float> ();
46         b.proportional = optional<float> ();
47
48         a.line = 4;
49         a.lines = 25;
50         a.reference = sub::TOP_OF_SCREEN;
51         b.line = 6;
52         b.lines = 25;
53         b.reference = sub::TOP_OF_SCREEN;
54         BOOST_CHECK (a < b);
55
56         a.line = 17;
57         a.lines = 25;
58         a.reference = sub::TOP_OF_SCREEN;
59         b.line = 2;
60         b.lines = 25;
61         b.reference = sub::TOP_OF_SCREEN;
62         BOOST_CHECK (b < a);
63
64         /* Different reference points with proportional */
65
66         a.line = optional<int> ();
67         a.lines = optional<int> ();
68         b.line = optional<int> ();
69         b.lines = optional<int> ();
70
71         a.proportional = 0.7;
72         a.reference = sub::TOP_OF_SCREEN;
73         b.proportional = 0.3;
74         b.reference = sub::VERTICAL_CENTRE_OF_SCREEN;
75         BOOST_CHECK (a < b);
76
77         a.proportional = 0.9;
78         a.reference = sub::BOTTOM_OF_SCREEN;
79         b.proportional = 0.1;
80         b.reference = sub::TOP_OF_SCREEN;
81         BOOST_CHECK (b < a);
82
83         /* Different line counts with lines */
84
85         a.proportional = optional<float> ();
86         b.proportional = optional<float> ();
87
88         a.line = 12;
89         a.lines = 99;
90         a.reference = sub::TOP_OF_SCREEN;
91         b.line = 12;
92         b.lines = 25;
93         b.reference = sub::TOP_OF_SCREEN;
94         BOOST_CHECK (a < b);
95 }