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
28 static void test_quvi_core()
34 if (chk_skip(__func__
) == TRUE
)
39 g_assert_cmpint(qerr(q
), ==, QUVI_OK
);
40 g_assert_cmpstr(quvi_errmsg(q
), ==, "Not an error");
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
);
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
);
56 quvi_get(q
, QUVI_INFO_CURL_HANDLE
, &p
);
60 quvi_get(q
, QUVI_INFO_CURL_HANDLE
+1, &p
);
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
);
74 static void test_version()
76 if (chk_skip(__func__
) == TRUE
)
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
));
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: */