Skip to content

Commit

Permalink
Added append test for html with input tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
f34nk committed Feb 2, 2020
1 parent aa93666 commit d55b5c7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions test/html_append_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@ int append_multiple_nodes_to_multiple_nodes_test(html_workspace_t* w)
return 0;
}

int append_text_node_to_single_input_node_test(html_workspace_t* w)
{
MODEST_HTML_LOG
const char* html = "<div><input type=\"radio\"></div>";
const char* selector = "div input";

int tree_index = html_parse_tree(w, html, strlen(html));
int selector_index = html_prepare_selector(w, selector, strlen(selector));
const char* scope_name = "body_children";
int collection_index = html_select(w, tree_index, scope_name, selector_index);

const char* new_html = "Radio Button";
int new_tree_index = html_parse_tree(w, new_html, strlen(new_html));
const char* new_scope_name = "body_children";
int new_collection_index = html_select_scope(w, new_tree_index, new_scope_name);

html_append_collection(w, collection_index, new_collection_index);

int buffer_index = html_serialize_collection(w, collection_index);
html_vec_str_t* buffer = html_get_buffer(w, buffer_index);
char* result = html_vec_str_join(buffer, "|");
printf("-> %s\n", result);
if(strcmp(result, "<p>Hello WorldAppend Me</p>") != 0) {
html_free(result);
MODEST_HTML_LOG_ERROR
return 1;
}
html_free(result);

return 0;
}

int append_text_node_to_single_node_test(html_workspace_t* w)
{
MODEST_HTML_LOG
Expand Down Expand Up @@ -102,8 +134,8 @@ int append_text_node_to_single_node_test(html_workspace_t* w)
return 0;
}

#define max_tests 3
int (*test[max_tests])() = {append_multiple_nodes_to_single_node_test, append_multiple_nodes_to_multiple_nodes_test, append_text_node_to_single_node_test};
#define max_tests 4
int (*test[max_tests])() = {append_multiple_nodes_to_single_node_test, append_multiple_nodes_to_multiple_nodes_test, append_text_node_to_single_node_test, append_text_node_to_single_input_node_test};

int main(int argc, char const* argv[])
{
Expand Down

0 comments on commit d55b5c7

Please sign in to comment.