Bump asdcplib for fix to assertion (DoM #2825).
[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::LC:
134                 s << "lc(8)";
135                 break;
136         case Channel::RC:
137                 s << "rc(9)";
138                 break;
139         case Channel::BSL:
140                 s << "bsl(10)";
141                 break;
142         case Channel::BSR:
143                 s << "bsr(11)";
144                 break;
145         case Channel::MOTION_DATA:
146                 s << "motion_data(12)";
147                 break;
148         case Channel::SYNC_SIGNAL:
149                 s << "sync_signal(13)";
150                 break;
151         case Channel::SIGN_LANGUAGE:
152                 s << "sign_language(14)";
153                 break;
154         case Channel::CHANNEL_COUNT:
155                 s << "(16)";
156                 break;
157         }
158         return s;
159 }
160
161
162 ostream&
163 dcp::operator<< (ostream& s, NoteType t)
164 {
165         switch (t) {
166         case NoteType::PROGRESS:
167                 s << "progress";
168                 break;
169         case NoteType::ERROR:
170                 s << "error";
171                 break;
172         case NoteType::NOTE:
173                 s << "note";
174                 break;
175         }
176         return s;
177 }
178
179
180 ostream&
181 dcp::operator<< (ostream& s, MCASoundField f)
182 {
183         switch (f) {
184         case MCASoundField::FIVE_POINT_ONE:
185                 s << "5.1";
186                 break;
187         case MCASoundField::SEVEN_POINT_ONE:
188                 s << "7.1";
189                 break;
190         case MCASoundField::OTHER:
191                 s << "other";
192                 break;
193         }
194         return s;
195 }
196
197
198 ostream&
199 dcp::operator<< (ostream& s, Standard t)
200 {
201         switch (t) {
202         case Standard::INTEROP:
203                 s << "interop";
204                 break;
205         case Standard::SMPTE:
206                 s << "smpte";
207                 break;
208         }
209         return s;
210 }
211
212
213 ostream&
214 dcp::operator<< (ostream& s, VerificationNote::Type t)
215 {
216         switch (t) {
217         case VerificationNote::Type::OK:
218                 s << "check";
219                 break;
220         case VerificationNote::Type::ERROR:
221                 s << "error";
222                 break;
223         case VerificationNote::Type::BV21_ERROR:
224                 s << "bv21_error";
225                 break;
226         case VerificationNote::Type::WARNING:
227                 s << "warning";
228                 break;
229         }
230         return s;
231 }
232
233
234 ostream&
235 dcp::operator<< (ostream& s, VerificationNote::Code c)
236 {
237         s << static_cast<int>(c);
238         return s;
239 }