qdef.h: Rename quvi_verify_t
[libquvi.git] / tests / quvi.c
blob1cc1a35c1550656768b69991d0d2428c9c52163d
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 <stdlib.h>
23 #include <glib.h>
24 #include <quvi.h>
26 #include "tests.h"
28 static void test_quvi_core()
30 gpointer p;
31 quvi_t q;
32 gint n;
34 if (chk_skip(__func__) == TRUE)
35 return;
37 q = quvi_new();
38 g_assert(q != NULL);
39 g_assert_cmpint(qerr(q), ==, QUVI_OK);
40 g_assert_cmpstr(quvi_errmsg(q), ==, "Not an error");
42 /* quvi_get */
44 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &n);
45 g_assert_cmpint(n, ==, 0);
47 quvi_get(q, QUVI_INFO_RESPONSE_CODE-1, &p);
48 g_assert(p == NULL);
50 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &n);
51 g_assert_cmpint(n, ==, 0);
53 quvi_get(q, QUVI_INFO_ERROR_CODE+1, &p);
54 g_assert(p == NULL);
56 quvi_get(q, QUVI_INFO_CURL_HANDLE, &p);
57 g_assert(p != NULL);
58 p = NULL;
60 quvi_get(q, QUVI_INFO_CURL_HANDLE+1, &p);
61 g_assert(p == NULL);
63 /* quvi_set */
65 quvi_set(q, QUVI_OPTION_CALLBACK_STATUS-1, 0);
66 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
68 quvi_set(q, QUVI_OPTION_AUTOPROXY+1, 0);
69 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
71 quvi_free(q);
74 static void test_version()
76 if (chk_skip(__func__) == TRUE)
77 return;
79 if (g_test_trap_fork(0,
80 G_TEST_TRAP_SILENCE_STDOUT|G_TEST_TRAP_SILENCE_STDERR))
82 g_print("%s", quvi_version(QUVI_VERSION));
83 g_printerr("%s", quvi_version(QUVI_VERSION_SCRIPTS));
84 exit(0);
86 g_test_trap_assert_passed();
87 g_test_trap_assert_stdout("v?.?.?*");
88 g_test_trap_assert_stderr("v?.?*");
90 g_assert_cmpstr(quvi_version(QUVI_VERSION_SCRIPTS+1),
91 ==, quvi_version(QUVI_VERSION));
93 g_assert_cmpstr(quvi_version(QUVI_VERSION-1),
94 ==, quvi_version(QUVI_VERSION));
97 gint main(gint argc, gchar **argv)
99 g_test_init(&argc, &argv, NULL);
100 g_test_add_func("/quvi (core)", test_quvi_core);
101 g_test_add_func("/quvi/version", test_version);
102 return (g_test_run());
105 /* vim: set ts=2 sw=2 tw=72 expandtab: */