1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/* libproxy-test.c
*
* Copyright 2023 The Libproxy Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "proxy.h"
#include <gio/gio.h>
typedef struct {
pxProxyFactory *pf;
} Fixture;
static void
fixture_setup (Fixture *self,
gconstpointer data)
{
self->pf = px_proxy_factory_new ();
}
static void
fixture_teardown (Fixture *fixture,
gconstpointer data)
{
px_proxy_factory_free (fixture->pf);
}
static void
test_libproxy_setup (Fixture *self,
const void *user_data)
{
char **proxies = NULL;
proxies = px_proxy_factory_get_proxies (self->pf, "https://www.example.com");
g_assert_nonnull (proxies);
g_assert_nonnull (proxies[0]);
px_proxy_factory_free_proxies (proxies);
return;
/* FIXME: Fails on Windows */
/* g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Could not query proxy: URI is not absolute, and no base URI was provided"); */
/* proxies = px_proxy_factory_get_proxies (self->pf, "http_unknown://www.example.com"); */
/* g_assert_nonnull (proxies); */
/* g_assert_nonnull (proxies[0]); */
/* px_proxy_factory_free_proxies (proxies); */
}
static void
test_libproxy_dup (Fixture *self,
const void *user_data)
{
pxProxyFactory *dup = g_boxed_copy (PX_TYPE_PROXY_FACTORY, self->pf);
g_assert_nonnull (dup);
px_proxy_factory_free (dup);
}
static void
test_libproxy_illegal_free (Fixture *self,
const void *user_data)
{
px_proxy_factory_free_proxies (NULL);
}
int
main (int argc,
char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add ("/libproxy/setup", Fixture, NULL, fixture_setup, test_libproxy_setup, fixture_teardown);
g_test_add ("/libproxy/dup", Fixture, NULL, fixture_setup, test_libproxy_dup, fixture_teardown);
g_test_add ("/libproxy/illegal_free", Fixture, NULL, fixture_setup, test_libproxy_illegal_free, fixture_teardown);
return g_test_run ();
}
|