[devhelp] unit-tests: write unit test for dh_link_belongs_to_page()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] unit-tests: write unit test for dh_link_belongs_to_page()
- Date: Thu, 7 Dec 2017 12:41:58 +0000 (UTC)
commit 2caf7664f54516449e67a0420050cbc530abdae0
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Dec 7 13:38:29 2017 +0100
unit-tests: write unit test for dh_link_belongs_to_page()
The first unit test of Devhelp! Champagne!
unit-tests/test-link.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/unit-tests/test-link.c b/unit-tests/test-link.c
index c243f2c..6c77ff6 100644
--- a/unit-tests/test-link.c
+++ b/unit-tests/test-link.c
@@ -17,9 +17,57 @@
#include "devhelp.h"
+#define DEVHELP_BOOK_BASE_PATH "/usr/share/gtk-doc/html/devhelp-3"
+
+static void
+check_belongs_to_page_book_link (DhLink *book_link)
+{
+ g_assert (dh_link_belongs_to_page (book_link, "index", TRUE));
+ g_assert (!dh_link_belongs_to_page (book_link, "Index", TRUE));
+ g_assert (dh_link_belongs_to_page (book_link, "Index", FALSE));
+ g_assert (!dh_link_belongs_to_page (book_link, "", TRUE));
+ g_assert (!dh_link_belongs_to_page (book_link, "kiwi", TRUE));
+ g_assert (!dh_link_belongs_to_page (book_link, "", FALSE));
+ g_assert (!dh_link_belongs_to_page (book_link, "kiwi", FALSE));
+}
+
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", TRUE));
+ g_assert (!dh_link_belongs_to_page (link, "dhlink", TRUE));
+ g_assert (dh_link_belongs_to_page (link, "dhlink", FALSE));
+ g_assert (!dh_link_belongs_to_page (link, "", TRUE));
+ g_assert (!dh_link_belongs_to_page (link, "kiwi", TRUE));
+ g_assert (!dh_link_belongs_to_page (link, "", FALSE));
+ g_assert (!dh_link_belongs_to_page (link, "kiwi", FALSE));
+
+ dh_link_unref (book_link);
+ dh_link_unref (link);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]