From 1ea55bb8190e782940ff893ac8d492acabbbc886 Mon Sep 17 00:00:00 2001 From: Antti Ajanki Date: Tue, 6 Aug 2013 16:21:26 +0300 Subject: Show title attribute of when present --- tests/libwebvi_tests.c | 4 ++++ tests/linkextractor_tests.c | 25 ++++++++++++++++++++++--- tests/linkextractor_tests.h | 10 ++++------ 3 files changed, 30 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/libwebvi_tests.c b/tests/libwebvi_tests.c index f754157..4d57a94 100644 --- a/tests/libwebvi_tests.c +++ b/tests/libwebvi_tests.c @@ -41,6 +41,10 @@ int main(int argc, char** argv) g_test_add("/linkextractor/html_title", LinkExtractorFixture, 0, link_extractor_fixture_setup, test_link_extractor_html_title, link_extractor_fixture_teardown); + g_test_add("/linkextractor/html_title", LinkExtractorFixture, 0, + link_extractor_fixture_setup, + test_link_extractor_title_overrides_content, + link_extractor_fixture_teardown); g_test_add_func("/menubuilder/mainmenu", test_mainmenu); g_test_add("/menubuilder/title", MenuBuilderFixture, 0, diff --git a/tests/linkextractor_tests.c b/tests/linkextractor_tests.c index 2aa9166..60deba0 100644 --- a/tests/linkextractor_tests.c +++ b/tests/linkextractor_tests.c @@ -38,6 +38,12 @@ " Test link" \ "" +#define HTML6_HREF "http://example.com/test/link" +#define HTML6_TITLE "Test link" +#define HTML6 "" \ + "ignored" \ + "" + void link_extractor_fixture_setup(LinkExtractorFixture *fixture, gconstpointer test_data) { @@ -152,7 +158,20 @@ void test_link_extractor_html_title(LinkExtractorFixture *fixture, g_ptr_array_free(links, TRUE); } -void test_link_extractor_xml(LinkExtractorFixture *fixture, - gconstpointer test_data) { - +void test_link_extractor_title_overrides_content( + LinkExtractorFixture *fixture, G_GNUC_UNUSED gconstpointer test_data) +{ + GPtrArray *links; + link_extractor_append(fixture->extractor, HTML6, strlen(HTML6)); + links = link_extractor_get_links(fixture->extractor); + g_assert(links); + g_assert(links->len == 1); + const struct Link *link = g_ptr_array_index(links, 0); + const char *href = link_get_href(link); + g_assert(href); + g_assert(strcmp(href, HTML6_HREF) == 0); + const char *title = link_get_title(link); + g_assert(title); + g_assert(strcmp(title, HTML6_TITLE) == 0); + g_ptr_array_free(links, TRUE); } diff --git a/tests/linkextractor_tests.h b/tests/linkextractor_tests.h index 49d2c7f..62cc52f 100644 --- a/tests/linkextractor_tests.h +++ b/tests/linkextractor_tests.h @@ -25,10 +25,8 @@ void test_link_extractor_invalid_html(LinkExtractorFixture *fixture, void test_link_extractor_relative_urls(LinkExtractorFixture *fixture, gconstpointer test_data); void test_link_extractor_html_title(LinkExtractorFixture *fixture, - G_GNUC_UNUSED gconstpointer test_data); - -void test_link_extractor_xml(LinkExtractorFixture *fixture, - gconstpointer test_data); - - + gconstpointer test_data); +void test_link_extractor_title_overrides_content(LinkExtractorFixture *fixture, + gconstpointer test_data); + #endif // LINK_EXTRACTOR_TESTS_H -- cgit v1.2.3