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
398d8bfe
Commit
398d8bfe
authored
Jul 16, 2018
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply tests: tests a diff w/ many small changes
parent
b8840db7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
tests/apply/apply_helpers.h
+60
-0
tests/apply/workdir.c
+52
-0
No files found.
tests/apply/apply_helpers.h
View file @
398d8bfe
...
@@ -52,6 +52,66 @@
...
@@ -52,6 +52,66 @@
"old mode 100644\n" \
"old mode 100644\n" \
"new mode 100755\n"
"new mode 100755\n"
#define DIFF_MANY_CHANGES_ONE \
"diff --git a/veal.txt b/veal.txt\n" \
"index 94d2c01..c9d7d5d 100644\n" \
"--- a/veal.txt\n" \
"+++ b/veal.txt\n" \
"@@ -1,2 +1,2 @@\n" \
"-VEAL SOUP!\n" \
"+VEAL SOUP\n" \
" \n" \
"@@ -4,3 +4,2 @@\n" \
" spoonful of black pepper pounded, and two of salt, with two or three\n" \
"-slices of lean ham; let it boil steadily two hours; skim it\n" \
" occasionally, then put into it a shin of veal, let it boil two hours\n" \
"@@ -8,3 +7,3 @@\n" \
" should rise, take a gill of good cream, mix with it two table-spoonsful\n" \
"-of flour very nicely, and the yelks of two eggs beaten well, strain this\n" \
"+OF FLOUR very nicely, and the yelks of two eggs beaten well, strain this\n" \
" mixture, and add some chopped parsley; pour some soup on by degrees,\n" \
"@@ -12,2 +11,3 @@\n" \
" boiled two or three minutes to take off the raw taste of the eggs. If\n" \
"+Inserted line.\n" \
" the cream be not perfectly sweet, and the eggs quite new, the thickening\n" \
"@@ -15,3 +15,3 @@\n" \
" in, first taking off their skins, by letting them stand a few minutes in\n" \
"-hot water, when they may be easily peeled. When made in this way you\n" \
"+Changed line.\n" \
" must thicken it with the flour only. Any part of the veal may be used,\n"
#define DIFF_MANY_CHANGES_TWO \
"diff --git a/veal.txt b/veal.txt\n" \
"index 94d2c01..6b943d6 100644\n" \
"--- a/veal.txt\n" \
"+++ b/veal.txt\n" \
"@@ -1,2 +1,2 @@\n" \
"-VEAL SOUP!\n" \
"+VEAL SOUP!!!\n" \
" \n" \
"@@ -4,3 +4,2 @@\n" \
" spoonful of black pepper pounded, and two of salt, with two or three\n" \
"-slices of lean ham; let it boil steadily two hours; skim it\n" \
" occasionally, then put into it a shin of veal, let it boil two hours\n" \
"@@ -8,3 +7,3 @@\n" \
" should rise, take a gill of good cream, mix with it two table-spoonsful\n" \
"-of flour very nicely, and the yelks of two eggs beaten well, strain this\n" \
"+of flour very nicely, AND the yelks of two eggs beaten well, strain this\n" \
" mixture, and add some chopped parsley; pour some soup on by degrees,\n" \
"@@ -12,2 +11,3 @@\n" \
" boiled two or three minutes to take off the raw taste of the eggs. If\n" \
"+New line.\n" \
" the cream be not perfectly sweet, and the eggs quite new, the thickening\n" \
"@@ -15,4 +15,5 @@\n" \
" in, first taking off their skins, by letting them stand a few minutes in\n" \
"-hot water, when they may be easily peeled. When made in this way you\n" \
"-must thicken it with the flour only. Any part of the veal may be used,\n" \
"-but the shin or knuckle is the nicest.\n" \
"+HOT water, when they may be easily peeled. When made in this way you\n" \
"+must THICKEN it with the flour only. Any part of the veal may be used,\n" \
"+but the shin OR knuckle is the nicest.\n" \
"+Another new line.\n" \
struct
iterator_compare_data
{
struct
iterator_compare_data
{
struct
merge_index_entry
*
expected
;
struct
merge_index_entry
*
expected
;
size_t
cnt
;
size_t
cnt
;
...
...
tests/apply/workdir.c
View file @
398d8bfe
...
@@ -304,3 +304,55 @@ void test_apply_workdir__change_mode(void)
...
@@ -304,3 +304,55 @@ void test_apply_workdir__change_mode(void)
git_diff_free
(
diff
);
git_diff_free
(
diff
);
#endif
#endif
}
}
void
test_apply_workdir__apply_many_changes_one
(
void
)
{
git_diff
*
diff
;
git_apply_options
opts
=
GIT_APPLY_OPTIONS_INIT
;
struct
merge_index_entry
workdir_expected
[]
=
{
{
0100644
,
"f51658077d85f2264fa179b4d0848268cb3475c3"
,
0
,
"asparagus.txt"
},
{
0100644
,
"68f6182f4c85d39e1309d97c7e456156dc9c0096"
,
0
,
"beef.txt"
},
{
0100644
,
"4b7c5650008b2e747fe1809eeb5a1dde0e80850a"
,
0
,
"bouilli.txt"
},
{
0100644
,
"c4e6cca3ec6ae0148ed231f97257df8c311e015f"
,
0
,
"gravy.txt"
},
{
0100644
,
"68af1fc7407fd9addf1701a87eb1c95c7494c598"
,
0
,
"oyster.txt"
},
{
0100644
,
"c9d7d5d58088bc91f6e06f17ca3a205091568d3a"
,
0
,
"veal.txt"
},
};
size_t
workdir_expected_cnt
=
sizeof
(
workdir_expected
)
/
sizeof
(
struct
merge_index_entry
);
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
DIFF_MANY_CHANGES_ONE
,
strlen
(
DIFF_MANY_CHANGES_ONE
)));
cl_git_pass
(
git_apply
(
repo
,
diff
,
GIT_APPLY_LOCATION_WORKDIR
,
&
opts
));
validate_index_unchanged
(
repo
);
validate_apply_workdir
(
repo
,
workdir_expected
,
workdir_expected_cnt
);
git_diff_free
(
diff
);
}
void
test_apply_workdir__apply_many_changes_two
(
void
)
{
git_diff
*
diff
;
git_apply_options
opts
=
GIT_APPLY_OPTIONS_INIT
;
struct
merge_index_entry
workdir_expected
[]
=
{
{
0100644
,
"f51658077d85f2264fa179b4d0848268cb3475c3"
,
0
,
"asparagus.txt"
},
{
0100644
,
"68f6182f4c85d39e1309d97c7e456156dc9c0096"
,
0
,
"beef.txt"
},
{
0100644
,
"4b7c5650008b2e747fe1809eeb5a1dde0e80850a"
,
0
,
"bouilli.txt"
},
{
0100644
,
"c4e6cca3ec6ae0148ed231f97257df8c311e015f"
,
0
,
"gravy.txt"
},
{
0100644
,
"68af1fc7407fd9addf1701a87eb1c95c7494c598"
,
0
,
"oyster.txt"
},
{
0100644
,
"6b943d65af6d8db74d747284fa4ca7d716ad5bbb"
,
0
,
"veal.txt"
},
};
size_t
workdir_expected_cnt
=
sizeof
(
workdir_expected
)
/
sizeof
(
struct
merge_index_entry
);
cl_git_pass
(
git_diff_from_buffer
(
&
diff
,
DIFF_MANY_CHANGES_TWO
,
strlen
(
DIFF_MANY_CHANGES_TWO
)));
cl_git_pass
(
git_apply
(
repo
,
diff
,
GIT_APPLY_LOCATION_WORKDIR
,
&
opts
));
validate_index_unchanged
(
repo
);
validate_apply_workdir
(
repo
,
workdir_expected
,
workdir_expected_cnt
);
git_diff_free
(
diff
);
}
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