]>
Commit | Line | Data |
---|---|---|
9ff46db9 | 1 | |
3fd1520c | 2 | #include "clar_libgit2.h" |
9ff46db9 MS |
3 | |
4 | #include "odb.h" | |
5 | #include "hash.h" | |
6 | ||
7 | void test_object_raw_type2string__convert_type_to_string(void) | |
8 | { | |
ac3d33df JK |
9 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_INVALID), ""); |
10 | cl_assert_equal_s(git_object_type2string(0), ""); /* EXT1 */ | |
11 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_COMMIT), "commit"); | |
12 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_TREE), "tree"); | |
13 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_BLOB), "blob"); | |
14 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_TAG), "tag"); | |
15 | cl_assert_equal_s(git_object_type2string(5), ""); /* EXT2 */ | |
16 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_OFS_DELTA), "OFS_DELTA"); | |
17 | cl_assert_equal_s(git_object_type2string(GIT_OBJECT_REF_DELTA), "REF_DELTA"); | |
9ff46db9 | 18 | |
946a6dc4 VM |
19 | cl_assert_equal_s(git_object_type2string(-2), ""); |
20 | cl_assert_equal_s(git_object_type2string(8), ""); | |
21 | cl_assert_equal_s(git_object_type2string(1234), ""); | |
9ff46db9 MS |
22 | } |
23 | ||
24 | void test_object_raw_type2string__convert_string_to_type(void) | |
25 | { | |
ac3d33df JK |
26 | cl_assert(git_object_string2type(NULL) == GIT_OBJECT_INVALID); |
27 | cl_assert(git_object_string2type("") == GIT_OBJECT_INVALID); | |
28 | cl_assert(git_object_string2type("commit") == GIT_OBJECT_COMMIT); | |
29 | cl_assert(git_object_string2type("tree") == GIT_OBJECT_TREE); | |
30 | cl_assert(git_object_string2type("blob") == GIT_OBJECT_BLOB); | |
31 | cl_assert(git_object_string2type("tag") == GIT_OBJECT_TAG); | |
32 | cl_assert(git_object_string2type("OFS_DELTA") == GIT_OBJECT_OFS_DELTA); | |
33 | cl_assert(git_object_string2type("REF_DELTA") == GIT_OBJECT_REF_DELTA); | |
34 | ||
35 | cl_assert(git_object_string2type("CoMmIt") == GIT_OBJECT_INVALID); | |
36 | cl_assert(git_object_string2type("hohoho") == GIT_OBJECT_INVALID); | |
9ff46db9 MS |
37 | } |
38 | ||
39 | void test_object_raw_type2string__check_type_is_loose(void) | |
40 | { | |
ac3d33df JK |
41 | cl_assert(git_object_typeisloose(GIT_OBJECT_INVALID) == 0); |
42 | cl_assert(git_object_typeisloose(0) == 0); /* EXT1 */ | |
43 | cl_assert(git_object_typeisloose(GIT_OBJECT_COMMIT) == 1); | |
44 | cl_assert(git_object_typeisloose(GIT_OBJECT_TREE) == 1); | |
45 | cl_assert(git_object_typeisloose(GIT_OBJECT_BLOB) == 1); | |
46 | cl_assert(git_object_typeisloose(GIT_OBJECT_TAG) == 1); | |
47 | cl_assert(git_object_typeisloose(5) == 0); /* EXT2 */ | |
48 | cl_assert(git_object_typeisloose(GIT_OBJECT_OFS_DELTA) == 0); | |
49 | cl_assert(git_object_typeisloose(GIT_OBJECT_REF_DELTA) == 0); | |
9ff46db9 MS |
50 | |
51 | cl_assert(git_object_typeisloose(-2) == 0); | |
52 | cl_assert(git_object_typeisloose(8) == 0); | |
53 | cl_assert(git_object_typeisloose(1234) == 0); | |
54 | } |