summaryrefslogtreecommitdiff
path: root/tests-clar/checkout/checkout_helpers.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-09-13 16:30:21 -0700
committerRussell Belfer <rb@github.com>2013-09-17 09:31:46 -0700
commit13f36ffb9e1c4fb70b44a477d716873fecfc0407 (patch)
treee5071f42071b085e90e77ffdaeb1304e19f8d0e1 /tests-clar/checkout/checkout_helpers.c
parentfa9cc14880cb50ea626c4bb0fcf1b68acdd73186 (diff)
downloadlibgit2-13f36ffb9e1c4fb70b44a477d716873fecfc0407.tar.gz
Add clar helpers for testing file equality
These are a couple of new clar helpers for testing that a file has expected contents that I extracted from the checkout code. Actually wrote this as part of an abandoned earlier attempt at a new filters API, but it will be useful now for some of the tests I'm going to write.
Diffstat (limited to 'tests-clar/checkout/checkout_helpers.c')
-rw-r--r--tests-clar/checkout/checkout_helpers.c58
1 files changed, 0 insertions, 58 deletions
diff --git a/tests-clar/checkout/checkout_helpers.c b/tests-clar/checkout/checkout_helpers.c
index f55f7b611..06b4e0682 100644
--- a/tests-clar/checkout/checkout_helpers.c
+++ b/tests-clar/checkout/checkout_helpers.c
@@ -3,22 +3,6 @@
#include "refs.h"
#include "fileops.h"
-/* this is essentially the code from git__unescape modified slightly */
-void strip_cr_from_buf(git_buf *buf)
-{
- char *scan, *pos = buf->ptr, *end = pos + buf->size;
-
- for (scan = pos; scan < end; pos++, scan++) {
- if (*scan == '\r')
- scan++; /* skip '\r' */
- if (pos != scan)
- *pos = *scan;
- }
-
- *pos = '\0';
- buf->size = (pos - buf->ptr);
-}
-
void assert_on_branch(git_repository *repo, const char *branch)
{
git_reference *head;
@@ -50,48 +34,6 @@ void reset_index_to_treeish(git_object *treeish)
git_index_free(index);
}
-static void check_file_contents_internal(
- const char *path,
- const char *expected_content,
- bool strip_cr,
- const char *file,
- int line,
- const char *msg)
-{
- int fd;
- char data[1024] = {0};
- git_buf buf = GIT_BUF_INIT;
- size_t expected_len = expected_content ? strlen(expected_content) : 0;
-
- fd = p_open(path, O_RDONLY);
- cl_assert(fd >= 0);
-
- buf.ptr = data;
- buf.size = p_read(fd, buf.ptr, sizeof(data));
-
- cl_git_pass(p_close(fd));
-
- if (strip_cr)
- strip_cr_from_buf(&buf);
-
- clar__assert_equal(file, line, "strlen(expected_content) != strlen(actual_content)", 1, PRIuZ, expected_len, (size_t)buf.size);
- clar__assert_equal(file, line, msg, 1, "%s", expected_content, buf.ptr);
-}
-
-void check_file_contents_at_line(
- const char *path, const char *expected,
- const char *file, int line, const char *msg)
-{
- check_file_contents_internal(path, expected, false, file, line, msg);
-}
-
-void check_file_contents_nocr_at_line(
- const char *path, const char *expected,
- const char *file, int line, const char *msg)
-{
- check_file_contents_internal(path, expected, true, file, line, msg);
-}
-
int checkout_count_callback(
git_checkout_notify_t why,
const char *path,