DOC: Revise QUVI_SCRIPT_PROPERTY_DOMAINS comment
[libquvi.git] / tests / quvi.c
blobd24431caa87ad7a2e8336343d84626da99e5a4d3
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
20 #include <stdlib.h>
21 #include <glib.h>
22 #include <quvi.h>
24 #include "tests.h"
26 static void test_quvi()
28 gpointer p;
29 quvi_t q;
30 gint n;
32 if (chk_skip(__func__) == TRUE)
33 return;
35 q = quvi_new();
36 g_assert(q != NULL);
37 g_assert_cmpint(qerr(q), ==, QUVI_OK);
39 g_assert_cmpstr(quvi_errmsg(q), ==, "No error");
41 /* quvi_get */
43 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &n);
44 g_assert_cmpint(n, ==, 0);
46 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &p);
47 g_assert(p == NULL);
49 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &n);
50 g_assert_cmpint(n, ==, 0);
52 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &p);
53 g_assert(p == NULL);
55 quvi_get(q, QUVI_INFO_CURL_HANDLE, &p);
56 g_assert(p != NULL);
57 p = NULL;
59 quvi_get(q, QUVI_INFO_CURL_HANDLE+1, &p);
60 g_assert(p == NULL);
62 /* quvi_set */
64 quvi_set(q, QUVI_OPTION_MEDIA_SCRIPT_PROTOCOL_CATEGORY-1, 0);
65 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
67 quvi_set(q, QUVI_OPTION_AUTOPROXY+1, 0);
68 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
70 quvi_free(q);
73 static void test_version()
75 if (chk_skip(__func__) == TRUE)
76 return;
78 if (g_test_trap_fork(0,
79 G_TEST_TRAP_SILENCE_STDOUT|G_TEST_TRAP_SILENCE_STDERR))
81 g_print("%s", quvi_version(QUVI_VERSION));
82 g_printerr("%s", quvi_version(QUVI_VERSION_SCRIPTS));
83 exit(0);
85 g_test_trap_assert_passed();
86 g_test_trap_assert_stdout("v?.?.?*");
87 g_test_trap_assert_stderr("v?.?*");
89 g_assert_cmpstr(quvi_version(QUVI_VERSION_SCRIPTS+1),
90 ==, quvi_version(QUVI_VERSION));
92 g_assert_cmpstr(quvi_version(QUVI_VERSION-1),
93 ==, quvi_version(QUVI_VERSION));
96 gint main(gint argc, gchar **argv)
98 g_test_init(&argc, &argv, NULL);
99 g_test_add_func("/quvi", test_quvi);
100 g_test_add_func("/quvi/version", test_version);
101 return (g_test_run());
104 /* vim: set ts=2 sw=2 tw=72 expandtab: */