Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased the test coverage of printbuf.c 82% to 92%. #526

Merged
merged 1 commit into from Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_printbuf.c
Expand Up @@ -127,6 +127,10 @@ static void test_sprintbuf(int before_resize);
static void test_sprintbuf(int before_resize)
{
struct printbuf *pb;
const char *max_char = "if string is greater than stack buffer, then use dynamic string"
" with vasprintf. Note: some implementation of vsnprintf return -1 "
" if output is truncated whereas some return the number of bytes that "
" would have been written - this code handles both cases.";

printf("%s: starting test\n", __func__);
pb = printbuf_new();
Expand Down Expand Up @@ -155,6 +159,8 @@ static void test_sprintbuf(int before_resize)
sprintbuf(pb, "%s", "%s");
printf("%d, [%s]\n", printbuf_length(pb), pb->buf);

sprintbuf(pb, max_char);
printf("%d, [%s]\n", printbuf_length(pb), pb->buf);
printbuf_free(pb);
printf("%s: end test\n", __func__);
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_printbuf.expected
Expand Up @@ -29,5 +29,6 @@ sprintbuf to just after resize(31+1): 32, [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX], st
16, [plain12147483647]
27, [plain12147483647-2147483648]
29, [plain12147483647-2147483648%s]
284, [plain12147483647-2147483648%sif string is greater than stack buffer, then use dynamic string with vasprintf. Note: some implementation of vsnprintf return -1 if output is truncated whereas some return the number of bytes that would have been written - this code handles both cases.]
test_sprintbuf: end test
========================================