Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
4374f187
Commit
4374f187
authored
May 09, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #678 from nulltoken/fix/msvc-weird-error
Fix MSVC compilation issue
parents
2aa1e94d
1956693f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
104 deletions
+104
-104
tests-clar/diff/blob.c
+104
-104
No files found.
tests-clar/diff/blob.c
View file @
4374f187
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#include "diff_helpers.h"
#include "diff_helpers.h"
static
git_repository
*
g_repo
=
NULL
;
static
git_repository
*
g_repo
=
NULL
;
static
diff_expects
exp
;
static
diff_expects
exp
ected
;
static
git_diff_options
opts
;
static
git_diff_options
opts
;
static
git_blob
*
d
,
*
alien
;
static
git_blob
*
d
,
*
alien
;
...
@@ -16,7 +16,7 @@ void test_diff_blob__initialize(void)
...
@@ -16,7 +16,7 @@ void test_diff_blob__initialize(void)
opts
.
context_lines
=
1
;
opts
.
context_lines
=
1
;
opts
.
interhunk_lines
=
1
;
opts
.
interhunk_lines
=
1
;
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
/* tests/resources/attr/root_test4.txt */
/* tests/resources/attr/root_test4.txt */
cl_git_pass
(
git_oid_fromstrn
(
&
oid
,
"fe773770c5a6"
,
12
));
cl_git_pass
(
git_oid_fromstrn
(
&
oid
,
"fe773770c5a6"
,
12
));
...
@@ -55,61 +55,61 @@ void test_diff_blob__can_compare_text_blobs(void)
...
@@ -55,61 +55,61 @@ void test_diff_blob__can_compare_text_blobs(void)
/* Doing the equivalent of a `git diff -U1` on these files */
/* Doing the equivalent of a `git diff -U1` on these files */
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
a
,
b
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
a
,
b
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_mods
==
1
);
cl_assert
(
exp
ected
.
file_mods
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
1
);
cl_assert
(
exp
ected
.
hunks
==
1
);
cl_assert
(
exp
.
lines
==
6
);
cl_assert
(
exp
ected
.
lines
==
6
);
cl_assert
(
exp
.
line_ctxt
==
1
);
cl_assert
(
exp
ected
.
line_ctxt
==
1
);
cl_assert
(
exp
.
line_adds
==
5
);
cl_assert
(
exp
ected
.
line_adds
==
5
);
cl_assert
(
exp
.
line_dels
==
0
);
cl_assert
(
exp
ected
.
line_dels
==
0
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
b
,
c
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
b
,
c
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_mods
==
1
);
cl_assert
(
exp
ected
.
file_mods
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
1
);
cl_assert
(
exp
ected
.
hunks
==
1
);
cl_assert
(
exp
.
lines
==
15
);
cl_assert
(
exp
ected
.
lines
==
15
);
cl_assert
(
exp
.
line_ctxt
==
3
);
cl_assert
(
exp
ected
.
line_ctxt
==
3
);
cl_assert
(
exp
.
line_adds
==
9
);
cl_assert
(
exp
ected
.
line_adds
==
9
);
cl_assert
(
exp
.
line_dels
==
3
);
cl_assert
(
exp
ected
.
line_dels
==
3
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
a
,
c
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
a
,
c
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_mods
==
1
);
cl_assert
(
exp
ected
.
file_mods
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
1
);
cl_assert
(
exp
ected
.
hunks
==
1
);
cl_assert
(
exp
.
lines
==
13
);
cl_assert
(
exp
ected
.
lines
==
13
);
cl_assert
(
exp
.
line_ctxt
==
0
);
cl_assert
(
exp
ected
.
line_ctxt
==
0
);
cl_assert
(
exp
.
line_adds
==
12
);
cl_assert
(
exp
ected
.
line_adds
==
12
);
cl_assert
(
exp
.
line_dels
==
1
);
cl_assert
(
exp
ected
.
line_dels
==
1
);
opts
.
context_lines
=
1
;
opts
.
context_lines
=
1
;
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
c
,
d
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
c
,
d
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_mods
==
1
);
cl_assert
(
exp
ected
.
file_mods
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
2
);
cl_assert
(
exp
ected
.
hunks
==
2
);
cl_assert
(
exp
.
lines
==
14
);
cl_assert
(
exp
ected
.
lines
==
14
);
cl_assert
(
exp
.
line_ctxt
==
4
);
cl_assert
(
exp
ected
.
line_ctxt
==
4
);
cl_assert
(
exp
.
line_adds
==
6
);
cl_assert
(
exp
ected
.
line_adds
==
6
);
cl_assert
(
exp
.
line_dels
==
4
);
cl_assert
(
exp
ected
.
line_dels
==
4
);
git_blob_free
(
a
);
git_blob_free
(
a
);
git_blob_free
(
b
);
git_blob_free
(
b
);
...
@@ -121,97 +121,97 @@ void test_diff_blob__can_compare_against_null_blobs(void)
...
@@ -121,97 +121,97 @@ void test_diff_blob__can_compare_against_null_blobs(void)
git_blob
*
e
=
NULL
;
git_blob
*
e
=
NULL
;
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
d
,
e
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
d
,
e
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_dels
==
1
);
cl_assert
(
exp
ected
.
file_dels
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
1
);
cl_assert
(
exp
ected
.
hunks
==
1
);
cl_assert
(
exp
.
hunk_old_lines
==
14
);
cl_assert
(
exp
ected
.
hunk_old_lines
==
14
);
cl_assert
(
exp
.
lines
==
14
);
cl_assert
(
exp
ected
.
lines
==
14
);
cl_assert
(
exp
.
line_dels
==
14
);
cl_assert
(
exp
ected
.
line_dels
==
14
);
opts
.
flags
|=
GIT_DIFF_REVERSE
;
opts
.
flags
|=
GIT_DIFF_REVERSE
;
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
d
,
e
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
d
,
e
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_adds
==
1
);
cl_assert
(
exp
ected
.
file_adds
==
1
);
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
.
hunks
==
1
);
cl_assert
(
exp
ected
.
hunks
==
1
);
cl_assert
(
exp
.
hunk_new_lines
==
14
);
cl_assert
(
exp
ected
.
hunk_new_lines
==
14
);
cl_assert
(
exp
.
lines
==
14
);
cl_assert
(
exp
ected
.
lines
==
14
);
cl_assert
(
exp
.
line_adds
==
14
);
cl_assert
(
exp
ected
.
line_adds
==
14
);
opts
.
flags
^=
GIT_DIFF_REVERSE
;
opts
.
flags
^=
GIT_DIFF_REVERSE
;
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
alien
,
NULL
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
alien
,
NULL
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_dels
==
1
);
cl_assert
(
exp
ected
.
file_dels
==
1
);
cl_assert
(
exp
.
hunks
==
0
);
cl_assert
(
exp
ected
.
hunks
==
0
);
cl_assert
(
exp
.
lines
==
0
);
cl_assert
(
exp
ected
.
lines
==
0
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
NULL
,
alien
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
NULL
,
alien
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_adds
==
1
);
cl_assert
(
exp
ected
.
file_adds
==
1
);
cl_assert
(
exp
.
hunks
==
0
);
cl_assert
(
exp
ected
.
hunks
==
0
);
cl_assert
(
exp
.
lines
==
0
);
cl_assert
(
exp
ected
.
lines
==
0
);
}
}
static
void
assert_identical_blobs_comparison
(
diff_expects
exp
)
static
void
assert_identical_blobs_comparison
(
diff_expects
exp
ected
)
{
{
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_unmodified
==
1
);
cl_assert
(
exp
ected
.
file_unmodified
==
1
);
cl_assert
(
exp
.
hunks
==
0
);
cl_assert
(
exp
ected
.
hunks
==
0
);
cl_assert
(
exp
.
lines
==
0
);
cl_assert
(
exp
ected
.
lines
==
0
);
}
}
void
test_diff_blob__can_compare_identical_blobs
(
void
)
void
test_diff_blob__can_compare_identical_blobs
(
void
)
{
{
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
d
,
d
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
d
,
d
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
assert_identical_blobs_comparison
(
exp
);
assert_identical_blobs_comparison
(
exp
ected
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
NULL
,
NULL
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
NULL
,
NULL
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
false
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
false
);
assert_identical_blobs_comparison
(
exp
);
assert_identical_blobs_comparison
(
exp
ected
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
alien
,
alien
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
alien
,
alien
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
true
);
assert_identical_blobs_comparison
(
exp
);
assert_identical_blobs_comparison
(
exp
ected
);
}
}
static
void
assert_binary_blobs_comparison
(
diff_expects
exp
)
static
void
assert_binary_blobs_comparison
(
diff_expects
exp
ected
)
{
{
cl_assert
(
exp
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
ected
.
at_least_one_of_them_is_binary
==
true
);
cl_assert
(
exp
.
files
==
1
);
cl_assert
(
exp
ected
.
files
==
1
);
cl_assert
(
exp
.
file_mods
==
1
);
cl_assert
(
exp
ected
.
file_mods
==
1
);
cl_assert
(
exp
.
hunks
==
0
);
cl_assert
(
exp
ected
.
hunks
==
0
);
cl_assert
(
exp
.
lines
==
0
);
cl_assert
(
exp
ected
.
lines
==
0
);
}
}
void
test_diff_blob__can_compare_two_binary_blobs
(
void
)
void
test_diff_blob__can_compare_two_binary_blobs
(
void
)
...
@@ -224,16 +224,16 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
...
@@ -224,16 +224,16 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
cl_git_pass
(
git_blob_lookup_prefix
(
&
heart
,
g_repo
,
&
h_oid
,
4
));
cl_git_pass
(
git_blob_lookup_prefix
(
&
heart
,
g_repo
,
&
h_oid
,
4
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
alien
,
heart
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
alien
,
heart
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
assert_binary_blobs_comparison
(
exp
);
assert_binary_blobs_comparison
(
exp
ected
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
heart
,
alien
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
heart
,
alien
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
assert_binary_blobs_comparison
(
exp
);
assert_binary_blobs_comparison
(
exp
ected
);
git_blob_free
(
heart
);
git_blob_free
(
heart
);
}
}
...
@@ -241,14 +241,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
...
@@ -241,14 +241,14 @@ void test_diff_blob__can_compare_two_binary_blobs(void)
void
test_diff_blob__can_compare_a_binary_blob_and_a_text_blob
(
void
)
void
test_diff_blob__can_compare_a_binary_blob_and_a_text_blob
(
void
)
{
{
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
alien
,
d
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
alien
,
d
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
assert_binary_blobs_comparison
(
exp
);
assert_binary_blobs_comparison
(
exp
ected
);
memset
(
&
exp
,
0
,
sizeof
(
exp
));
memset
(
&
exp
ected
,
0
,
sizeof
(
expected
));
cl_git_pass
(
git_diff_blobs
(
cl_git_pass
(
git_diff_blobs
(
d
,
alien
,
&
opts
,
&
exp
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
d
,
alien
,
&
opts
,
&
exp
ected
,
diff_file_fn
,
diff_hunk_fn
,
diff_line_fn
));
assert_binary_blobs_comparison
(
exp
);
assert_binary_blobs_comparison
(
exp
ected
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment