summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 50eb185)
raw | patch | inline | side by side (parent: 50eb185)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 13 Dec 2013 13:53:02 +0000 (14:53 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 13 Dec 2013 13:53:02 +0000 (14:53 +0100) |
This is mostly about checking that this does not crash.
t/utils/strbuf_test.c | patch | blob | history |
diff --git a/t/utils/strbuf_test.c b/t/utils/strbuf_test.c
index c68a23efcf22df1157d2ac4adb02ceaf5f3b7f38..749d5821622a0189e4fa8130d38b671a6f9958b4 100644 (file)
--- a/t/utils/strbuf_test.c
+++ b/t/utils/strbuf_test.c
* tests
*/
-START_TEST(test_empty)
+START_TEST(test_null)
{
sdb_strbuf_t *b = NULL;
va_list ap;
sdb_strbuf_skip(b, 0, 0);
sdb_strbuf_skip(b, 0, 10);
sdb_strbuf_skip(b, 10, 10);
+ sdb_strbuf_clear(b);
/* check that methods return an error */
fail_unless(sdb_strbuf_vappend(b, "test", ap) < 0,
}
END_TEST
+START_TEST(test_empty)
+{
+ sdb_strbuf_t *b = sdb_strbuf_create(0);
+ const char *data;
+ size_t len;
+
+ /* check that methods don't crash */
+ sdb_strbuf_skip(b, 1, 1);
+ sdb_strbuf_clear(b);
+ sdb_strbuf_chomp(b);
+
+ data = sdb_strbuf_string(b);
+ fail_unless(data && (*data == '\0'),
+ "sdb_strbuf_string(<empty>) = '%s'; expected: ''", data);
+ len = sdb_strbuf_len(b);
+ fail_unless(len == 0,
+ "sdb_strbuf_len(<empty>) = %zu; expected: 0", len);
+
+ sdb_strbuf_destroy(b);
+}
+END_TEST
+
START_TEST(test_sdb_strbuf_create)
{
sdb_strbuf_t *s;
TCase *tc;
tc = tcase_create("empty");
+ tcase_add_test(tc, test_null);
tcase_add_test(tc, test_empty);
suite_add_tcase(s, tc);