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()
34 if (chk_skip(__func__
) == TRUE
)
39 g_assert_cmpint(qerr(q
), ==, QUVI_OK
);
41 g_assert_cmpstr(quvi_errmsg(q
), ==, "No error");
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
);
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
);
57 quvi_get(q
, QUVI_INFO_CURL_HANDLE
, &p
);
61 quvi_get(q
, QUVI_INFO_CURL_HANDLE
+1, &p
);
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
);
75 static void test_version()
77 if (chk_skip(__func__
) == TRUE
)
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
));
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", test_quvi
);
102 g_test_add_func("/quvi/version", test_version
);
103 return (g_test_run());
106 /* vim: set ts=2 sw=2 tw=72 expandtab: */