aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc/check_template_parser.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-02-21 18:49:24 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-02-21 16:09:40 +0100
commit4cf5dabd31c1c0bba54b36790d4068c39e2ce7d9 (patch)
tree77504e1eedf2df783ef7c962ca4d2f582f65accc /tests/blogc/check_template_parser.c
parentd6830301f215e96328fa4f9a5ad9e253830386c3 (diff)
downloadblogc-4cf5dabd31c1c0bba54b36790d4068c39e2ce7d9.tar.gz
blogc-4cf5dabd31c1c0bba54b36790d4068c39e2ce7d9.tar.bz2
blogc-4cf5dabd31c1c0bba54b36790d4068c39e2ce7d9.zip
blogc: template parser refactoring
mostly names and data structures.
Diffstat (limited to 'tests/blogc/check_template_parser.c')
-rw-r--r--tests/blogc/check_template_parser.c730
1 files changed, 365 insertions, 365 deletions
diff --git a/tests/blogc/check_template_parser.c b/tests/blogc/check_template_parser.c
index afc42f2..a6d9034 100644
--- a/tests/blogc/check_template_parser.c
+++ b/tests/blogc/check_template_parser.c
@@ -17,27 +17,27 @@
static void
-blogc_assert_template_stmt(bc_slist_t *l, const char *value,
- const blogc_template_stmt_type_t type)
+blogc_assert_template_node(bc_slist_t *l, const char *data,
+ const blogc_template_node_type_t type)
{
- blogc_template_stmt_t *stmt = l->data;
- if (value == NULL)
- assert_null(stmt->value);
+ blogc_template_node_t *node = l->data;
+ if (data == NULL)
+ assert_null(node->data[0]);
else
- assert_string_equal(stmt->value, value);
- assert_int_equal(stmt->type, type);
+ assert_string_equal(node->data[0], data);
+ assert_int_equal(node->type, type);
}
static void
-blogc_assert_template_if_stmt(bc_slist_t *l, const char *variable,
- blogc_template_stmt_operator_t operator, const char *operand)
+blogc_assert_template_if_node(bc_slist_t *l, const char *variable,
+ blogc_template_operator_t operator, const char *operand)
{
- blogc_template_stmt_t *stmt = l->data;
- assert_string_equal(stmt->value, variable);
- assert_int_equal(stmt->op, operator);
- assert_string_equal(stmt->value2, operand);
- assert_int_equal(stmt->type, BLOGC_TEMPLATE_IF_STMT);
+ blogc_template_node_t *node = l->data;
+ assert_string_equal(node->data[0], variable);
+ assert_int_equal(node->op, operator);
+ assert_string_equal(node->data[1], operand);
+ assert_int_equal(node->type, BLOGC_TEMPLATE_NODE_IF);
}
@@ -60,68 +60,68 @@ test_template_parse(void **state)
"{%- foreach BOLA %}hahaha{% endforeach %}\n"
"{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
- assert_non_null(stmts);
- blogc_assert_template_stmt(stmts, "Test",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next, "entry",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(stmts->next->next, "",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next, "CHUNDA",
- BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next, "\nbola\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT);
- blogc_assert_template_stmt(tmp->next, "\nbolao", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
+ assert_non_null(ast);
+ blogc_assert_template_node(ast, "Test",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next, "entry",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(ast->next->next, "",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next, "CHUNDA",
+ BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next->next->next->next, "\nbola\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(ast->next->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ bc_slist_t *tmp = ast->next->next->next->next->next->next->next;
+ blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_IFNDEF);
+ blogc_assert_template_node(tmp->next, "\nbolao", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next;
- blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next, "\n", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, "listing",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "BOLA",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "listing_once", BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "asd", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next->next,
- "", BLOGC_TEMPLATE_CONTENT_STMT);
+ blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next, "\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, "listing",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next, "BOLA",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "listing_once", BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "asd", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next->next,
+ "", BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_FOREACH_STMT);
- blogc_assert_template_stmt(tmp->next, "hahaha",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL,
- BLOGC_TEMPLATE_ENDFOREACH_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_if_stmt(tmp->next->next->next->next, "BOLA",
+ blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_FOREACH);
+ blogc_assert_template_node(tmp->next, "hahaha",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDFOREACH);
+ blogc_assert_template_node(tmp->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_if_node(tmp->next->next->next->next, "BOLA",
BLOGC_TEMPLATE_OP_EQ, "\"1\\\"0\"");
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "aee",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ELSE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "fffuuuuuuu", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDIF_STMT);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "aee",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ELSE);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "fffuuuuuuu", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDIF);
assert_null(tmp->next->next->next->next->next->next->next->next->next);
- blogc_template_free_stmts(stmts);
+ blogc_template_free_ast(ast);
}
@@ -144,68 +144,68 @@ test_template_parse_crlf(void **state)
"{%- foreach BOLA %}hahaha{% endforeach %}\r\n"
"{% if BOLA == \"1\\\"0\" %}aee{% else %}fffuuuuuuu{% endif %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
- assert_non_null(stmts);
- blogc_assert_template_stmt(stmts, "Test",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next, "entry",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(stmts->next->next, "",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next, "CHUNDA",
- BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next, "\r\nbola\r\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next, "\r\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_IFNDEF_STMT);
- blogc_assert_template_stmt(tmp->next, "\r\nbolao", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\r\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
+ assert_non_null(ast);
+ blogc_assert_template_node(ast, "Test",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next, "entry",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(ast->next->next, "",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next, "CHUNDA",
+ BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next->next->next->next, "\r\nbola\r\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(ast->next->next->next->next->next->next, "\r\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ bc_slist_t *tmp = ast->next->next->next->next->next->next->next;
+ blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_IFNDEF);
+ blogc_assert_template_node(tmp->next, "\r\nbolao", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next, "\r\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next;
- blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next, "\r\n", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, "listing",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "BOLA",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "\r\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "listing_once", BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "asd", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next->next,
- "", BLOGC_TEMPLATE_CONTENT_STMT);
+ blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next, "\r\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, "listing",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next, "BOLA",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "\r\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "listing_once", BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "asd", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next->next,
+ "", BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "BOLA", BLOGC_TEMPLATE_FOREACH_STMT);
- blogc_assert_template_stmt(tmp->next, "hahaha",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL,
- BLOGC_TEMPLATE_ENDFOREACH_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\r\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_if_stmt(tmp->next->next->next->next, "BOLA",
+ blogc_assert_template_node(tmp, "BOLA", BLOGC_TEMPLATE_NODE_FOREACH);
+ blogc_assert_template_node(tmp->next, "hahaha",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDFOREACH);
+ blogc_assert_template_node(tmp->next->next->next, "\r\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_if_node(tmp->next->next->next->next, "BOLA",
BLOGC_TEMPLATE_OP_EQ, "\"1\\\"0\"");
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "aee",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ELSE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "fffuuuuuuu", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDIF_STMT);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "aee",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ELSE);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "fffuuuuuuu", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDIF);
assert_null(tmp->next->next->next->next->next->next->next->next->next);
- blogc_template_free_stmts(stmts);
+ blogc_template_free_ast(ast);
}
@@ -236,105 +236,105 @@ test_template_parse_html(void **state)
" </body>\n"
"</html>\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
- assert_non_null(stmts);
- blogc_assert_template_stmt(stmts, "<html>\n <head>\n ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next, "entry",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(stmts->next->next,
- "\n <title>My cool blog >> ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next, "TITLE",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next,
- "</title>\n ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next,
- "\n ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next,
- "listing_once", BLOGC_TEMPLATE_BLOCK_STMT);
- bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp,
+ assert_non_null(ast);
+ blogc_assert_template_node(ast, "<html>\n <head>\n ",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next, "entry",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(ast->next->next,
+ "\n <title>My cool blog >> ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next, "TITLE",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(ast->next->next->next->next,
+ "</title>\n ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(ast->next->next->next->next->next->next,
+ "\n ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next->next->next,
+ "listing_once", BLOGC_TEMPLATE_NODE_BLOCK);
+ bc_slist_t *tmp = ast->next->next->next->next->next->next->next->next;
+ blogc_assert_template_node(tmp,
"\n <title>My cool blog - Main page</title>\n ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next,
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next,
"\n </head>\n <body>\n <h1>My cool blog</h1>\n ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "entry",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next,
- "\n <h2>", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next,
- "TITLE", BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "</h2>\n ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "DATE", BLOGC_TEMPLATE_IFDEF_STMT);
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next, "entry",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next,
+ "\n <h2>", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next,
+ "TITLE", BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "</h2>\n ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "DATE", BLOGC_TEMPLATE_NODE_IFDEF);
tmp = tmp->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "<h4>Published in: ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next, "DATE", BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next, "</h4>",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, "\n <pre>",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next,
- "CONTENT", BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "</pre>\n ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
+ blogc_assert_template_node(tmp, "<h4>Published in: ",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next, "DATE", BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next, "</h4>",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next->next, "\n <pre>",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next,
+ "CONTENT", BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "</pre>\n ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
tmp = tmp->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "\n ", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next, "listing_once",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next, "<ul>",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, "\n ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next,
- "listing", BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "<p><a href=\"", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "FILENAME", BLOGC_TEMPLATE_VARIABLE_STMT);
+ blogc_assert_template_node(tmp, "\n ", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next, "listing_once",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next, "<ul>",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next, "\n ",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next,
+ "listing", BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "<p><a href=\"", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "FILENAME", BLOGC_TEMPLATE_NODE_VARIABLE);
tmp = tmp->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, ".html\">", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next, "TITLE",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next, "</a>",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "DATE",
- BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, " - ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "DATE",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- NULL, BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "</p>", BLOGC_TEMPLATE_CONTENT_STMT);
+ blogc_assert_template_node(tmp, ".html\">", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next, "TITLE",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next, "</a>",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next, "DATE",
+ BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(tmp->next->next->next->next, " - ",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "DATE",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ NULL, BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "</p>", BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next, "\n ",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, "listing_once",
- BLOGC_TEMPLATE_BLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "</ul>",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDBLOCK_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next,
- "\n </body>\n</html>\n", BLOGC_TEMPLATE_CONTENT_STMT);
+ blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next, "\n ",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, "listing_once",
+ BLOGC_TEMPLATE_NODE_BLOCK);
+ blogc_assert_template_node(tmp->next->next->next, "</ul>",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDBLOCK);
+ blogc_assert_template_node(tmp->next->next->next->next->next,
+ "\n </body>\n</html>\n", BLOGC_TEMPLATE_NODE_CONTENT);
assert_null(tmp->next->next->next->next->next->next);
- blogc_template_free_stmts(stmts);
+ blogc_template_free_ast(ast);
}
@@ -346,29 +346,29 @@ test_template_parse_ifdef_and_var_outside_block(void **state)
"{{ BOLA }}\n"
"{% ifndef CHUNDA %}{{ CHUNDA }}{% endif %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
- assert_non_null(stmts);
- blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next, "bola",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next, "BOLA",
- BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next,
- "CHUNDA", BLOGC_TEMPLATE_IFNDEF_STMT);
- bc_slist_t *tmp = stmts->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, "CHUNDA", BLOGC_TEMPLATE_VARIABLE_STMT);
- blogc_assert_template_stmt(tmp->next, NULL, BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
+ assert_non_null(ast);
+ blogc_assert_template_node(ast, "GUDA", BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next, "bola",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(ast->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next, "BOLA",
+ BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(ast->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next->next,
+ "CHUNDA", BLOGC_TEMPLATE_NODE_IFNDEF);
+ bc_slist_t *tmp = ast->next->next->next->next->next->next->next;
+ blogc_assert_template_node(tmp, "CHUNDA", BLOGC_TEMPLATE_NODE_VARIABLE);
+ blogc_assert_template_node(tmp->next, NULL, BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
assert_null(tmp->next->next->next);
- blogc_template_free_stmts(stmts);
+ blogc_template_free_ast(ast);
}
@@ -393,50 +393,50 @@ test_template_parse_nested_else(void **state)
"{% endif %}\n"
"{% endif %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_null(err);
- assert_non_null(stmts);
- blogc_assert_template_stmt(stmts, "GUDA", BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next, "\n", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next, "BOLA", BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next, "\nasd\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ELSE_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next,
- "CHUNDA", BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(stmts->next->next->next->next->next->next->next,
- "\nqwe\n", BLOGC_TEMPLATE_CONTENT_STMT);
- bc_slist_t *tmp = stmts->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ELSE_STMT);
- blogc_assert_template_stmt(tmp->next, "\nrty\n", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next,
- "LOL", BLOGC_TEMPLATE_IFDEF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next->next->next,
- "\nzxc\n", BLOGC_TEMPLATE_CONTENT_STMT);
+ assert_non_null(ast);
+ blogc_assert_template_node(ast, "GUDA", BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next, "\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next, "BOLA", BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next->next->next, "\nasd\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ELSE);
+ blogc_assert_template_node(ast->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(ast->next->next->next->next->next->next,
+ "CHUNDA", BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(ast->next->next->next->next->next->next->next,
+ "\nqwe\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ bc_slist_t *tmp = ast->next->next->next->next->next->next->next->next;
+ blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ELSE);
+ blogc_assert_template_node(tmp->next, "\nrty\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next,
+ "LOL", BLOGC_TEMPLATE_NODE_IFDEF);
+ blogc_assert_template_node(tmp->next->next->next->next->next->next->next,
+ "\nzxc\n", BLOGC_TEMPLATE_NODE_CONTENT);
tmp = tmp->next->next->next->next->next->next->next->next;
- blogc_assert_template_stmt(tmp, NULL, BLOGC_TEMPLATE_ELSE_STMT);
- blogc_assert_template_stmt(tmp->next, "\nbnm\n", BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next, NULL,
- BLOGC_TEMPLATE_ENDIF_STMT);
- blogc_assert_template_stmt(tmp->next->next->next->next->next, "\n",
- BLOGC_TEMPLATE_CONTENT_STMT);
+ blogc_assert_template_node(tmp, NULL, BLOGC_TEMPLATE_NODE_ELSE);
+ blogc_assert_template_node(tmp->next, "\nbnm\n", BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
+ blogc_assert_template_node(tmp->next->next->next->next, NULL,
+ BLOGC_TEMPLATE_NODE_ENDIF);
+ blogc_assert_template_node(tmp->next->next->next->next->next, "\n",
+ BLOGC_TEMPLATE_NODE_CONTENT);
assert_null(tmp->next->next->next->next->next->next);
- blogc_template_free_stmts(stmts);
+ blogc_template_free_ast(ast);
}
@@ -445,9 +445,9 @@ test_template_parse_invalid_block_start(void **state)
{
const char *a = "{% ASD %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must begin with lowercase letter.\n"
@@ -455,9 +455,9 @@ test_template_parse_invalid_block_start(void **state)
bc_error_free(err);
a = "{%-- block entry %}\n";
err = NULL;
- stmts = blogc_template_parse(a, strlen(a), &err);
+ ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Duplicated whitespace cleaner before statement.\n"
@@ -465,9 +465,9 @@ test_template_parse_invalid_block_start(void **state)
bc_error_free(err);
a = "{% block entry --%}\n";
err = NULL;
- stmts = blogc_template_parse(a, strlen(a), &err);
+ ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Duplicated whitespace cleaner after statement.\n"
@@ -483,9 +483,9 @@ test_template_parse_invalid_block_nested(void **state)
"{% block entry %}\n"
"{% block listing %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Blocks can't be nested.\n"
@@ -501,9 +501,9 @@ test_template_parse_invalid_foreach_nested(void **state)
"{% foreach A %}\n"
"{% foreach B %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'foreach' statements can't be nested.\n"
@@ -517,9 +517,9 @@ test_template_parse_invalid_block_not_open(void **state)
{
const char *a = "{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endblock' statement without an open 'block' statement.\n"
@@ -533,9 +533,9 @@ test_template_parse_invalid_endif_not_open(void **state)
{
const char *a = "{% block listing %}{% endif %}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endif' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n"
@@ -550,9 +550,9 @@ test_template_parse_invalid_endif_not_open_inside_block(void **state)
{
const char *a = "{% ifdef BOLA %}{% block listing %}{% endif %}{% endblock %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endif' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n"
@@ -567,9 +567,9 @@ test_template_parse_invalid_else_not_open_inside_block(void **state)
{
const char *a = "{% ifdef BOLA %}{% block listing %}{% else %}{% endif %}{% endblock %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'else' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n"
@@ -584,9 +584,9 @@ test_template_parse_invalid_endforeach_not_open(void **state)
{
const char *a = "{% endforeach %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endforeach' statement without an open 'foreach' statement.\n"
@@ -601,9 +601,9 @@ test_template_parse_invalid_endforeach_not_open_inside_block(void **state)
const char *a = "{% foreach TAGS %}{% block entry %}{% endforeach %}"
"{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endforeach' statement without an open 'foreach' statement.\n"
@@ -619,9 +619,9 @@ test_template_parse_invalid_endforeach_not_open_inside_block2(void **state)
const char *a = "{% block entry %}{% foreach TAGS %}"
"{% endforeach %}{% endforeach %}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'endforeach' statement without an open 'foreach' statement.\n"
@@ -637,9 +637,9 @@ test_template_parse_invalid_endforeach_not_closed_inside_block(void **state)
const char *a = "{% block entry %}{% foreach TAGS %}{% endblock %}"
"{% endforeach %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"An open 'foreach' statement was not closed inside a 'entry' block!");
@@ -653,9 +653,9 @@ test_template_parse_invalid_endforeach_not_closed_inside_block2(void **state)
const char *a = "{% block entry %}{% foreach TAGS %}{% endforeach %}"
"{% foreach TAGS %}{% endblock %}{% endforeach %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"An open 'foreach' statement was not closed inside a 'entry' block!");
@@ -668,9 +668,9 @@ test_template_parse_invalid_block_name(void **state)
{
const char *a = "{% chunda %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement type: Allowed types are: 'block', 'endblock', 'if', "
@@ -685,9 +685,9 @@ test_template_parse_invalid_block_type_start(void **state)
{
const char *a = "{% block ENTRY %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid block syntax. Must begin with lowercase letter.\n"
@@ -701,9 +701,9 @@ test_template_parse_invalid_block_type(void **state)
{
const char *a = "{% block chunda %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid block type. Allowed types are: 'entry', 'listing' and 'listing_once'.\n"
@@ -717,9 +717,9 @@ test_template_parse_invalid_ifdef_start(void **state)
{
const char *a = "{% block entry %}{% ifdef guda %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
@@ -734,9 +734,9 @@ test_template_parse_invalid_foreach_start(void **state)
{
const char *a = "{% block entry %}{% foreach guda %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must begin with uppercase letter.\n"
@@ -751,9 +751,9 @@ test_template_parse_invalid_ifdef_variable(void **state)
{
const char *a = "{% block entry %}{% ifdef BoLA %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must be uppercase letter, number or '_'.\n"
@@ -768,9 +768,9 @@ test_template_parse_invalid_ifdef_variable2(void **state)
{
const char *a = "{% block entry %}{% ifdef 0123 %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
@@ -785,9 +785,9 @@ test_template_parse_invalid_foreach_variable(void **state)
{
const char *a = "{% block entry %}{% foreach BoLA %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must be uppercase letter, number or '_'.\n"
@@ -802,9 +802,9 @@ test_template_parse_invalid_foreach_variable2(void **state)
{
const char *a = "{% block entry %}{% foreach 0123 %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid foreach variable name. Must begin with uppercase letter.\n"
@@ -819,9 +819,9 @@ test_template_parse_invalid_if_operator(void **state)
{
const char *a = "{% block entry %}{% if BOLA = \"asd\" %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operator. Must be '<', '>', '<=', '>=', '==' or '!='.\n"
@@ -836,9 +836,9 @@ test_template_parse_invalid_if_operand(void **state)
{
const char *a = "{% block entry %}{% if BOLA == asd %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operand. Must be double-quoted static string or variable.\n"
@@ -853,9 +853,9 @@ test_template_parse_invalid_if_operand2(void **state)
{
const char *a = "{% block entry %}{% if BOLA == \"asd %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Found an open double-quoted string.\n"
@@ -870,9 +870,9 @@ test_template_parse_invalid_if_operand3(void **state)
{
const char *a = "{% block entry %}{% if BOLA == 0123 %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid 'if' operand. Must be double-quoted static string or variable.\n"
@@ -887,9 +887,9 @@ test_template_parse_invalid_else1(void **state)
{
const char *a = "{% else %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"'else' statement without an open 'if', 'ifdef' or 'ifndef' statement.\n"
@@ -903,9 +903,9 @@ test_template_parse_invalid_else2(void **state)
{
const char *a = "{% if BOLA == \"123\" %}{% if GUDA == \"1\" %}{% else %}{% else %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"More than one 'else' statement for an open 'if', 'ifdef' or 'ifndef' "
@@ -927,9 +927,9 @@ test_template_parse_invalid_else3(void **state)
"{% else %}\n"
"{% else %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"More than one 'else' statement for an open 'if', 'ifdef' or 'ifndef' "
@@ -943,9 +943,9 @@ test_template_parse_invalid_block_end(void **state)
{
const char *a = "{% block entry }}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '%}'.\n"
@@ -959,9 +959,9 @@ test_template_parse_invalid_variable_name(void **state)
{
const char *a = "{% block entry %}{{ bola }}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
@@ -976,9 +976,9 @@ test_template_parse_invalid_variable_name2(void **state)
{
const char *a = "{% block entry %}{{ Bola }}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must be uppercase letter, number or '_'.\n"
@@ -993,9 +993,9 @@ test_template_parse_invalid_variable_name3(void **state)
{
const char *a = "{% block entry %}{{ 0123 }}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid variable name. Must begin with uppercase letter.\n"
@@ -1010,9 +1010,9 @@ test_template_parse_invalid_variable_end(void **state)
{
const char *a = "{% block entry %}{{ BOLA %}{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}}'.\n"
@@ -1027,9 +1027,9 @@ test_template_parse_invalid_close(void **state)
{
const char *a = "{% block entry %%\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}'.\n"
@@ -1043,9 +1043,9 @@ test_template_parse_invalid_close2(void **state)
{
const char *a = "{% block entry %}{{ BOLA }%{% endblock %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"Invalid statement syntax. Must end with '}'.\n"
@@ -1060,9 +1060,9 @@ test_template_parse_invalid_endif_not_closed(void **state)
{
const char *a = "{% block entry %}{% endblock %}{% ifdef BOLA %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "1 open 'if', 'ifdef' and/or 'ifndef' statements "
"were not closed!");
@@ -1075,9 +1075,9 @@ test_template_parse_invalid_endif_not_closed_inside_block(void **state)
{
const char *a = "{% block listing %}{% ifdef BOLA %}{% endblock %}{% endif %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"1 open 'if', 'ifdef' and/or 'ifndef' statements were not closed inside "
@@ -1091,9 +1091,9 @@ test_template_parse_invalid_else_not_closed_inside_block(void **state)
{
const char *a = "{% block listing %}{% ifdef BOLA %}{% else %}{% endblock %}{% endif %}";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg,
"1 open 'if', 'ifdef' and/or 'ifndef' statements were not closed inside "
@@ -1107,9 +1107,9 @@ test_template_parse_invalid_block_not_closed(void **state)
{
const char *a = "{% block entry %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "An open block was not closed!");
bc_error_free(err);
@@ -1121,9 +1121,9 @@ test_template_parse_invalid_foreach_not_closed(void **state)
{
const char *a = "{% foreach ASD %}\n";
bc_error_t *err = NULL;
- bc_slist_t *stmts = blogc_template_parse(a, strlen(a), &err);
+ bc_slist_t *ast = blogc_template_parse(a, strlen(a), &err);
assert_non_null(err);
- assert_null(stmts);
+ assert_null(ast);
assert_int_equal(err->type, BLOGC_ERROR_TEMPLATE_PARSER);
assert_string_equal(err->msg, "An open 'foreach' statement was not closed!");
bc_error_free(err);