m_match_media_script: Remove unused parameter
[libquvi.git] / tests / script.c
blob1c938f443bdb67895f1e59d518dd71612f6eea67
1 /* libquvi
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 #include "config.h"
22 #include <string.h>
23 #include <glib.h>
24 #include <quvi.h>
26 #include "tests.h"
28 static gint count(const quvi_t q, const QuviScriptType t)
30 gint c = 0;
31 while (quvi_script_next(q, t) == QUVI_TRUE)
32 ++c;
33 return (c);
36 static gsize len(const quvi_t q,
37 const QuviScriptType t,
38 const QuviScriptProperty p)
40 gchar *s = NULL;
42 quvi_script_get(q, t, p, &s);
43 g_assert(s != NULL);
45 return (strlen(s));
48 static void test_script()
50 QuviScriptType t;
51 quvi_t q;
53 if (chk_skip(__func__) == TRUE)
54 return;
56 q = quvi_new();
57 g_assert(q != NULL);
58 g_assert_cmpint(qerr(q), ==, QUVI_OK);
60 /* Properties. */
61 for (t=QUVI_SCRIPT_TYPE_PLAYLIST; t<QUVI_SCRIPT_TYPE_SCAN+1; ++t)
63 g_assert_cmpint(count(q, t), >=, 1);
65 while (quvi_script_next(q, t) == QUVI_TRUE)
67 /* Shared with all scripts. */
68 g_assert_cmpint(len(q, t, QUVI_SCRIPT_PROPERTY_FILEPATH), >, 0);
69 g_assert_cmpint(len(q, t, QUVI_SCRIPT_PROPERTY_FILENAME), >, 0);
70 g_assert_cmpint(len(q, t, QUVI_SCRIPT_PROPERTY_SHA1), >, 0);
72 /* Media script specific. */
73 if (t == QUVI_SCRIPT_TYPE_MEDIA || t == QUVI_SCRIPT_TYPE_PLAYLIST)
74 g_assert_cmpint(len(q, t, QUVI_SCRIPT_PROPERTY_DOMAINS),>,0);
78 /* Boundaries */
80 /* Script type. */
82 const gint c = count(q, QUVI_SCRIPT_TYPE_MEDIA);
84 g_assert_cmpint(c, ==, count(q, QUVI_SCRIPT_TYPE_PLAYLIST-1));
85 g_assert_cmpint(c, ==, count(q, QUVI_SCRIPT_TYPE_SCAN+1));
88 /* Property. Do this last (quvi_script_next is called once). */
90 gchar *s;
92 t = QUVI_SCRIPT_TYPE_MEDIA;
93 g_assert(quvi_script_next(q, t) == QUVI_TRUE);
95 quvi_script_get(q, t, QUVI_SCRIPT_PROPERTY_FILEPATH-1, &s);
96 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
98 quvi_script_get(q, t, QUVI_SCRIPT_PROPERTY_SHA1+1, &s);
99 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
102 quvi_free(q);
105 gint main(gint argc, gchar **argv)
107 g_test_init(&argc, &argv, NULL);
108 g_test_add_func("/quvi/script", test_script);
109 return (g_test_run());
112 /* vim: set ts=2 sw=2 tw=72 expandtab: */