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
cf4c43ab
Commit
cf4c43ab
authored
Sep 04, 2012
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object: make git_object_peel() test more readable
parent
746642a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
tests-clar/object/peel.c
+25
-10
No files found.
tests-clar/object/peel.c
View file @
cf4c43ab
...
...
@@ -12,7 +12,11 @@ void test_object_peel__cleanup(void)
git_repository_free
(
g_repo
);
}
static
void
assert_peel
(
const
char
*
expected_sha
,
const
char
*
sha
,
git_otype
requested_type
)
static
void
assert_peel
(
const
char
*
sha
,
git_otype
requested_type
,
const
char
*
expected_sha
,
git_otype
expected_type
)
{
git_oid
oid
,
expected_oid
;
git_object
*
obj
;
...
...
@@ -26,6 +30,8 @@ static void assert_peel(const char* expected_sha, const char *sha, git_otype req
cl_git_pass
(
git_oid_fromstr
(
&
expected_oid
,
expected_sha
));
cl_assert_equal_i
(
0
,
git_oid_cmp
(
&
expected_oid
,
git_object_id
(
peeled
)));
cl_assert_equal_i
(
expected_type
,
git_object_type
(
peeled
));
git_object_free
(
peeled
);
git_object_free
(
obj
);
}
...
...
@@ -46,21 +52,28 @@ static void assert_peel_error(int error, const char *sha, git_otype requested_ty
void
test_object_peel__peeling_an_object_into_its_own_type_returns_another_instance_of_it
(
void
)
{
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_COMMIT
);
assert_peel
(
"7b4384978d2493e851f9cca7858815fac9b10980"
,
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_TAG
);
assert_peel
(
"53fc32d17276939fc79ed05badaef2db09990016"
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
);
assert_peel
(
"0266163a49e280c4f5ed1e08facd36a2bd716bcf"
,
"0266163a49e280c4f5ed1e08facd36a2bd716bcf"
,
GIT_OBJ_BLOB
);
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_COMMIT
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_COMMIT
);
assert_peel
(
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_TAG
,
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_TAG
);
assert_peel
(
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
);
assert_peel
(
"0266163a49e280c4f5ed1e08facd36a2bd716bcf"
,
GIT_OBJ_BLOB
,
"0266163a49e280c4f5ed1e08facd36a2bd716bcf"
,
GIT_OBJ_BLOB
);
}
void
test_object_peel__can_peel_a_tag
(
void
)
{
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_COMMIT
);
assert_peel
(
"53fc32d17276939fc79ed05badaef2db09990016"
,
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_TREE
);
assert_peel
(
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_COMMIT
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_COMMIT
);
assert_peel
(
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_TREE
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
);
}
void
test_object_peel__can_peel_a_commit
(
void
)
{
assert_peel
(
"53fc32d17276939fc79ed05badaef2db09990016"
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_TREE
);
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_TREE
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
);
}
void
test_object_peel__cannot_peel_a_tree
(
void
)
...
...
@@ -76,10 +89,12 @@ void test_object_peel__cannot_peel_a_blob(void)
void
test_object_peel__target_any_object_for_type_change
(
void
)
{
/* tag to commit */
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_ANY
);
assert_peel
(
"7b4384978d2493e851f9cca7858815fac9b10980"
,
GIT_OBJ_ANY
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_COMMIT
);
/* commit to tree */
assert_peel
(
"53fc32d17276939fc79ed05badaef2db09990016"
,
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_ANY
);
assert_peel
(
"e90810b8df3e80c413d903f631643c716887138d"
,
GIT_OBJ_ANY
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_TREE
);
/* fail to peel tree */
assert_peel_error
(
GIT_ERROR
,
"53fc32d17276939fc79ed05badaef2db09990016"
,
GIT_OBJ_ANY
);
...
...
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