Add gcc printf attribute to gbuf_printf.

More gbuf tests
This commit is contained in:
Nils O. Selåsdal
2012-11-18 14:12:05 +01:00
parent 9bf56c1756
commit c260602890
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -70,7 +70,8 @@ int uc_gbuf_append(GBuf *buf,const void *data,size_t len);
* @return The number of chars written excluding the terminating nul * @return The number of chars written excluding the terminating nul
* character , or negative if an error occurs * character , or negative if an error occurs
*/ */
int uc_gbuf_printf(GBuf *buf, const char *fmt, ...); int uc_gbuf_printf(GBuf *buf, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
/** Expand the capacity of the GBuf. /** Expand the capacity of the GBuf.
* *
+14
View File
@@ -69,6 +69,19 @@ START_TEST (test_gbuf_printf2)
END_TEST END_TEST
START_TEST (test_gbuf_printf_empty_string)
int rc;
GBuf *buf = uc_new_gbuf(1);
const char *fmt = ""; //tricks gcc to not warn about empty format string
fail_if(buf == NULL);
rc = uc_gbuf_printf(buf, fmt);
fail_if(rc != 0);
fail_if(buf->used != 0);
END_TEST
Suite *buffer_suite(void) Suite *buffer_suite(void)
{ {
@@ -79,6 +92,7 @@ Suite *buffer_suite(void)
tcase_add_test(tc, test_gbuf_grow); tcase_add_test(tc, test_gbuf_grow);
tcase_add_test(tc, test_gbuf_printf1); tcase_add_test(tc, test_gbuf_printf1);
tcase_add_test(tc, test_gbuf_printf2); tcase_add_test(tc, test_gbuf_printf2);
tcase_add_test(tc, test_gbuf_printf_empty_string);
suite_add_tcase(s, tc); suite_add_tcase(s, tc);