summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e990840)
raw | patch | inline | side by side (parent: e990840)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 20 Feb 2014 21:41:26 +0000 (22:41 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 20 Feb 2014 21:41:26 +0000 (22:41 +0100) |
t/core/data_test.c | patch | blob | history |
diff --git a/t/core/data_test.c b/t/core/data_test.c
index 420ee851bd38587f3168981393df54b154c0d7a8..8af042a8a79a1cfb53deccd7c6a55874d327ec15 100644 (file)
--- a/t/core/data_test.c
+++ b/t/core/data_test.c
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
sdb_data_t *datum = &golden_data[i].datum;
- char buf[sdb_data_strlen(datum) + 1];
+ char buf[sdb_data_strlen(datum) + 2];
int check;
- check = sdb_data_format(datum, buf, sizeof(buf));
+ memset(buf, (int)'A', sizeof(buf));
+
+ check = sdb_data_format(datum, buf, sizeof(buf) - 1);
fail_unless(! check,
"sdb_data_format(type=%s) = %d; expected: 0",
SDB_TYPE_TO_STRING(datum->type), check);
fail_unless(! strcmp(buf, golden_data[i].expected),
"sdb_data_format(type=%s) used wrong format: %s; expected: %s",
SDB_TYPE_TO_STRING(datum->type), buf, golden_data[i].expected);
+
+ fail_unless(buf[sizeof(buf) - 2] == '\0',
+ "sdb_data_format(type=%s) did not nul-terminate the buffer",
+ SDB_TYPE_TO_STRING(datum->type));
+ fail_unless(buf[sizeof(buf) - 1] == 'A',
+ "sdb_data_format(type=%s) wrote past the end of the buffer",
+ SDB_TYPE_TO_STRING(datum->type));
}
}
END_TEST