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
8e11e707
Commit
8e11e707
authored
Jun 15, 2011
by
nulltoken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_index_add: enforce test coverage
parent
a64bf21b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
1 deletions
+42
-1
tests/t06-index.c
+42
-1
No files found.
tests/t06-index.c
View file @
8e11e707
...
...
@@ -161,7 +161,6 @@ BEGIN_TEST(sort0, "sort the entires in an index")
*/
END_TEST
BEGIN_TEST
(
sort1
,
"sort the entires in an empty index"
)
git_index
*
index
;
...
...
@@ -173,6 +172,46 @@ BEGIN_TEST(sort1, "sort the entires in an empty index")
git_index_free
(
index
);
END_TEST
BEGIN_TEST
(
add0
,
"add a new file to the index"
)
git_index
*
index
;
git_filebuf
file
;
git_repository
*
repo
;
git_index_entry
*
entry
;
git_oid
id1
;
/* Intialize a new repository */
must_pass
(
git_repository_init
(
&
repo
,
TEMP_REPO_FOLDER
"myrepo"
,
0
));
/* Ensure we're the only guy in the room */
must_pass
(
git_repository_index
(
&
index
,
repo
));
must_pass
(
git_index_entrycount
(
index
)
==
0
);
/* Create a new file in the working directory */
must_pass
(
gitfo_mkdir_2file
(
TEMP_REPO_FOLDER
"myrepo/test.txt"
));
must_pass
(
git_filebuf_open
(
&
file
,
TEMP_REPO_FOLDER
"myrepo/test.txt"
,
0
));
must_pass
(
git_filebuf_write
(
&
file
,
"hey there
\n
"
,
10
));
must_pass
(
git_filebuf_commit
(
&
file
));
/* Store the expected hash of the file/blob
* This has been generated by executing the following
* $ echo "hey there" | git hash-object --stdin
*/
must_pass
(
git_oid_mkstr
(
&
id1
,
"a8233120f6ad708f843d861ce2b7228ec4e3dec6"
));
/* Add the new file to the index */
must_pass
(
git_index_add
(
index
,
"test.txt"
,
0
));
/* Wow... it worked! */
must_pass
(
git_index_entrycount
(
index
)
==
1
);
entry
=
git_index_get
(
index
,
0
);
/* And the built-in hashing mechanism worked as expected */
must_be_true
(
git_oid_cmp
(
&
id1
,
&
entry
->
oid
)
==
0
);
git_repository_free
(
repo
);
rmdir_recurs
(
TEMP_REPO_FOLDER
);
END_TEST
BEGIN_SUITE
(
index
)
ADD_TEST
(
read0
);
ADD_TEST
(
read1
);
...
...
@@ -185,4 +224,6 @@ BEGIN_SUITE(index)
ADD_TEST
(
sort0
);
ADD_TEST
(
sort1
);
ADD_TEST
(
add0
);
END_SUITE
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