From c5f4811d0ba74715c8e128da133248cc399a6a6a Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman Date: Sat, 25 May 2019 03:58:20 +0200 Subject: Allow reusing doc for multiple xpath searches --- tests/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') 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; } -- cgit v1.2.3