File: emptyobjects.c

package info (click to toggle)
monodevelop 5.10.0.871-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 272,040 kB
  • ctags: 258,152
  • sloc: cs: 1,439,098; xml: 947,206; ansic: 148,611; java: 64,114; makefile: 4,256; lisp: 3,174; python: 2,072; sh: 2,058; objc: 302; sql: 111; php: 65
file content (57 lines) | stat: -rw-r--r-- 1,631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "clar_libgit2.h"
#include "odb.h"
#include "filebuf.h"

git_repository *g_repo;

void test_odb_emptyobjects__initialize(void)
{
	cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
}
void test_odb_emptyobjects__cleanup(void)
{
	git_repository_free(g_repo);
}

void test_odb_emptyobjects__read(void)
{
	git_oid id;
	git_blob *blob;

	cl_git_pass(git_oid_fromstr(&id, "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"));
	cl_git_pass(git_blob_lookup(&blob, g_repo, &id));
	cl_assert_equal_i(GIT_OBJ_BLOB, git_object_type((git_object *) blob));
	cl_assert(git_blob_rawcontent(blob));
	cl_assert_equal_s("", git_blob_rawcontent(blob));
	cl_assert_equal_i(0, git_blob_rawsize(blob));
	git_blob_free(blob);
}

void test_odb_emptyobjects__read_tree(void)
{
	git_oid id;
	git_tree *tree;

	cl_git_pass(git_oid_fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904"));
	cl_git_pass(git_tree_lookup(&tree, g_repo, &id));
	cl_assert_equal_i(GIT_OBJ_TREE, git_object_type((git_object *) tree));
	cl_assert_equal_i(0, git_tree_entrycount(tree));
	cl_assert_equal_p(NULL, git_tree_entry_byname(tree, "foo"));
	git_tree_free(tree);
}

void test_odb_emptyobjects__read_tree_odb(void)
{
	git_oid id;
	git_odb *odb;
	git_odb_object *tree_odb;

	cl_git_pass(git_oid_fromstr(&id, "4b825dc642cb6eb9a060e54bf8d69288fbee4904"));
	cl_git_pass(git_repository_odb(&odb, g_repo));
	cl_git_pass(git_odb_read(&tree_odb, odb, &id));
	cl_assert(git_odb_object_data(tree_odb));
	cl_assert_equal_s("", git_odb_object_data(tree_odb));
	cl_assert_equal_i(0, git_odb_object_size(tree_odb));
	git_odb_object_free(tree_odb);
	git_odb_free(odb);
}