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
eddde618
Commit
eddde618
authored
Nov 27, 2012
by
Scott J. Goldman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for ahead-behind count
parent
bff53e54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
tests-clar/revwalk/mergebase.c
+33
-0
No files found.
tests-clar/revwalk/mergebase.c
View file @
eddde618
...
...
@@ -18,6 +18,7 @@ void test_revwalk_mergebase__cleanup(void)
void
test_revwalk_mergebase__single1
(
void
)
{
git_oid
result
,
one
,
two
,
expected
;
int
ahead
,
behind
;
cl_git_pass
(
git_oid_fromstr
(
&
one
,
"c47800c7266a2be04c571c04d5a6614691ea99bd "
));
cl_git_pass
(
git_oid_fromstr
(
&
two
,
"9fd738e8f7967c078dceed8190330fc8648ee56a"
));
...
...
@@ -25,11 +26,20 @@ void test_revwalk_mergebase__single1(void)
cl_git_pass
(
git_merge_base
(
&
result
,
_repo
,
&
one
,
&
two
));
cl_assert
(
git_oid_cmp
(
&
result
,
&
expected
)
==
0
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert
(
ahead
==
2
);
cl_assert
(
behind
==
1
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert
(
ahead
==
1
);
cl_assert
(
behind
==
2
);
}
void
test_revwalk_mergebase__single2
(
void
)
{
git_oid
result
,
one
,
two
,
expected
;
int
ahead
,
behind
;
cl_git_pass
(
git_oid_fromstr
(
&
one
,
"763d71aadf09a7951596c9746c024e7eece7c7af"
));
cl_git_pass
(
git_oid_fromstr
(
&
two
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
));
...
...
@@ -37,11 +47,20 @@ void test_revwalk_mergebase__single2(void)
cl_git_pass
(
git_merge_base
(
&
result
,
_repo
,
&
one
,
&
two
));
cl_assert
(
git_oid_cmp
(
&
result
,
&
expected
)
==
0
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert
(
ahead
==
4
);
cl_assert
(
behind
==
1
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert
(
ahead
==
1
);
cl_assert
(
behind
==
4
);
}
void
test_revwalk_mergebase__merged_branch
(
void
)
{
git_oid
result
,
one
,
two
,
expected
;
int
ahead
,
behind
;
cl_git_pass
(
git_oid_fromstr
(
&
one
,
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750"
));
cl_git_pass
(
git_oid_fromstr
(
&
two
,
"9fd738e8f7967c078dceed8190330fc8648ee56a"
));
...
...
@@ -52,11 +71,20 @@ void test_revwalk_mergebase__merged_branch(void)
cl_git_pass
(
git_merge_base
(
&
result
,
_repo
,
&
two
,
&
one
));
cl_assert
(
git_oid_cmp
(
&
result
,
&
expected
)
==
0
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_assert
(
ahead
==
0
);
cl_assert
(
behind
==
3
);
cl_git_pass
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
two
,
&
one
));
cl_assert
(
ahead
==
3
);
cl_assert
(
behind
==
0
);
}
void
test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND
(
void
)
{
git_oid
result
,
one
,
two
;
int
ahead
,
behind
;
int
error
;
cl_git_pass
(
git_oid_fromstr
(
&
one
,
"763d71aadf09a7951596c9746c024e7eece7c7af"
));
...
...
@@ -66,6 +94,11 @@ void test_revwalk_mergebase__no_common_ancestor_returns_ENOTFOUND(void)
cl_git_fail
(
error
);
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
cl_git_fail
(
git_count_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
one
,
&
two
));
cl_git_fail
(
error
);
cl_assert_equal_i
(
GIT_ENOTFOUND
,
error
);
}
void
test_revwalk_mergebase__no_off_by_one_missing
(
void
)
...
...
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