Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-16 19:46:41 +0400
committerVicent Marti <tanoku@gmail.com>2013-04-16 19:46:41 +0400
commita50086d174658914d4d6462afbc83b02825b1f5b (patch)
treee8daa1c7bf678222cf351445179837bed7db3a72 /tests-clar/object/blob/filter.c
parent5b9fac39d8a76b9139667c26a63e6b3f204b3977 (diff)
parentf124ebd457bfbf43de3516629aaba5a279636e04 (diff)
Merge branch 'development'v0.18.0
Diffstat (limited to 'tests-clar/object/blob/filter.c')
-rw-r--r--tests-clar/object/blob/filter.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c
index 0b87b2b46..042bddab7 100644
--- a/tests-clar/object/blob/filter.c
+++ b/tests-clar/object/blob/filter.c
@@ -2,9 +2,10 @@
#include "posix.h"
#include "blob.h"
#include "filter.h"
+#include "buf_text.h"
static git_repository *g_repo = NULL;
-#define NUM_TEST_OBJECTS 6
+#define NUM_TEST_OBJECTS 8
static git_oid g_oids[NUM_TEST_OBJECTS];
static const char *g_raw[NUM_TEST_OBJECTS] = {
"",
@@ -12,16 +13,20 @@ static const char *g_raw[NUM_TEST_OBJECTS] = {
"foo\rbar\r",
"foo\r\nbar\r\n",
"foo\nbar\rboth\r\nreversed\n\ragain\nproblems\r",
- "123\n\000\001\002\003\004abc\255\254\253\r\n"
+ "123\n\000\001\002\003\004abc\255\254\253\r\n",
+ "\xEF\xBB\xBFThis is UTF-8\n",
+ "\xFE\xFF\x00T\x00h\x00i\x00s\x00!"
};
-static int g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17 };
-static git_text_stats g_stats[NUM_TEST_OBJECTS] = {
- { 0, 0, 0, 0, 0, 0 },
- { 0, 0, 2, 0, 6, 0 },
- { 0, 2, 0, 0, 6, 0 },
- { 0, 2, 2, 2, 6, 0 },
- { 0, 4, 4, 1, 31, 0 },
- { 1, 1, 2, 1, 9, 5 }
+static git_off_t g_len[NUM_TEST_OBJECTS] = { -1, -1, -1, -1, -1, 17, -1, 12 };
+static git_buf_text_stats g_stats[NUM_TEST_OBJECTS] = {
+ { 0, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 2, 0, 6, 0 },
+ { 0, 0, 2, 0, 0, 6, 0 },
+ { 0, 0, 2, 2, 2, 6, 0 },
+ { 0, 0, 4, 4, 1, 31, 0 },
+ { 0, 1, 1, 2, 1, 9, 5 },
+ { GIT_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
+ { GIT_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
};
static git_buf g_crlf_filtered[NUM_TEST_OBJECTS] = {
{ "", 0, 0 },
@@ -29,7 +34,9 @@ static git_buf g_crlf_filtered[NUM_TEST_OBJECTS] = {
{ "foo\rbar\r", 0, 8 },
{ "foo\nbar\n", 0, 8 },
{ "foo\nbar\rboth\nreversed\n\ragain\nproblems\r", 0, 38 },
- { "123\n\000\001\002\003\004abc\255\254\253\n", 0, 16 }
+ { "123\n\000\001\002\003\004abc\255\254\253\n", 0, 16 },
+ { "\xEF\xBB\xBFThis is UTF-8\n", 0, 17 },
+ { "\xFE\xFF\x00T\x00h\x00i\x00s\x00!", 0, 12 }
};
void test_object_blob_filter__initialize(void)
@@ -43,7 +50,7 @@ void test_object_blob_filter__initialize(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
size_t len = (g_len[i] < 0) ? strlen(g_raw[i]) : (size_t)g_len[i];
- g_len[i] = (int)len;
+ g_len[i] = (git_off_t)len;
cl_git_pass(
git_blob_create_frombuffer(&g_oids[i], g_repo, g_raw[i], len)
@@ -65,8 +72,8 @@ void test_object_blob_filter__unfiltered(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i]));
- cl_assert((size_t)g_len[i] == git_blob_rawsize(blob));
- cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], g_len[i]) == 0);
+ cl_assert(g_len[i] == git_blob_rawsize(blob));
+ cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], (size_t)g_len[i]) == 0);
git_blob_free(blob);
}
}
@@ -76,12 +83,12 @@ void test_object_blob_filter__stats(void)
int i;
git_blob *blob;
git_buf buf = GIT_BUF_INIT;
- git_text_stats stats;
+ git_buf_text_stats stats;
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i]));
cl_git_pass(git_blob__getbuf(&buf, blob));
- git_text_gather_stats(&stats, &buf);
+ git_buf_text_gather_stats(&stats, &buf, false);
cl_assert(memcmp(&g_stats[i], &stats, sizeof(stats)) == 0);
git_blob_free(blob);
}