2 * Copyright (C) 2012,2013 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/>.
29 static void test_quvi_core()
35 if (chk_skip(__func__
) == TRUE
)
40 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_OK
);
41 g_assert_cmpstr(quvi_errmsg(q
), ==, "Not an error");
42 g_assert_cmpint(quvi_ok(q
), ==, QUVI_TRUE
);
47 quvi_get(q
, QUVI_INFO_RESPONSE_CODE
-1, &n
);
48 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
49 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
50 g_assert_cmpint(n
, ==, 0);
53 quvi_get(q
, QUVI_INFO_RESPONSE_CODE
-1, &p
);
54 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
55 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
59 quvi_get(q
, QUVI_INFO_RESPONSE_CODE
+1, &n
);
60 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
61 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
62 g_assert_cmpint(n
, ==, 0);
65 quvi_get(q
, QUVI_INFO_CURL_HANDLE
, &p
);
66 g_assert_cmpint(quvi_ok(q
), ==, QUVI_TRUE
);
70 quvi_get(q
, QUVI_INFO_CURL_HANDLE
+1, &p
);
71 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
72 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
77 quvi_set(q
, QUVI_OPTION_CALLBACK_STATUS
-1, 0);
78 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
79 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
81 quvi_set(q
, QUVI_OPTION_AUTOPROXY
+1, 0);
82 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_ERROR_INVALID_ARG
);
83 g_assert_cmpint(quvi_ok(q
), ==, QUVI_FALSE
);
88 static void test_version()
90 if (chk_skip(__func__
) == TRUE
)
93 if (g_test_trap_fork(0,
94 G_TEST_TRAP_SILENCE_STDOUT
|G_TEST_TRAP_SILENCE_STDERR
))
96 g_print("%s", quvi_version(QUVI_VERSION
));
97 g_printerr("%s", quvi_version(QUVI_VERSION_SCRIPTS
));
100 g_test_trap_assert_passed();
101 g_test_trap_assert_stdout("v?.?.?*");
102 g_test_trap_assert_stderr("v?.?*");
104 g_assert_cmpstr(quvi_version(QUVI_VERSION_SCRIPTS
+1),
105 ==, quvi_version(QUVI_VERSION
));
107 g_assert_cmpstr(quvi_version(QUVI_VERSION
-1),
108 ==, quvi_version(QUVI_VERSION
));
111 static void test_file_ext()
119 static const struct lookup_s l
[] =
121 {"video/x-flv", "flv"},
122 {"audio/mpeg", "mp3"},
123 {"video/mp4", "mp4"},
132 if (chk_skip(__func__
) == TRUE
)
137 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_OK
);
138 g_assert_cmpint(quvi_ok(q
), ==, QUVI_TRUE
);
141 while (l
[i
].input
!= NULL
)
143 qfe
= quvi_file_ext_new(q
, l
[i
].input
);
144 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_OK
);
145 g_assert_cmpint(quvi_ok(q
), ==, QUVI_TRUE
);
146 g_assert_cmpstr(l
[i
].output
, ==, quvi_file_ext_get(qfe
));
147 quvi_file_ext_free(qfe
);
153 gint
main(gint argc
, gchar
**argv
)
155 g_test_init(&argc
, &argv
, NULL
);
156 g_test_add_func("/quvi (core)", test_quvi_core
);
157 g_test_add_func("/quvi/version", test_version
);
158 g_test_add_func("/quvi/file_ext", test_file_ext
);
159 return (g_test_run());
162 /* vim: set ts=2 sw=2 tw=72 expandtab: */