From 519f1f8031687ebf3853817a8b2e3557c2443d67 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Mon, 27 Jun 2016 03:01:20 +0200 Subject: content-parser: rewrote inline parser. parser is stricter now, and won't produce invalid HTML anymore. --- tests/check_utils.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/check_utils.c') 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 @@ -256,6 +256,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) { @@ -528,6 +540,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) { @@ -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), -- cgit v1.2.3-18-g5258