index b0159c4d7406cc4e44cd0812c8ae03bfd06c1e72..cb86a3e1ef3edd75ba03f26da11996c5532c5c49 100644 (file)
size_t i;
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
- n = sdb_strbuf_append(buf, golden_data[i].input);
+ n = sdb_strbuf_append(buf, "%s", golden_data[i].input);
fail_unless((size_t)n == strlen(golden_data[i].input),
"sdb_strbuf_append() appended %zi bytes; expected: %zu",
n, strlen(golden_data[i].input));
test, golden_data[i].result);
}
- n = sdb_strbuf_append(buf, "%zu; %5.4f", 42, 4.2);
+ n = sdb_strbuf_append(buf, "%zu; %5.4f", (size_t)42, 4.2);
fail_unless(n == 10,
"sdb_strbuf_append() appended %zi bytes; expected: 10", n);
total += n;
size_t i;
+ sdb_strbuf_destroy(buf);
+ buf = sdb_strbuf_create(1); /* -> min_size = 1 */
+
for (i = 0; i < SDB_STATIC_ARRAY_LEN(golden_data); ++i) {
- n = sdb_strbuf_sprintf(buf, golden_data[i]);
+ n = sdb_strbuf_sprintf(buf, "%s", golden_data[i]);
fail_unless((size_t)n == strlen(golden_data[i]),
"sdb_strbuf_sprintf() wrote %zi bytes; expected: %zu",
n, strlen(golden_data[i]));
"got: %s; expected: %s", test, golden_data[i]);
check = sdb_strbuf_cap(buf);
- if (n) /* 3 times the current len is the threshold for shrinking */
+ /* 3 times the current len is the threshold for shrinking,
+ * but it's capped to the initial size (or 64) */
+ if (n)
fail_unless(((size_t)n < check) && (check < (size_t)n * 3),
"sdb_strbuf_sprintf() did not resize the buffer "
"correctly (got size %zu; expected %zi < <size> < %d)",
check, n, n / 3);
}
- n = sdb_strbuf_sprintf(buf, "%zu; %5.4f", 42, 4.2);
+ n = sdb_strbuf_sprintf(buf, "%zu; %5.4f", (size_t)42, 4.2);
fail_unless(n == 10,
"sdb_strbuf_sprintf() wrote %zi bytes; expected: 10", n);
check = sdb_strbuf_len(buf);
const char *check;
if (golden_data[i].input)
- sdb_strbuf_sprintf(buf, golden_data[i].input);
+ sdb_strbuf_sprintf(buf, "%s", golden_data[i].input);
/* empty buffer */
n = sdb_strbuf_chomp(buf);
const char *check;
size_t n;
- sdb_strbuf_sprintf(buf, input);
+ sdb_strbuf_sprintf(buf, "%s", input);
sdb_strbuf_skip(buf, golden_data[i].offset,
golden_data[i].n);
const char *check;
if (golden_data[i].input)
- sdb_strbuf_sprintf(buf, golden_data[i].input);
+ sdb_strbuf_sprintf(buf, "%s", golden_data[i].input);
check = sdb_strbuf_string(buf);
fail_unless(!strcmp(check, golden_data[i].expected),
"sdb_strbuf_string() = '%s'; expected: '%s'",
size_t check;
if (golden_data[i].input)
- sdb_strbuf_sprintf(buf, golden_data[i].input);
+ sdb_strbuf_sprintf(buf, "%s", golden_data[i].input);
check = sdb_strbuf_len(buf);
fail_unless(check == golden_data[i].expected,
"sdb_strbuf_len() = %zu; expected: %zu",