]>
Commit | Line | Data |
---|---|---|
3fd1520c | 1 | #include "clar_libgit2.h" |
1d09a1c8 VM |
2 | #include "buffer.h" |
3 | ||
4 | static const char *test_string = "Have you seen that? Have you seeeen that??"; | |
5 | ||
6 | void test_buf_basic__resize(void) | |
7 | { | |
8 | git_buf buf1 = GIT_BUF_INIT; | |
9 | git_buf_puts(&buf1, test_string); | |
10 | cl_assert(git_buf_oom(&buf1) == 0); | |
946a6dc4 | 11 | cl_assert_equal_s(git_buf_cstr(&buf1), test_string); |
1d09a1c8 VM |
12 | |
13 | git_buf_puts(&buf1, test_string); | |
14 | cl_assert(strlen(git_buf_cstr(&buf1)) == strlen(test_string) * 2); | |
15 | git_buf_free(&buf1); | |
16 | } | |
17 | ||
18 | void test_buf_basic__printf(void) | |
19 | { | |
20 | git_buf buf2 = GIT_BUF_INIT; | |
21 | git_buf_printf(&buf2, "%s %s %d ", "shoop", "da", 23); | |
22 | cl_assert(git_buf_oom(&buf2) == 0); | |
946a6dc4 | 23 | cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 "); |
1d09a1c8 VM |
24 | |
25 | git_buf_printf(&buf2, "%s %d", "woop", 42); | |
26 | cl_assert(git_buf_oom(&buf2) == 0); | |
946a6dc4 | 27 | cl_assert_equal_s(git_buf_cstr(&buf2), "shoop da 23 woop 42"); |
1d09a1c8 | 28 | git_buf_free(&buf2); |
3fd1520c | 29 | } |