diff options
author | Aleksi Lindeman <dec05eba@protonmail.com> | 2019-05-25 03:58:20 +0200 |
---|---|---|
committer | Aleksi Lindeman <dec05eba@protonmail.com> | 2019-05-25 03:58:23 +0200 |
commit | c5f4811d0ba74715c8e128da133248cc399a6a6a (patch) | |
tree | 38c50f1a5c8be839d1101bb8b5b7fd13f16ee4a5 /tests | |
parent | 9c52fc54400d706f8f7cdf82d3df2da733862819 (diff) |
Allow reusing doc for multiple xpath searches
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/main.c b/tests/main.c index 5b697a9..4d16ad6 100644 --- a/tests/main.c +++ b/tests/main.c @@ -26,7 +26,17 @@ static void result_callback(QuickMediaHtmlNode *node, void *userdata) { int main(int argc, char **argv) { char *file_content = get_file_content("test_files/test.html"); - int result = quickmedia_html_find_nodes_xpath(file_content, "//h3[class=\"story_name\"]//a", result_callback, NULL); + QuickMediaHtmlSearch html_search; + + int result = quickmedia_html_search_init(&html_search, file_content); + if(result != 0) + goto cleanup; + result = quickmedia_html_find_nodes_xpath(&html_search, "//h3[class=\"story_name\"]//a", result_callback, NULL); + /* Test that the object can be reused without reloading html doc */ + result = quickmedia_html_find_nodes_xpath(&html_search, "//h3[class=\"story_name\"]//a", result_callback, NULL); + + cleanup: + quickmedia_html_search_deinit(&html_search); free(file_content); return result; } |