tests/lib/: Change license header
[libquvi-scripts.git] / tests / lib / tests.h
blob214fa77b8f1b1deb9ec457bc3f6eb564aaedea15
1 /* libquvi-scripts
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi-scripts <http://quvi.sourceforge.net>.
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This program 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 Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #ifndef tests_h
22 #define tests_h
24 /* qerr.c */
26 glong qerr(quvi_t);
28 /* env.c */
30 gboolean chk_env(const gchar*, const gchar*);
31 gboolean chk_skip(const gchar*);
32 void chk_verbose(quvi_t);
33 gboolean chk_geoblocked();
34 gboolean chk_complete();
35 gboolean chk_fixme();
36 gboolean chk_nsfw();
38 /* Media. */
40 struct qm_test_exact_s
42 const gchar *title;
43 const gchar *id;
45 typedef struct qm_test_exact_s *qm_test_exact_t;
47 struct qm_test_opts_s
49 struct /* String value length >0 */
51 struct /* stream */
53 struct /* video */
55 gboolean encoding;
56 } video;
57 struct /* audio */
59 gboolean encoding;
60 } audio;
61 gboolean container;
62 } stream;
63 } s_len_gt0;
64 struct /* >0 (numeric) */
66 struct /* stream */
68 struct /* video */
70 gboolean bitrate_kbit_s;
71 gboolean height;
72 gboolean width;
73 } video;
74 struct
76 gboolean bitrate_kbit_s;
77 } audio;
78 } stream;
79 gboolean start_time_ms;
80 gboolean duration_ms;
81 } gt0;
83 typedef struct qm_test_opts_s *qm_test_opts_t;
85 /* Compare media property string values. */
86 #define qm_cmp_s(qmp, e)\
87 do {\
88 gchar *s = NULL;\
89 quvi_media_get(qm, qmp, &s);\
90 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
91 g_assert(s != NULL);\
92 g_test_message("%s=%s", #qmp, s);\
93 g_assert_cmpstr(s, ==, e);\
94 } while (0)
96 /* Media property string value length >0 */
97 #define qm_chk_l(qmp)\
98 do {\
99 gchar *s = NULL;\
100 quvi_media_get(qm, qmp, &s);\
101 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
102 g_assert(s != NULL);\
103 g_test_message("%s=%s", #qmp, s);\
104 g_assert_cmpint(strlen(s), >, 0);\
105 } while (0)
107 /* Media property value (double) >0 */
108 #define qm_chk_gt0(qmp)\
109 do {\
110 gdouble v = 0;\
111 quvi_media_get(qm, qmp, &v);\
112 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
113 g_test_message("%s=%g", #qmp, v);\
114 g_assert_cmpfloat(v, >, 0);\
115 } while (0)
117 void qm_test(const gchar*, const gchar*,
118 const qm_test_exact_t, const qm_test_opts_t);
120 /* Playlist. */
122 struct qp_test_exact_s
124 const gchar *id;
126 typedef struct qp_test_exact_s *qp_test_exact_t;
128 struct qp_test_opts_s
130 struct
132 struct
134 gboolean title;
135 } media;
136 gboolean thumbnail_url;
137 gboolean title;
138 } s_len_gt0;
139 struct
141 struct
143 gboolean duration_ms;
144 } media;
145 } gt0;
147 typedef struct qp_test_opts_s *qp_test_opts_t;
149 /* Compare playlist property string values. */
150 #define qp_cmp_s(qpp, e)\
151 do {\
152 gchar *s = NULL;\
153 quvi_playlist_get(qp, qpp, &s);\
154 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
155 g_assert(s != NULL);\
156 g_test_message("%s=%s", #qpp, s);\
157 g_assert_cmpstr(s, ==, e);\
158 } while (0)
160 /* Playist property string value length >0 */
161 #define qp_chk_l(qpp)\
162 do {\
163 gchar *s = NULL;\
164 quvi_playlist_get(qp, qpp, &s);\
165 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
166 g_assert(s != NULL);\
167 g_test_message("%s=%s", #qpp, s);\
168 g_assert_cmpint(strlen(s), >, 0);\
169 } while (0)
171 /* Media property value (double) >0 */
172 #define qp_chk_gt0(qpp)\
173 do {\
174 gdouble v = 0;\
175 quvi_playlist_get(qp, qpp, &v);\
176 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
177 g_test_message("%s=%g", #qpp, v);\
178 g_assert_cmpfloat(v, >, 0);\
179 } while (0)
181 void qp_test(const gchar*, const gchar*,
182 const qp_test_exact_t, const qp_test_opts_t);
184 /* Scan. */
186 struct qs_test_exact_s
188 const gchar *url;
189 const gint n; /* Expected no. of returned media URLs. */
191 typedef struct qs_test_exact_s *qs_test_exact_t;
193 void qs_test(const gchar*, qs_test_exact_t);
195 /* Other. */
197 gboolean match(const gchar*, const gchar*);
198 gchar *capture(const gchar*, const gchar*);
199 gchar *fetch(const gchar*);
201 #endif /* tests_h */
203 /* vim: set ts=2 sw=2 tw=72 expandtab: */