diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-12-23 23:45:54 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-12-23 23:45:54 +0100 |
commit | 14e9d7b2299f15efb695b0202f9c1f6a9f7a4ba6 (patch) | |
tree | 31b3d9a6f9f6144b08b852d016b5b4bdfce553ef /tests/check_renderer.c | |
parent | 8e62072d91193b4894adda9c40544c18c1a01f57 (diff) | |
download | blogc-14e9d7b2299f15efb695b0202f9c1f6a9f7a4ba6.tar.gz blogc-14e9d7b2299f15efb695b0202f9c1f6a9f7a4ba6.tar.bz2 blogc-14e9d7b2299f15efb695b0202f9c1f6a9f7a4ba6.zip |
Revert "build: removing src/utils and replacing with squareball"
This reverts commit 950e6c9148eca244a89d18a21d4ae4e5c3d1c646.
Diffstat (limited to 'tests/check_renderer.c')
-rw-r--r-- | tests/check_renderer.c | 224 |
1 files changed, 112 insertions, 112 deletions
diff --git a/tests/check_renderer.c b/tests/check_renderer.c index 802b159..cb8f8f1 100644 --- a/tests/check_renderer.c +++ b/tests/check_renderer.c @@ -19,10 +19,10 @@ #include "../src/renderer.h" #include "../src/source-parser.h" #include "../src/template-parser.h" -#include <squareball.h> +#include "../src/utils/utils.h" -static sb_slist_t* +static b_slist_t* create_sources(unsigned int count) { const char *s[] = { @@ -46,12 +46,12 @@ create_sources(unsigned int count) }; assert_false(count > 3); blogc_error_t *err = NULL; - sb_slist_t *l = NULL; + b_slist_t *l = NULL; for (unsigned int i = 0; i < count; i++) { - l = sb_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err)); + l = b_slist_append(l, blogc_source_parse(s[i], strlen(s[i]), &err)); assert_null(err); } - assert_int_equal(sb_slist_length(l), count); + assert_int_equal(b_slist_length(l), count); return l; } @@ -76,10 +76,10 @@ test_render_entry(void **state) "{% if GUDA > \"zxd\" %}LOL3{% endif %}\n" "{% if GUDA <= \"zxc\" %}LOL4{% endif %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -99,7 +99,7 @@ test_render_entry(void **state) "\n" "LOL4\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -119,10 +119,10 @@ test_render_listing(void **state) "bola: {% ifdef BOLA %}{{ BOLA }}{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(3); + b_slist_t *s = create_sources(3); assert_non_null(s); char *out = blogc_render(l, s, NULL, true); assert_string_equal(out, @@ -140,7 +140,7 @@ test_render_listing(void **state) "bola: asd3\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -160,7 +160,7 @@ test_render_listing_empty(void **state) "bola: {% ifdef BOLA %}{{ BOLA }}{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); char *out = blogc_render(l, NULL, NULL, true); @@ -187,10 +187,10 @@ test_render_ifdef(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -198,7 +198,7 @@ test_render_ifdef(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -216,10 +216,10 @@ test_render_ifdef2(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -229,7 +229,7 @@ test_render_ifdef2(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -247,10 +247,10 @@ test_render_ifdef3(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -262,7 +262,7 @@ test_render_ifdef3(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -280,10 +280,10 @@ test_render_ifndef(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -295,7 +295,7 @@ test_render_ifndef(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -314,10 +314,10 @@ test_render_if_eq(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -330,7 +330,7 @@ test_render_if_eq(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -349,10 +349,10 @@ test_render_if_neq(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -365,7 +365,7 @@ test_render_if_neq(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -384,10 +384,10 @@ test_render_if_lt(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -400,7 +400,7 @@ test_render_if_lt(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -419,10 +419,10 @@ test_render_if_gt(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -435,7 +435,7 @@ test_render_if_gt(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -456,10 +456,10 @@ test_render_if_lt_eq(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -474,7 +474,7 @@ test_render_if_lt_eq(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -495,10 +495,10 @@ test_render_if_gt_eq(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); char *out = blogc_render(l, s, NULL, false); assert_string_equal(out, @@ -513,7 +513,7 @@ test_render_if_gt_eq(void **state) "\n" "\n"); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -533,21 +533,21 @@ test_render_outside_block(void **state) "{{ BOLA }}\n" "{% ifndef CHUNDA %}lol{% endif %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); - sb_trie_t *c = sb_trie_new(free); - sb_trie_insert(c, "GUDA", sb_strdup("asd")); + b_trie_t *c = b_trie_new(free); + b_trie_insert(c, "GUDA", b_strdup("asd")); char *out = blogc_render(l, s, c, false); assert_string_equal(out, "bola\n" "\n" "lol\n"); - sb_trie_free(c); + b_trie_free(c); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -566,14 +566,14 @@ test_render_prefer_local_variable(void **state) "{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); - sb_trie_t *c = sb_trie_new(free); - sb_trie_insert(c, "GUDA", sb_strdup("hehe")); - sb_trie_insert(c, "LOL", sb_strdup("hmm")); + b_trie_t *c = b_trie_new(free); + b_trie_insert(c, "GUDA", b_strdup("hehe")); + b_trie_insert(c, "LOL", b_strdup("hmm")); char *out = blogc_render(l, s, c, false); assert_string_equal(out, "\n" @@ -584,9 +584,9 @@ test_render_prefer_local_variable(void **state) "\n" "\n" "\n"); - sb_trie_free(c); + b_trie_free(c); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -602,12 +602,12 @@ test_render_respect_variable_scope(void **state) "{% ifdef BOLA %}{{ BOLA }}{% endif %}\n" "{% endblock %}\n"; blogc_error_t *err = NULL; - sb_slist_t *l = blogc_template_parse(str, strlen(str), &err); + b_slist_t *l = blogc_template_parse(str, strlen(str), &err); assert_non_null(l); assert_null(err); - sb_slist_t *s = create_sources(1); + b_slist_t *s = create_sources(1); assert_non_null(s); - sb_trie_t *c = sb_trie_new(free); + b_trie_t *c = b_trie_new(free); char *out = blogc_render(l, s, c, false); assert_string_equal(out, "\n" @@ -616,9 +616,9 @@ test_render_respect_variable_scope(void **state) "\n" "asd\n" "\n"); - sb_trie_free(c); + b_trie_free(c); blogc_template_free_stmts(l); - sb_slist_free_full(s, (sb_free_func_t) sb_trie_free); + b_slist_free_full(s, (b_free_func_t) b_trie_free); free(out); } @@ -626,112 +626,112 @@ test_render_respect_variable_scope(void **state) static void test_get_variable(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "NAME", sb_strdup("bola")); - sb_trie_insert(g, "TITLE", sb_strdup("bola2")); - sb_trie_t *l = sb_trie_new(free); - sb_trie_insert(l, "NAME", sb_strdup("chunda")); - sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "NAME", b_strdup("bola")); + b_trie_insert(g, "TITLE", b_strdup("bola2")); + b_trie_t *l = b_trie_new(free); + b_trie_insert(l, "NAME", b_strdup("chunda")); + b_trie_insert(l, "TITLE", b_strdup("chunda2")); assert_string_equal(blogc_get_variable("NAME", g, l), "chunda"); assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2"); assert_null(blogc_get_variable("BOLA", g, l)); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_get_variable_only_local(void **state) { - sb_trie_t *g = NULL; - sb_trie_t *l = sb_trie_new(free); - sb_trie_insert(l, "NAME", sb_strdup("chunda")); - sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); + b_trie_t *g = NULL; + b_trie_t *l = b_trie_new(free); + b_trie_insert(l, "NAME", b_strdup("chunda")); + b_trie_insert(l, "TITLE", b_strdup("chunda2")); assert_string_equal(blogc_get_variable("NAME", g, l), "chunda"); assert_string_equal(blogc_get_variable("TITLE", g, l), "chunda2"); assert_null(blogc_get_variable("BOLA", g, l)); - sb_trie_free(l); + b_trie_free(l); } static void test_get_variable_only_global(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "NAME", sb_strdup("bola")); - sb_trie_insert(g, "TITLE", sb_strdup("bola2")); - sb_trie_t *l = NULL; + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "NAME", b_strdup("bola")); + b_trie_insert(g, "TITLE", b_strdup("bola2")); + b_trie_t *l = NULL; assert_string_equal(blogc_get_variable("NAME", g, l), "bola"); assert_string_equal(blogc_get_variable("TITLE", g, l), "bola2"); assert_null(blogc_get_variable("BOLA", g, l)); - sb_trie_free(g); + b_trie_free(g); } static void test_format_date(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M")); - sb_trie_t *l = sb_trie_new(free); - sb_trie_insert(l, "DATE_FORMAT", sb_strdup("%R")); + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "DATE_FORMAT", b_strdup("%H -- %M")); + b_trie_t *l = b_trie_new(free); + b_trie_insert(l, "DATE_FORMAT", b_strdup("%R")); char *date = blogc_format_date("2015-01-02 03:04:05", g, l); assert_string_equal(date, "03:04"); free(date); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_format_date_with_global_format(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%H -- %M")); - sb_trie_t *l = sb_trie_new(free); + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "DATE_FORMAT", b_strdup("%H -- %M")); + b_trie_t *l = b_trie_new(free); char *date = blogc_format_date("2015-01-02 03:04:05", g, l); assert_string_equal(date, "03 -- 04"); free(date); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_format_date_without_format(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_t *l = sb_trie_new(free); + b_trie_t *g = b_trie_new(free); + b_trie_t *l = b_trie_new(free); char *date = blogc_format_date("2015-01-02 03:04:05", g, l); assert_string_equal(date, "2015-01-02 03:04:05"); free(date); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_format_date_without_date(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_t *l = sb_trie_new(free); + b_trie_t *g = b_trie_new(free); + b_trie_t *l = b_trie_new(free); char *date = blogc_format_date(NULL, g, l); assert_null(date); free(date); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_format_variable(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "NAME", sb_strdup("bola")); - sb_trie_insert(g, "TITLE", sb_strdup("bola2")); - sb_trie_t *l = sb_trie_new(free); - sb_trie_insert(l, "NAME", sb_strdup("chunda")); - sb_trie_insert(l, "TITLE", sb_strdup("chunda2")); + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "NAME", b_strdup("bola")); + b_trie_insert(g, "TITLE", b_strdup("bola2")); + b_trie_t *l = b_trie_new(free); + b_trie_insert(l, "NAME", b_strdup("chunda")); + b_trie_insert(l, "TITLE", b_strdup("chunda2")); char *tmp = blogc_format_variable("NAME", g, l); assert_string_equal(tmp, "chunda"); free(tmp); @@ -739,24 +739,24 @@ test_format_variable(void **state) assert_string_equal(tmp, "chunda2"); free(tmp); assert_null(blogc_format_variable("BOLA", g, l)); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } static void test_format_variable_with_date(void **state) { - sb_trie_t *g = sb_trie_new(free); - sb_trie_insert(g, "DATE", sb_strdup("2010-11-12 13:14:15")); - sb_trie_insert(g, "DATE_FORMAT", sb_strdup("%R")); - sb_trie_t *l = sb_trie_new(free); - sb_trie_insert(l, "DATE", sb_strdup("2011-12-13 14:15:16")); + b_trie_t *g = b_trie_new(free); + b_trie_insert(g, "DATE", b_strdup("2010-11-12 13:14:15")); + b_trie_insert(g, "DATE_FORMAT", b_strdup("%R")); + b_trie_t *l = b_trie_new(free); + b_trie_insert(l, "DATE", b_strdup("2011-12-13 14:15:16")); char *tmp = blogc_format_variable("DATE_FORMATTED", g, l); assert_string_equal(tmp, "14:15"); free(tmp); - sb_trie_free(g); - sb_trie_free(l); + b_trie_free(g); + b_trie_free(l); } |