quvi_supports: Handle QUVI_SUPPORTS_TYPE_SUBTITLE
[libquvi.git] / tests / quvi.c
blob3fa5056e7d9160ed403714b36c8b23e4d29c76f3
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <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 #include "config.h"
23 #include <stdlib.h>
24 #include <glib.h>
25 #include <quvi.h>
27 #include "tests.h"
29 static void test_quvi_core()
31 gpointer p;
32 quvi_t q;
33 gint n;
35 if (chk_skip(__func__) == TRUE)
36 return;
38 q = quvi_new();
39 g_assert(q != NULL);
40 g_assert_cmpint(qerr(q), ==, QUVI_OK);
41 g_assert_cmpstr(quvi_errmsg(q), ==, "Not an error");
43 /* quvi_get */
45 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &n);
46 g_assert_cmpint(n, ==, 0);
48 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &p);
49 g_assert(p == NULL);
51 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &n);
52 g_assert_cmpint(n, ==, 0);
54 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &p);
55 g_assert(p == NULL);
57 quvi_get(q, QUVI_INFO_CURL_HANDLE, &p);
58 g_assert(p != NULL);
59 p = NULL;
61 quvi_get(q, QUVI_INFO_CURL_HANDLE+1, &p);
62 g_assert(p == NULL);
64 /* quvi_set */
66 quvi_set(q, QUVI_OPTION_CALLBACK_STATUS-1, 0);
67 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
69 quvi_set(q, QUVI_OPTION_AUTOPROXY+1, 0);
70 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
72 quvi_free(q);
75 static void test_version()
77 if (chk_skip(__func__) == TRUE)
78 return;
80 if (g_test_trap_fork(0,
81 G_TEST_TRAP_SILENCE_STDOUT|G_TEST_TRAP_SILENCE_STDERR))
83 g_print("%s", quvi_version(QUVI_VERSION));
84 g_printerr("%s", quvi_version(QUVI_VERSION_SCRIPTS));
85 exit(0);
87 g_test_trap_assert_passed();
88 g_test_trap_assert_stdout("v?.?.?*");
89 g_test_trap_assert_stderr("v?.?*");
91 g_assert_cmpstr(quvi_version(QUVI_VERSION_SCRIPTS+1),
92 ==, quvi_version(QUVI_VERSION));
94 g_assert_cmpstr(quvi_version(QUVI_VERSION-1),
95 ==, quvi_version(QUVI_VERSION));
98 gint main(gint argc, gchar **argv)
100 g_test_init(&argc, &argv, NULL);
101 g_test_add_func("/quvi (core)", test_quvi_core);
102 g_test_add_func("/quvi/version", test_version);
103 return (g_test_run());
106 /* vim: set ts=2 sw=2 tw=72 expandtab: */