summaryrefslogtreecommitdiff
path: root/tests-clay
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2011-11-29 16:39:49 -0800
committerRussell Belfer <arrbee@arrbee.com>2011-11-29 16:39:49 -0800
commitc63728cd73c14093665880b26505418581d7a29a (patch)
treedbb5b0645b57324310c1fde7436832663b5a72b4 /tests-clay
parentfc88a8d321541165b52d2cdb27753bab76870321 (diff)
downloadlibgit2-c63728cd73c14093665880b26505418581d7a29a.tar.gz
Make git_buf functions always maintain a valid cstr.
At a tiny cost of 1 extra byte per allocation, this makes git_buf_cstr into basically a noop, which simplifies error checking when trying to convert things to use dynamic allocation. This patch also adds a new function (git_buf_copy_cstr) for copying the cstr data directly into an external buffer.
Diffstat (limited to 'tests-clay')
-rw-r--r--tests-clay/core/buffer.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/tests-clay/core/buffer.c b/tests-clay/core/buffer.c
index bf88a3073..cf6e45bd9 100644
--- a/tests-clay/core/buffer.c
+++ b/tests-clay/core/buffer.c
@@ -57,14 +57,13 @@ void test_core_buffer__2(void)
/* this must be safe to do */
git_buf_free(&buf);
-
cl_assert(buf.size == 0);
cl_assert(buf.asize == 0);
/* empty buffer should be empty string */
cl_assert_strequal("", git_buf_cstr(&buf));
cl_assert(buf.size == 0);
- cl_assert(buf.asize > 0);
+ /* cl_assert(buf.asize == 0); -- should not assume what git_buf does */
/* free should set us back to the beginning */
git_buf_free(&buf);
@@ -277,15 +276,15 @@ void test_core_buffer__5(void)
*/
check_buf_append("abcdefgh", "/", "abcdefgh/", 9, 16);
- check_buf_append("abcdefgh", "ijklmno", "abcdefghijklmno", 15, 24);
+ check_buf_append("abcdefgh", "ijklmno", "abcdefghijklmno", 15, 16);
check_buf_append("abcdefgh", "ijklmnop", "abcdefghijklmnop", 16, 24);
check_buf_append("0123456789", "0123456789",
"01234567890123456789", 20, 24);
check_buf_append(REP16("x"), REP16("o"),
REP16("x") REP16("o"), 32, 40);
- check_buf_append(test_4096, "", test_4096, 4096, 6144);
- check_buf_append(test_4096, test_4096, test_8192, 8192, 9216);
+ check_buf_append(test_4096, "", test_4096, 4096, 4104);
+ check_buf_append(test_4096, test_4096, test_8192, 8192, 9240);
/* check sequences of appends */
check_buf_append_abc("a", "b", "c",