buf: add buf_add_fmt()

This commit is contained in:
Johan Malm 2024-08-19 21:22:50 +01:00 committed by Consolatis
parent cd961b1ac1
commit 6564e1bc8d
3 changed files with 56 additions and 0 deletions

View file

@ -55,10 +55,25 @@ test_expand_title(void **state)
free(s.data);
}
static void
test_buf_add_fmt(void **state)
{
(void)state;
struct buf s = BUF_INIT;
buf_add(&s, "foo");
buf_add_fmt(&s, " %s baz %d", "bar", 10);
assert_string_equal(s.data, "foo bar baz 10");
buf_reset(&s);
}
int main(int argc, char **argv)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_expand_title),
cmocka_unit_test(test_buf_add_fmt),
};
return cmocka_run_group_tests(tests, NULL, NULL);