tests/lib/: Use the intended license
[libquvi-scripts.git] / tests / lib / tests.h
blobdded720b9dbf6602eb04c32fba1853dd796df76a
1 /* libquvi-scripts
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 #ifndef tests_h
21 #define tests_h
23 /* qerr.c */
25 glong qerr(quvi_t);
27 /* env.c */
29 gboolean chk_env(const gchar*, const gchar*);
30 gboolean chk_skip(const gchar*);
31 void chk_verbose(quvi_t);
32 gboolean chk_geoblocked();
33 gboolean chk_complete();
34 gboolean chk_fixme();
35 gboolean chk_nsfw();
37 /* Media. */
39 struct qm_test_exact_s
41 const gchar *title;
42 const gchar *id;
44 typedef struct qm_test_exact_s *qm_test_exact_t;
46 struct qm_test_opts_s
48 struct /* String value length >0 */
50 struct /* stream */
52 struct /* video */
54 gboolean encoding;
55 } video;
56 struct /* audio */
58 gboolean encoding;
59 } audio;
60 gboolean container;
61 } stream;
62 } s_len_gt0;
63 struct /* >0 (numeric) */
65 struct /* stream */
67 struct /* video */
69 gboolean bitrate_kbit_s;
70 gboolean height;
71 gboolean width;
72 } video;
73 struct
75 gboolean bitrate_kbit_s;
76 } audio;
77 } stream;
78 gboolean start_time_ms;
79 gboolean duration_ms;
80 } gt0;
82 typedef struct qm_test_opts_s *qm_test_opts_t;
84 /* Compare media property string values. */
85 #define qm_cmp_s(qmp, e)\
86 do {\
87 gchar *s = NULL;\
88 quvi_media_get(qm, qmp, &s);\
89 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
90 g_assert(s != NULL);\
91 g_test_message("%s=%s", #qmp, s);\
92 g_assert_cmpstr(s, ==, e);\
93 } while (0)
95 /* Media property string value length >0 */
96 #define qm_chk_l(qmp)\
97 do {\
98 gchar *s = NULL;\
99 quvi_media_get(qm, qmp, &s);\
100 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
101 g_assert(s != NULL);\
102 g_test_message("%s=%s", #qmp, s);\
103 g_assert_cmpint(strlen(s), >, 0);\
104 } while (0)
106 /* Media property value (double) >0 */
107 #define qm_chk_gt0(qmp)\
108 do {\
109 gdouble v = 0;\
110 quvi_media_get(qm, qmp, &v);\
111 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
112 g_test_message("%s=%g", #qmp, v);\
113 g_assert_cmpfloat(v, >, 0);\
114 } while (0)
116 void qm_test(const gchar*, const gchar*,
117 const qm_test_exact_t, const qm_test_opts_t);
119 /* Playlist. */
121 struct qp_test_exact_s
123 const gchar *id;
125 typedef struct qp_test_exact_s *qp_test_exact_t;
127 struct qp_test_opts_s
129 struct
131 struct
133 gboolean title;
134 } media;
135 gboolean thumbnail_url;
136 gboolean title;
137 } s_len_gt0;
138 struct
140 struct
142 gboolean duration_ms;
143 } media;
144 } gt0;
146 typedef struct qp_test_opts_s *qp_test_opts_t;
148 /* Compare playlist property string values. */
149 #define qp_cmp_s(qpp, e)\
150 do {\
151 gchar *s = NULL;\
152 quvi_playlist_get(qp, qpp, &s);\
153 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
154 g_assert(s != NULL);\
155 g_test_message("%s=%s", #qpp, s);\
156 g_assert_cmpstr(s, ==, e);\
157 } while (0)
159 /* Playist property string value length >0 */
160 #define qp_chk_l(qpp)\
161 do {\
162 gchar *s = NULL;\
163 quvi_playlist_get(qp, qpp, &s);\
164 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
165 g_assert(s != NULL);\
166 g_test_message("%s=%s", #qpp, s);\
167 g_assert_cmpint(strlen(s), >, 0);\
168 } while (0)
170 /* Media property value (double) >0 */
171 #define qp_chk_gt0(qpp)\
172 do {\
173 gdouble v = 0;\
174 quvi_playlist_get(qp, qpp, &v);\
175 g_assert_cmpint(qerr(q), ==, QUVI_OK);\
176 g_test_message("%s=%g", #qpp, v);\
177 g_assert_cmpfloat(v, >, 0);\
178 } while (0)
180 void qp_test(const gchar*, const gchar*,
181 const qp_test_exact_t, const qp_test_opts_t);
183 /* Scan. */
185 struct qs_test_exact_s
187 const gchar *url;
188 const gint n; /* Expected no. of returned media URLs. */
190 typedef struct qs_test_exact_s *qs_test_exact_t;
192 void qs_test(const gchar*, qs_test_exact_t);
194 /* Other. */
196 gboolean match(const gchar*, const gchar*);
197 gchar *capture(const gchar*, const gchar*);
198 gchar *fetch(const gchar*);
200 #endif /* tests_h */
202 /* vim: set ts=2 sw=2 tw=72 expandtab: */