aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-05-29 14:19:54 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-05-30 01:17:19 +0200
commitfabdcfe3f7dc890f89c0ca2f0ef034d189226531 (patch)
treec3f831a3b60c79dbb9cdca626f9d649be07af557 /tests
parent407c8e7ba58755a2f0998e46b594d89aff4ec7d6 (diff)
downloadblogc-fabdcfe3f7dc890f89c0ca2f0ef034d189226531.tar.gz
blogc-fabdcfe3f7dc890f89c0ca2f0ef034d189226531.tar.bz2
blogc-fabdcfe3f7dc890f89c0ca2f0ef034d189226531.zip
renderer: added support to truncate variables.
this commit also documents variable formatters properly.
Diffstat (limited to 'tests')
-rw-r--r--tests/check_renderer.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/check_renderer.c b/tests/check_renderer.c
index 13e7309..0f17d23 100644
--- a/tests/check_renderer.c
+++ b/tests/check_renderer.c
@@ -820,18 +820,30 @@ test_format_date_without_date(void **state)
static void
test_format_variable(void **state)
{
+ // FIXME: test warnings
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"));
+ sb_trie_insert(l, "SIZE", sb_strdup("1234567890987654321"));
char *tmp = blogc_format_variable("NAME", g, l, NULL);
assert_string_equal(tmp, "chunda");
free(tmp);
tmp = blogc_format_variable("TITLE", g, l, NULL);
assert_string_equal(tmp, "chunda2");
free(tmp);
+ tmp = blogc_format_variable("TITLE_2", g, l, NULL);
+ assert_string_equal(tmp, "ch");
+ free(tmp);
+ tmp = blogc_format_variable("SIZE_12", g, l, NULL);
+ assert_string_equal(tmp, "123456789098");
+ free(tmp);
+ tmp = blogc_format_variable("SIZE_200", g, l, NULL);
+ assert_string_equal(tmp, "1234567890987654321");
+ free(tmp);
+ assert_null(blogc_format_variable("SIZE_", g, l, NULL));
assert_null(blogc_format_variable("BOLA", g, l, NULL));
sb_trie_free(g);
sb_trie_free(l);
@@ -849,6 +861,12 @@ test_format_variable_with_date(void **state)
char *tmp = blogc_format_variable("DATE_FORMATTED", g, l, NULL);
assert_string_equal(tmp, "14:15");
free(tmp);
+ tmp = blogc_format_variable("DATE_FORMATTED_3", g, l, NULL);
+ assert_string_equal(tmp, "14:");
+ free(tmp);
+ tmp = blogc_format_variable("DATE_FORMATTED_10", g, l, NULL);
+ assert_string_equal(tmp, "14:15");
+ free(tmp);
sb_trie_free(g);
sb_trie_free(l);
}
@@ -860,9 +878,18 @@ test_format_variable_foreach(void **state)
sb_slist_t *l = NULL;
l = sb_slist_append(l, sb_strdup("asd"));
l = sb_slist_append(l, sb_strdup("qwe"));
+ l = sb_slist_append(l, sb_strdup("zxcvbn"));
char *tmp = blogc_format_variable("FOREACH_ITEM", NULL, NULL, l->next);
assert_string_equal(tmp, "qwe");
free(tmp);
+ tmp = blogc_format_variable("FOREACH_ITEM_4", NULL, NULL,
+ l->next->next);
+ assert_string_equal(tmp, "zxcv");
+ free(tmp);
+ tmp = blogc_format_variable("FOREACH_ITEM_10", NULL, NULL,
+ l->next->next);
+ assert_string_equal(tmp, "zxcvbn");
+ free(tmp);
sb_slist_free_full(l, free);
}
@@ -871,6 +898,7 @@ static void
test_format_variable_foreach_empty(void **state)
{
assert_null(blogc_format_variable("FOREACH_ITEM", NULL, NULL, NULL));
+ assert_null(blogc_format_variable("FOREACH_ITEM_4", NULL, NULL, NULL));
}