Add missing operator case.
[libdcp.git] / test / stream_operators.cc
1 /*
2     Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34
35 /** @file  test/stream_operators.cc
36  *  @brief A collection of operator<< methods so that we can use boost test macros with libdcp's types.
37  */
38
39
40 #include "stream_operators.h"
41 #include "types.h"
42 #include "verify.h"
43 #include <iostream>
44
45
46 using std::ostream;
47
48
49 ostream&
50 dcp::operator<< (ostream& s, Size const & a)
51 {
52         s << a.width << "x" << a.height;
53         return s;
54 }
55
56
57 ostream&
58 dcp::operator<< (ostream& s, Fraction const & f)
59 {
60         s << f.numerator << "/" << f.denominator;
61         return s;
62 }
63
64
65 ostream &
66 dcp::operator<< (ostream& s, Colour const & c)
67 {
68         s << "(" << c.r << ", " << c.g << ", " << c.b << ")";
69         return s;
70 }
71
72
73 ostream&
74 dcp::operator<< (std::ostream& s, Effect e)
75 {
76         s << effect_to_string(e);
77         return s;
78 }
79
80
81 ostream&
82 dcp::operator<< (ostream& s, ContentKind c)
83 {
84         s << c.name();
85         return s;
86 }
87
88
89 ostream &
90 dcp::operator<< (ostream& s, Rating const & r)
91 {
92         s << r.agency << " " << r.label;
93         return s;
94 }
95
96
97 ostream&
98 dcp::operator<<(ostream& s, Status t)
99 {
100         s << status_to_string(t);
101         return s;
102 }
103
104
105 ostream&
106 dcp::operator<<(ostream& s, Channel c)
107 {
108         switch (c) {
109         case Channel::LEFT:
110                 s << "left(0)";
111                 break;
112         case Channel::RIGHT:
113                 s << "right(1)";
114                 break;
115         case Channel::CENTRE:
116                 s << "centre(2)";
117                 break;
118         case Channel::LFE:
119                 s << "lfe(3)";
120                 break;
121         case Channel::LS:
122                 s << "ls(4)";
123                 break;
124         case Channel::RS:
125                 s << "rs(5)";
126                 break;
127         case Channel::HI:
128                 s << "hi(6)";
129                 break;
130         case Channel::VI:
131                 s << "vi(7)";
132                 break;
133         case Channel::BSL:
134                 s << "bsl(10)";
135                 break;
136         case Channel::BSR:
137                 s << "bsr(11)";
138                 break;
139         case Channel::MOTION_DATA:
140                 s << "motion_data(12)";
141                 break;
142         case Channel::SYNC_SIGNAL:
143                 s << "sync_signal(13)";
144                 break;
145         case Channel::SIGN_LANGUAGE:
146                 s << "sign_language(14)";
147                 break;
148         case Channel::CHANNEL_COUNT:
149                 s << "(16)";
150                 break;
151         }
152         return s;
153 }
154
155
156 ostream&
157 dcp::operator<< (ostream& s, NoteType t)
158 {
159         switch (t) {
160         case NoteType::PROGRESS:
161                 s << "progress";
162                 break;
163         case NoteType::ERROR:
164                 s << "error";
165                 break;
166         case NoteType::NOTE:
167                 s << "note";
168                 break;
169         }
170         return s;
171 }
172
173
174 ostream&
175 dcp::operator<< (ostream& s, MCASoundField f)
176 {
177         switch (f) {
178         case MCASoundField::FIVE_POINT_ONE:
179                 s << "5.1";
180                 break;
181         case MCASoundField::SEVEN_POINT_ONE:
182                 s << "7.1";
183                 break;
184         case MCASoundField::OTHER:
185                 s << "other";
186                 break;
187         }
188         return s;
189 }
190
191
192 ostream&
193 dcp::operator<< (ostream& s, Standard t)
194 {
195         switch (t) {
196         case Standard::INTEROP:
197                 s << "interop";
198                 break;
199         case Standard::SMPTE:
200                 s << "smpte";
201                 break;
202         }
203         return s;
204 }
205
206
207 ostream&
208 dcp::operator<< (ostream& s, VerificationNote::Type t)
209 {
210         switch (t) {
211         case VerificationNote::Type::ERROR:
212                 s << "error";
213                 break;
214         case VerificationNote::Type::BV21_ERROR:
215                 s << "bv21_error";
216                 break;
217         case VerificationNote::Type::WARNING:
218                 s << "warning";
219                 break;
220         }
221         return s;
222 }
223
224
225 ostream&
226 dcp::operator<< (ostream& s, VerificationNote::Code c)
227 {
228         s << static_cast<int>(c);
229         return s;
230 }