From: Sebastian Harl Date: Thu, 20 Feb 2014 21:52:02 +0000 (+0100) Subject: data_test: Compare return values of format() and strlen(). X-Git-Tag: sysdb-0.1.0~199 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c2f349fcd25cf12ce89e73072f7d0f7876f50606;p=sysdb.git data_test: Compare return values of format() and strlen(). This is to check that sdb_data_strlen() reports sane numbers. --- diff --git a/t/core/data_test.c b/t/core/data_test.c index 4d2efed..f6f9b48 100644 --- a/t/core/data_test.c +++ b/t/core/data_test.c @@ -167,6 +167,11 @@ START_TEST(test_format) "sdb_data_format(type=%s) used wrong format: %s; expected: %s", SDB_TYPE_TO_STRING(datum->type), buf, golden_data[i].expected); + fail_unless((size_t)check <= sizeof(buf) - 2, + "sdb_data_format(type=%s) wrote %d bytes; " + "expected <= %zu based on sdb_data_strlen()", + SDB_TYPE_TO_STRING(datum->type), check, sizeof(buf) - 2); + fail_unless(buf[sizeof(buf) - 2] == '\0', "sdb_data_format(type=%s) did not nul-terminate the buffer", SDB_TYPE_TO_STRING(datum->type));