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
865e2dd4
Commit
865e2dd4
authored
Apr 17, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: Cleanup commit parse testing code
parent
5d2d21e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
tests-clar/commit/parse.c
+23
-22
No files found.
tests-clar/commit/parse.c
View file @
865e2dd4
...
...
@@ -264,37 +264,40 @@ gpgsig -----BEGIN PGP SIGNATURE-----\n\
a simple commit which works
\n
"
,
};
static
int
parse_commit
(
git_commit
**
out
,
const
char
*
buffer
)
{
git_commit
*
commit
;
git_odb_object
fake_odb_object
;
int
error
;
commit
=
(
git_commit
*
)
git__malloc
(
sizeof
(
git_commit
));
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
g_repo
;
memset
(
&
fake_odb_object
,
0x0
,
sizeof
(
git_odb_object
));
fake_odb_object
.
buffer
=
(
char
*
)
buffer
;
fake_odb_object
.
cached
.
size
=
strlen
(
fake_odb_object
.
buffer
);
error
=
git_commit__parse
(
commit
,
&
fake_odb_object
);
*
out
=
commit
;
return
error
;
}
void
test_commit_parse__entire_commit
(
void
)
{
const
int
failing_commit_count
=
ARRAY_SIZE
(
failing_commit_cases
);
const
int
passing_commit_count
=
ARRAY_SIZE
(
passing_commit_cases
);
int
i
;
git_commit
*
commit
;
git_odb_object
fake_odb_object
;
memset
(
&
fake_odb_object
,
0
,
sizeof
(
fake_odb_object
));
for
(
i
=
0
;
i
<
failing_commit_count
;
++
i
)
{
commit
=
(
git_commit
*
)
git__malloc
(
sizeof
(
git_commit
));
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
g_repo
;
fake_odb_object
.
buffer
=
failing_commit_cases
[
i
];
fake_odb_object
.
cached
.
size
=
strlen
(
fake_odb_object
.
buffer
);
cl_git_fail
(
git_commit__parse
(
commit
,
&
fake_odb_object
));
cl_git_fail
(
parse_commit
(
&
commit
,
failing_commit_cases
[
i
]));
git_commit__free
(
commit
);
}
for
(
i
=
0
;
i
<
passing_commit_count
;
++
i
)
{
commit
=
(
git_commit
*
)
git__malloc
(
sizeof
(
git_commit
));
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
g_repo
;
fake_odb_object
.
buffer
=
passing_commit_cases
[
i
];
fake_odb_object
.
cached
.
size
=
strlen
(
fake_odb_object
.
buffer
);
cl_git_pass
(
git_commit__parse
(
commit
,
&
fake_odb_object
));
cl_git_pass
(
parse_commit
(
&
commit
,
passing_commit_cases
[
i
]));
if
(
!
i
)
cl_assert_equal_s
(
""
,
git_commit_message
(
commit
));
...
...
@@ -387,9 +390,7 @@ This commit has a few LF at the start of the commit message";
memset
(
commit
,
0x0
,
sizeof
(
git_commit
));
commit
->
object
.
repo
=
g_repo
;
cl_git_pass
(
git_commit__parse_buffer
(
commit
,
buffer
,
strlen
(
buffer
)));
cl_git_pass
(
parse_commit
(
&
commit
,
buffer
));
cl_assert_equal_s
(
message
,
git_commit_message
(
commit
));
git_commit__free
(
commit
);
}
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