]>
git.proxmox.com Git - libgit2.git/blob - tests/status/single.c
e7f92097cd864b9c3fbb796eeb143a1efce2a18a
1 #include "clar_libgit2.h"
5 cleanup__remove_file(void *_file
)
7 cl_must_pass(p_unlink((char *)_file
));
10 /* test retrieving OID from a file apart from the ODB */
11 void test_status_single__hash_single_file(void)
13 static const char file_name
[] = "new_file";
14 static const char file_contents
[] = "new_file\n";
15 static const char file_hash
[] = "d4fa8600b4f37d7516bef4816ae2c64dbf029e3a";
17 git_oid expected_id
, actual_id
;
20 git_oid_fromstr(&expected_id
, file_hash
);
21 cl_git_mkfile(file_name
, file_contents
);
22 cl_set_cleanup(&cleanup__remove_file
, (void *)file_name
);
24 cl_git_pass(git_odb_hashfile(&actual_id
, file_name
, GIT_OBJECT_BLOB
));
25 cl_assert_equal_oid(&expected_id
, &actual_id
);
28 /* test retrieving OID from an empty file apart from the ODB */
29 void test_status_single__hash_single_empty_file(void)
31 static const char file_name
[] = "new_empty_file";
32 static const char file_contents
[] = "";
33 static const char file_hash
[] = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";
35 git_oid expected_id
, actual_id
;
38 git_oid_fromstr(&expected_id
, file_hash
);
39 cl_git_mkfile(file_name
, file_contents
);
40 cl_set_cleanup(&cleanup__remove_file
, (void *)file_name
);
42 cl_git_pass(git_odb_hashfile(&actual_id
, file_name
, GIT_OBJECT_BLOB
));
43 cl_assert_equal_oid(&expected_id
, &actual_id
);