diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-06-27 03:01:20 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-06-29 01:35:45 +0200 |
commit | 519f1f8031687ebf3853817a8b2e3557c2443d67 (patch) | |
tree | 320be2942773ee95c34a798da09685728115045f /tests/check_utils.c | |
parent | 4cfeb39fbe99be28f22611c6146b1655549f7850 (diff) | |
download | blogc-519f1f8031687ebf3853817a8b2e3557c2443d67.tar.gz blogc-519f1f8031687ebf3853817a8b2e3557c2443d67.tar.bz2 blogc-519f1f8031687ebf3853817a8b2e3557c2443d67.zip |
content-parser: rewrote inline parser.
parser is stricter now, and won't produce invalid HTML anymore.
Diffstat (limited to 'tests/check_utils.c')
-rw-r--r-- | tests/check_utils.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/check_utils.c b/tests/check_utils.c index 6a6ceca..31087f1 100644 --- a/tests/check_utils.c +++ b/tests/check_utils.c @@ -257,6 +257,18 @@ test_str_replace(void **state) static void +test_str_find(void **state) +{ + assert_null(sb_str_find(NULL, 'c')); + assert_string_equal(sb_str_find("bola", 'l'), "la"); + assert_string_equal(sb_str_find("bo\\lalala", 'l'), "lala"); + assert_string_equal(sb_str_find("bola", '\0'), ""); + assert_null(sb_str_find("bola", 'g')); + assert_null(sb_str_find("bo\\la", 'l')); +} + + +static void test_strv_join(void **state) { char *pieces[] = {"guda","bola", "chunda", NULL}; @@ -529,6 +541,25 @@ test_string_append_printf(void **state) static void +test_string_append_escaped(void **state) +{ + sb_string_t *str = sb_string_new(); + str = sb_string_append_escaped(str, NULL); + assert_non_null(str); + assert_string_equal(str->str, ""); + assert_int_equal(str->len, 0); + assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); + str = sb_string_append_escaped(str, "foo \\a bar \\\\ lol"); + assert_non_null(str); + assert_string_equal(str->str, "foo a bar \\ lol"); + assert_int_equal(str->len, 15); + assert_int_equal(str->allocated_len, SB_STRING_CHUNK_SIZE); + assert_null(sb_string_free(str, true)); + assert_null(sb_string_append_escaped(NULL, "asd")); +} + + +static void test_trie_new(void **state) { sb_trie_t *trie = sb_trie_new(free); @@ -934,6 +965,7 @@ main(void) unit_test(test_str_strip), unit_test(test_str_split), unit_test(test_str_replace), + unit_test(test_str_find), unit_test(test_strv_join), unit_test(test_strv_length), @@ -945,6 +977,7 @@ main(void) unit_test(test_string_append), unit_test(test_string_append_c), unit_test(test_string_append_printf), + unit_test(test_string_append_escaped), // trie unit_test(test_trie_new), |