Blame tests/object/raw/type2string.c

Packit ae9e2a
Packit ae9e2a
#include "clar_libgit2.h"
Packit ae9e2a
Packit ae9e2a
#include "odb.h"
Packit ae9e2a
#include "hash.h"
Packit ae9e2a
Packit ae9e2a
void test_object_raw_type2string__convert_type_to_string(void)
Packit ae9e2a
{
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_BAD), "");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ__EXT1), "");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_COMMIT), "commit");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_TREE), "tree");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_BLOB), "blob");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_TAG), "tag");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ__EXT2), "");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_OFS_DELTA), "OFS_DELTA");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(GIT_OBJ_REF_DELTA), "REF_DELTA");
Packit ae9e2a
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(-2), "");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(8), "");
Packit ae9e2a
	cl_assert_equal_s(git_object_type2string(1234), "");
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
void test_object_raw_type2string__convert_string_to_type(void)
Packit ae9e2a
{
Packit ae9e2a
	cl_assert(git_object_string2type(NULL) == GIT_OBJ_BAD);
Packit ae9e2a
	cl_assert(git_object_string2type("") == GIT_OBJ_BAD);
Packit ae9e2a
	cl_assert(git_object_string2type("commit") == GIT_OBJ_COMMIT);
Packit ae9e2a
	cl_assert(git_object_string2type("tree") == GIT_OBJ_TREE);
Packit ae9e2a
	cl_assert(git_object_string2type("blob") == GIT_OBJ_BLOB);
Packit ae9e2a
	cl_assert(git_object_string2type("tag") == GIT_OBJ_TAG);
Packit ae9e2a
	cl_assert(git_object_string2type("OFS_DELTA") == GIT_OBJ_OFS_DELTA);
Packit ae9e2a
	cl_assert(git_object_string2type("REF_DELTA") == GIT_OBJ_REF_DELTA);
Packit ae9e2a
Packit ae9e2a
	cl_assert(git_object_string2type("CoMmIt") == GIT_OBJ_BAD);
Packit ae9e2a
	cl_assert(git_object_string2type("hohoho") == GIT_OBJ_BAD);
Packit ae9e2a
}
Packit ae9e2a
Packit ae9e2a
void test_object_raw_type2string__check_type_is_loose(void)
Packit ae9e2a
{
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_BAD) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ__EXT1) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_COMMIT) == 1);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_TREE) == 1);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_BLOB) == 1);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_TAG) == 1);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ__EXT2) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_OFS_DELTA) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(GIT_OBJ_REF_DELTA) == 0);
Packit ae9e2a
Packit ae9e2a
	cl_assert(git_object_typeisloose(-2) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(8) == 0);
Packit ae9e2a
	cl_assert(git_object_typeisloose(1234) == 0);
Packit ae9e2a
}