diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2013-08-06 18:05:44 +0300 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2013-08-06 18:05:44 +0300 |
commit | 27b116a64069ba0c0d734073fd33b5fb67958024 (patch) | |
tree | d96f7be107b119467aa9819a16db9b9bf8863fc7 /tests/linkextractor_tests.c | |
parent | 1ea55bb8190e782940ff893ac8d492acabbbc886 (diff) | |
download | vdr-plugin-webvideo-27b116a64069ba0c0d734073fd33b5fb67958024.tar.gz vdr-plugin-webvideo-27b116a64069ba0c0d734073fd33b5fb67958024.tar.bz2 |
Hide duplicate links
Diffstat (limited to 'tests/linkextractor_tests.c')
-rw-r--r-- | tests/linkextractor_tests.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/linkextractor_tests.c b/tests/linkextractor_tests.c index 60deba0..7fe9afc 100644 --- a/tests/linkextractor_tests.c +++ b/tests/linkextractor_tests.c @@ -44,6 +44,17 @@ "<a href=\"" HTML6_HREF "\" title=\"" HTML6_TITLE "\">ignored</a>" \ "</body></html>" +#define HTML_DUPLICATE_HREF1 "http://example.com/test/1" +#define HTML_DUPLICATE_TITLE1 "First link" +#define HTML_DUPLICATE_HREF2 "http://example.com/test/2" +#define HTML_DUPLICATE_TITLE2 "Second link" +#define HTML_DUPLICATE_LINKS "<html><body>" \ + "<a href=\"" HTML_DUPLICATE_HREF1 "\">d1</a>" \ + "<a href=\"" HTML_DUPLICATE_HREF1 "\">" HTML_DUPLICATE_TITLE1 "</a>" \ + "<a href=\"" HTML_DUPLICATE_HREF2 "\">" HTML_DUPLICATE_TITLE2 "</a>" \ + "<a href=\"" HTML_DUPLICATE_HREF2 "\">d2</a>" \ + "</body></html>" + void link_extractor_fixture_setup(LinkExtractorFixture *fixture, gconstpointer test_data) { @@ -175,3 +186,34 @@ void test_link_extractor_title_overrides_content( g_assert(strcmp(title, HTML6_TITLE) == 0); g_ptr_array_free(links, TRUE); } + +void test_link_extractor_remove_duplicates(LinkExtractorFixture *fixture, + gconstpointer test_data) +{ + link_extractor_append(fixture->extractor, HTML_DUPLICATE_LINKS, + strlen(HTML_DUPLICATE_LINKS)); + GPtrArray *links = link_extractor_get_links(fixture->extractor); + g_assert(links); + g_assert(links->len == 2); + + const struct Link *link; + const char *href; + const char *title; + link = g_ptr_array_index(links, 0); + href = link_get_href(link); + g_assert(href); + g_assert(strcmp(href, HTML_DUPLICATE_HREF1) == 0); + title = link_get_title(link); + g_assert(title); + g_assert(strcmp(title, HTML_DUPLICATE_TITLE1) == 0); + + link = g_ptr_array_index(links, 1); + href = link_get_href(link); + g_assert(href); + g_assert(strcmp(href, HTML_DUPLICATE_HREF2) == 0); + title = link_get_title(link); + g_assert(title); + g_assert(strcmp(title, HTML_DUPLICATE_TITLE2) == 0); + + g_ptr_array_free(links, TRUE); +} |