From: Sebastian Harl Date: Fri, 13 Dec 2013 13:57:40 +0000 (+0100) Subject: strbuf_test: Added tests for sdb_strbuf_clear(). X-Git-Tag: sysdb-0.1.0~300^2~7 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a123fb951e4eb2ad220755246833873ab6417330;p=sysdb.git strbuf_test: Added tests for sdb_strbuf_clear(). --- diff --git a/t/utils/strbuf_test.c b/t/utils/strbuf_test.c index 749d582..0acb1de 100644 --- a/t/utils/strbuf_test.c +++ b/t/utils/strbuf_test.c @@ -447,6 +447,27 @@ START_TEST(test_sdb_strbuf_skip) } END_TEST +START_TEST(test_sdb_strbuf_clear) +{ + const char *data; + size_t len; + + sdb_strbuf_append(buf, "abc"); + len = sdb_strbuf_len(buf); + fail_unless(len != 0, + "sdb_strbuf_len() = %zu; expected: != 0", len); + + sdb_strbuf_clear(buf); + len = sdb_strbuf_len(buf); + fail_unless(len == 0, + "sdb_strbuf_len() = %zu (after clear); expected: 0", len); + + data = sdb_strbuf_string(buf); + fail_unless(*data == '\0', + "sdb_strbuf_string() = '%s' (after clear); expected: ''", data); +} +END_TEST + static struct { const char *input; const char *expected; @@ -520,6 +541,7 @@ util_strbuf_suite(void) tcase_add_test(tc, test_sdb_strbuf_memappend); tcase_add_test(tc, test_sdb_strbuf_chomp); tcase_add_test(tc, test_sdb_strbuf_skip); + tcase_add_test(tc, test_sdb_strbuf_clear); tcase_add_test(tc, test_sdb_strbuf_string); tcase_add_test(tc, test_sdb_strbuf_len); suite_add_tcase(s, tc);