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
fdd10839
Commit
fdd10839
authored
Jun 30, 2019
by
Janardhan Pulivarthi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement test for graph ahead and behind
parent
e3adc99e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
tests/graph/ahead_behind.c
+58
-0
No files found.
tests/graph/ahead_behind.c
0 → 100644
View file @
fdd10839
#include "clar_libgit2.h"
static
git_repository
*
_repo
;
static
git_commit
*
commit
;
static
size_t
ahead
;
static
size_t
behind
;
void
test_graph_ahead_behind__initialize
(
void
)
{
git_oid
oid
;
cl_git_pass
(
git_repository_open
(
&
_repo
,
cl_fixture
(
"testrepo.git"
)));
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
));
cl_git_pass
(
git_commit_lookup
(
&
commit
,
_repo
,
&
oid
));
}
void
test_graph_ahead_behind__cleanup
(
void
)
{
git_commit_free
(
commit
);
commit
=
NULL
;
git_repository_free
(
_repo
);
_repo
=
NULL
;
}
void
test_graph_ahead_behind__returns_correct_result
(
void
)
{
git_oid
oid
;
git_oid
oid2
;
git_commit
*
other
;
cl_git_pass
(
git_oid_fromstr
(
&
oid
,
"e90810b8df3e80c413d903f631643c716887138d"
));
cl_git_pass
(
git_oid_fromstr
(
&
oid2
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
));
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
&
oid
,
&
oid2
));
cl_assert_equal_sz
(
2
,
ahead
);
cl_assert_equal_sz
(
6
,
behind
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
git_commit_id
(
commit
),
git_commit_id
(
commit
)));
cl_assert_equal_sz
(
ahead
,
behind
);
cl_git_pass
(
git_commit_nth_gen_ancestor
(
&
other
,
commit
,
1
));
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
git_commit_id
(
commit
),
git_commit_id
(
other
)));
cl_assert_equal_sz
(
ahead
,
behind
+
2
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
git_commit_id
(
other
),
git_commit_id
(
commit
)));
cl_assert_equal_sz
(
ahead
+
2
,
behind
);
git_commit_free
(
other
);
cl_git_pass
(
git_commit_nth_gen_ancestor
(
&
other
,
commit
,
3
));
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
git_commit_id
(
commit
),
git_commit_id
(
other
)));
cl_assert_equal_sz
(
ahead
,
behind
+
4
);
cl_git_pass
(
git_graph_ahead_behind
(
&
ahead
,
&
behind
,
_repo
,
git_commit_id
(
other
),
git_commit_id
(
commit
)));
cl_assert_equal_sz
(
ahead
+
4
,
behind
);
git_commit_free
(
other
);
}
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