Blame unit-tests/test-link.c

Packit 116408
/*
Packit 116408
 * Copyright (C) 2017 Sébastien Wilmet <swilmet@gnome.org>
Packit 116408
 *
Packit 116408
 * This program is free software; you can redistribute it and/or
Packit 116408
 * modify it under the terms of the GNU General Public License as
Packit 116408
 * published by the Free Software Foundation; either version 2 of the
Packit 116408
 * License, or (at your option) any later version.
Packit 116408
 *
Packit 116408
 * This program is distributed in the hope that it will be useful,
Packit 116408
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 116408
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 116408
 * General Public License for more details.
Packit 116408
 *
Packit 116408
 * You should have received a copy of the GNU General Public License
Packit 116408
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 116408
 */
Packit 116408
Packit 116408
#include "devhelp.h"
Packit 116408
Packit 116408
#define DEVHELP_BOOK_BASE_PATH "/usr/share/gtk-doc/html/devhelp-3"
Packit 116408
Packit 116408
static void
Packit 116408
check_belongs_to_page_book_link (DhLink *book_link)
Packit 116408
{
Packit 116408
        g_assert (dh_link_belongs_to_page (book_link, "index"));
Packit 116408
        g_assert (!dh_link_belongs_to_page (book_link, "Index"));
Packit 116408
        g_assert (!dh_link_belongs_to_page (book_link, ""));
Packit 116408
        g_assert (!dh_link_belongs_to_page (book_link, "kiwi"));
Packit 116408
}
Packit 116408
Packit 116408
static void
Packit 116408
test_belongs_to_page (void)
Packit 116408
{
Packit 116408
        DhLink *book_link;
Packit 116408
        DhLink *link;
Packit 116408
Packit 116408
        /* index.html */
Packit 116408
        book_link = dh_link_new_book (DEVHELP_BOOK_BASE_PATH,
Packit 116408
                                      "devhelp",
Packit 116408
                                      "Devhelp Reference Manual",
Packit 116408
                                      "index.html");
Packit 116408
        check_belongs_to_page_book_link (book_link);
Packit 116408
        dh_link_unref (book_link);
Packit 116408
Packit 116408
        /* Empty relative_url */
Packit 116408
        book_link = dh_link_new_book (DEVHELP_BOOK_BASE_PATH,
Packit 116408
                                      "devhelp",
Packit 116408
                                      "Devhelp Reference Manual",
Packit 116408
                                      "");
Packit 116408
        check_belongs_to_page_book_link (book_link);
Packit 116408
Packit 116408
        /* A function */
Packit 116408
        link = dh_link_new (DH_LINK_TYPE_FUNCTION,
Packit 116408
                            book_link,
Packit 116408
                            "dh_link_ref",
Packit 116408
                            "DhLink.html#dh-link-ref");
Packit 116408
Packit 116408
        g_assert (dh_link_belongs_to_page (link, "DhLink"));
Packit 116408
        g_assert (!dh_link_belongs_to_page (link, "dhlink"));
Packit 116408
        g_assert (!dh_link_belongs_to_page (link, ""));
Packit 116408
        g_assert (!dh_link_belongs_to_page (link, "kiwi"));
Packit 116408
Packit 116408
        dh_link_unref (book_link);
Packit 116408
        dh_link_unref (link);
Packit 116408
}
Packit 116408
Packit 116408
int
Packit 116408
main (int    argc,
Packit 116408
      char **argv)
Packit 116408
{
Packit 116408
        g_test_init (&argc, &argv, NULL);
Packit 116408
Packit 116408
        g_test_add_func ("/link/belongs_to_page", test_belongs_to_page);
Packit 116408
Packit 116408
        return g_test_run ();
Packit 116408
}