]>
git.proxmox.com Git - libgit2.git/blob - tests/object/raw/type2string.c
2 #include "clar_libgit2.h"
7 void test_object_raw_type2string__convert_type_to_string(void)
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");
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), "");
24 void test_object_raw_type2string__convert_string_to_type(void)
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
);
35 cl_assert(git_object_string2type("CoMmIt") == GIT_OBJECT_INVALID
);
36 cl_assert(git_object_string2type("hohoho") == GIT_OBJECT_INVALID
);
39 void test_object_raw_type2string__check_type_is_loose(void)
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);
51 cl_assert(git_object_typeisloose(-2) == 0);
52 cl_assert(git_object_typeisloose(8) == 0);
53 cl_assert(git_object_typeisloose(1234) == 0);