File: testgit.c

package info (click to toggle)
anjuta 2%3A3.34.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 72,440 kB
  • sloc: ansic: 207,444; sh: 47,499; cpp: 11,461; makefile: 3,586; yacc: 2,821; perl: 2,094; lex: 1,546; xml: 904; python: 149; sql: 99; javascript: 51; java: 10
file content (169 lines) | stat: -rw-r--r-- 5,836 bytes parent folder | download | duplicates (5)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#include <glib.h>
#include "../git-status-factory.h"

static void 
check_status (AnjutaVcsStatus index, AnjutaVcsStatus working_tree, 
              AnjutaVcsStatus expected_index, 
              AnjutaVcsStatus expected_working_tree,
              gchar *test_type)
              
{
	if (g_test_verbose ())
		g_print ("Testing %s\n", test_type);

	g_assert_cmpint (expected_index, ==, index);
	g_assert_cmpint (expected_working_tree, ==, working_tree);
}

static void
test_status (void)
{
	GitStatusFactory *factory;
	GitStatus *status;
	AnjutaVcsStatus working_tree, index;

	factory = git_status_factory_new ();
	status = git_status_factory_create_status (factory, 
											   " M plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_MODIFIED, 
	              "modified in working tree");

	status = git_status_factory_create_status (factory, 
											   "A  plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_ADDED, 
	              ANJUTA_VCS_STATUS_NONE, 
	              "added to index");

	status = git_status_factory_create_status (factory,
	                                           "D  plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_DELETED, 
	              ANJUTA_VCS_STATUS_NONE, 
	              "removed from index");

	status = git_status_factory_create_status (factory,
	                                           "MM plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_MODIFIED, 
	              ANJUTA_VCS_STATUS_MODIFIED, 
	              "modified in index and working tree");

	status = git_status_factory_create_status (factory,
	                                           "?? plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_UNVERSIONED, 
	              ANJUTA_VCS_STATUS_UNVERSIONED, 
	              "untracked");

	status = git_status_factory_create_status (factory,
	                                           "DD plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: both deleted");

	status = git_status_factory_create_status (factory,
	                                           "AU plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: added by us");

	status = git_status_factory_create_status (factory,
	                                           "UD plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: deleted by them");

	status = git_status_factory_create_status (factory,
	                                           "UA plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: added by them");

	status = git_status_factory_create_status (factory,
	                                           "DU plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: deleted by us");

	status = git_status_factory_create_status (factory,
	                                           "AA plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: both added");

	status = git_status_factory_create_status (factory,
	                                           "UU plugins/git/plugin.c");
	index = git_status_get_index_status (status);
	working_tree = git_status_get_working_tree_status (status);

	g_object_unref (status);
	check_status (index, working_tree, 
	              ANJUTA_VCS_STATUS_NONE, 
	              ANJUTA_VCS_STATUS_CONFLICTED, 
	              "conflict: both modified");
	
	g_object_unref (factory);
}

int
main (int argc, char *argv[])
{
	g_test_init (&argc, &argv, NULL);

	g_test_add_func ("/Git/Status", test_status);

	return g_test_run ();
}