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
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* SPDX-FileCopyrightText: 2017 Sébastien Wilmet <swilmet@gnome.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include <devhelp/devhelp.h>
#define DEVHELP_BOOK_BASE_PATH "/usr/share/gtk-doc/html/devhelp"
static void
check_belongs_to_page_book_link (DhLink *book_link)
{
g_assert (dh_link_belongs_to_page (book_link, "index"));
g_assert (!dh_link_belongs_to_page (book_link, "Index"));
g_assert (!dh_link_belongs_to_page (book_link, ""));
g_assert (!dh_link_belongs_to_page (book_link, "kiwi"));
}
static void
test_belongs_to_page (void)
{
DhLink *book_link;
DhLink *link;
/* index.html */
book_link = dh_link_new_book (DEVHELP_BOOK_BASE_PATH,
"devhelp",
"Devhelp Reference Manual",
"index.html");
check_belongs_to_page_book_link (book_link);
dh_link_unref (book_link);
/* Empty relative_url */
book_link = dh_link_new_book (DEVHELP_BOOK_BASE_PATH,
"devhelp",
"Devhelp Reference Manual",
"");
check_belongs_to_page_book_link (book_link);
/* A function */
link = dh_link_new (DH_LINK_TYPE_FUNCTION,
book_link,
"dh_link_ref",
"DhLink.html#dh-link-ref");
g_assert (dh_link_belongs_to_page (link, "DhLink"));
g_assert (!dh_link_belongs_to_page (link, "dhlink"));
g_assert (!dh_link_belongs_to_page (link, ""));
g_assert (!dh_link_belongs_to_page (link, "kiwi"));
dh_link_unref (book_link);
dh_link_unref (link);
}
int
main (int argc,
char **argv)
{
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/link/belongs_to_page", test_belongs_to_page);
return g_test_run ();
}
|