summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5e52344)
raw | patch | inline | side by side (parent: 5e52344)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 31 Oct 2013 18:09:05 +0000 (19:09 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 31 Oct 2013 18:09:05 +0000 (19:09 +0100) |
These are mainly to check that the functions do no segfault but report an
error.
error.
t/utils/strbuf_test.c | patch | blob | history |
diff --git a/t/utils/strbuf_test.c b/t/utils/strbuf_test.c
index 3b88b5844e1e8c3904afe1ef6c8f0e98a453f562..9e96b984a2a764d5d322fc60e1065e2ee9cb2b6b 100644 (file)
--- a/t/utils/strbuf_test.c
+++ b/t/utils/strbuf_test.c
* tests
*/
+START_TEST(test_empty)
+{
+ sdb_strbuf_t *b = NULL;
+ va_list ap;
+
+ /* check that methods don't crash */
+ sdb_strbuf_destroy(b);
+ sdb_strbuf_skip(b, 0);
+ sdb_strbuf_skip(b, 10);
+
+ /* check that methods return an error */
+ fail_unless(sdb_strbuf_vappend(b, "test", ap) < 0,
+ "sdb_strbuf_vappend(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_append(b, "test") < 0,
+ "sdb_strbuf_append(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_vsprintf(b, "test", ap) < 0,
+ "sdb_strbuf_vsprintf(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_sprintf(b, "test") < 0,
+ "sdb_strbuf_sprintf(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_memcpy(b, "test", 4) < 0,
+ "sdb_strbuf_memcpy(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_memappend(b, "test", 4) < 0,
+ "sdb_strbuf_memappend(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_read(b, 0, 32) < 0,
+ "sdb_strbuf_read(NULL) didn't report failure");
+ fail_unless(sdb_strbuf_chomp(b) < 0,
+ "sdb_strbuf_chomp(NULL) didn't report failure");
+}
+END_TEST
+
START_TEST(test_sdb_strbuf_create)
{
sdb_strbuf_t *s;
Suite *s = suite_create("utils::strbuf");
TCase *tc;
+ tc = tcase_create("empty");
+ tcase_add_test(tc, test_empty);
+ suite_add_tcase(s, tc);
+
tc = tcase_create("core");
tcase_add_checked_fixture(tc, setup, teardown);
tcase_add_test(tc, test_sdb_strbuf_create);