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
fd96f98e
Commit
fd96f98e
authored
May 07, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests for files with no newline at end
parent
e35e2684
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
5 deletions
+30
-5
tests-clar/diff/patch.c
+30
-5
No files found.
tests-clar/diff/patch.c
View file @
fd96f98e
...
@@ -323,7 +323,9 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
...
@@ -323,7 +323,9 @@ void test_diff_patch__hunks_have_correct_line_numbers(void)
}
}
static
void
check_single_patch_stats
(
static
void
check_single_patch_stats
(
git_repository
*
repo
,
size_t
hunks
,
size_t
adds
,
size_t
dels
,
size_t
ctxt
)
git_repository
*
repo
,
size_t
hunks
,
size_t
adds
,
size_t
dels
,
size_t
ctxt
,
const
char
*
expected
)
{
{
git_diff_list
*
diff
;
git_diff_list
*
diff
;
git_diff_patch
*
patch
;
git_diff_patch
*
patch
;
...
@@ -346,6 +348,13 @@ static void check_single_patch_stats(
...
@@ -346,6 +348,13 @@ static void check_single_patch_stats(
cl_assert_equal_sz
(
adds
,
actual_adds
);
cl_assert_equal_sz
(
adds
,
actual_adds
);
cl_assert_equal_sz
(
dels
,
actual_dels
);
cl_assert_equal_sz
(
dels
,
actual_dels
);
if
(
expected
!=
NULL
)
{
char
*
text
;
cl_git_pass
(
git_diff_patch_to_str
(
&
text
,
patch
));
cl_assert_equal_s
(
expected
,
text
);
git__free
(
text
);
}
git_diff_patch_free
(
patch
);
git_diff_patch_free
(
patch
);
git_diff_list_free
(
diff
);
git_diff_list_free
(
diff
);
}
}
...
@@ -370,14 +379,14 @@ void test_diff_patch__line_counts_with_eofnl(void)
...
@@ -370,14 +379,14 @@ void test_diff_patch__line_counts_with_eofnl(void)
git_buf_consume
(
&
content
,
end
);
git_buf_consume
(
&
content
,
end
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
check_single_patch_stats
(
g_repo
,
1
,
0
,
1
,
3
);
check_single_patch_stats
(
g_repo
,
1
,
0
,
1
,
3
,
NULL
);
/* remove trailing whitespace */
/* remove trailing whitespace */
git_buf_rtrim
(
&
content
);
git_buf_rtrim
(
&
content
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
check_single_patch_stats
(
g_repo
,
2
,
1
,
2
,
6
);
check_single_patch_stats
(
g_repo
,
2
,
1
,
2
,
6
,
NULL
);
/* add trailing whitespace */
/* add trailing whitespace */
...
@@ -389,7 +398,7 @@ void test_diff_patch__line_counts_with_eofnl(void)
...
@@ -389,7 +398,7 @@ void test_diff_patch__line_counts_with_eofnl(void)
cl_git_pass
(
git_buf_putc
(
&
content
,
'\n'
));
cl_git_pass
(
git_buf_putc
(
&
content
,
'\n'
));
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
check_single_patch_stats
(
g_repo
,
1
,
1
,
1
,
3
);
check_single_patch_stats
(
g_repo
,
1
,
1
,
1
,
3
,
NULL
);
/* no trailing whitespace as context line */
/* no trailing whitespace as context line */
...
@@ -411,7 +420,23 @@ void test_diff_patch__line_counts_with_eofnl(void)
...
@@ -411,7 +420,23 @@ void test_diff_patch__line_counts_with_eofnl(void)
}
}
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
cl_git_rewritefile
(
"renames/songof7cities.txt"
,
content
.
ptr
);
check_single_patch_stats
(
g_repo
,
1
,
1
,
1
,
6
);
check_single_patch_stats
(
g_repo
,
1
,
1
,
1
,
6
,
/* below is pasted output of 'git diff' with fn context removed */
"diff --git a/songof7cities.txt b/songof7cities.txt
\n
"
"index 378a7d9..3d0154e 100644
\n
"
"--- a/songof7cities.txt
\n
"
"+++ b/songof7cities.txt
\n
"
"@@ -42,7 +42,7 @@
\n
"
"
\n
"
" To the sound of trumpets shall their seed restore my Cities
\n
"
" Wealthy and well-weaponed, that once more may I behold
\n
"
"-All the world go softly when it walks before my Cities,
\n
"
"+#All the world go softly when it walks before my Cities,
\n
"
" And the horses and the chariots fleeing from them as of old!
\n
"
"
\n
"
" -- Rudyard Kipling
\n
"
"
\\
No newline at end of file
\n
"
);
git_buf_free
(
&
content
);
git_buf_free
(
&
content
);
git_config_free
(
cfg
);
git_config_free
(
cfg
);
...
...
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