aboutsummaryrefslogtreecommitdiff
path: root/tests/main.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-05-25 03:58:20 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 06:55:04 +0200
commitbc0b7338ed2d4c126c15eaf57aeb84655e0e1cc3 (patch)
tree0cb334708717bc6304d32320356df64df8f2778c /tests/main.c
parent2f9cf2385a90920b1bcbe6cefa899f33c615e2a5 (diff)
Allow reusing doc for multiple xpath searches
Diffstat (limited to 'tests/main.c')
-rw-r--r--tests/main.c12
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;
}