7
7
static git_repository * g_repo ;
8
8
void test_commit_parse__initialize (void )
9
9
{
10
- g_repo = cl_git_sandbox_init ("testrepo" );
10
+ g_repo = cl_git_sandbox_init ("testrepo" );
11
11
}
12
12
void test_commit_parse__cleanup (void )
13
13
{
14
- cl_git_sandbox_cleanup ();
14
+ cl_git_sandbox_cleanup ();
15
15
}
16
16
17
17
18
18
// Header parsing
19
19
typedef struct {
20
- const char * line ;
21
- const char * header ;
20
+ const char * line ;
21
+ const char * header ;
22
22
} parse_test_case ;
23
23
24
24
static parse_test_case passing_header_cases [] = {
25
- { "parent 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "parent " },
26
- { "tree 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
27
- { "random_heading 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "random_heading " },
28
- { "stuck_heading05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "stuck_heading" },
29
- { "tree 5F4BEFFC0759261D015AA63A3A85613FF2F235DE\n" , "tree " },
30
- { "tree 1A669B8AB81B5EB7D9DB69562D34952A38A9B504\n" , "tree " },
31
- { "tree 5B20DCC6110FCC75D31C6CEDEBD7F43ECA65B503\n" , "tree " },
32
- { "tree 173E7BF00EA5C33447E99E6C1255954A13026BE4\n" , "tree " },
33
- { NULL , NULL }
25
+ { "parent 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "parent " },
26
+ { "tree 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
27
+ { "random_heading 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "random_heading " },
28
+ { "stuck_heading05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "stuck_heading" },
29
+ { "tree 5F4BEFFC0759261D015AA63A3A85613FF2F235DE\n" , "tree " },
30
+ { "tree 1A669B8AB81B5EB7D9DB69562D34952A38A9B504\n" , "tree " },
31
+ { "tree 5B20DCC6110FCC75D31C6CEDEBD7F43ECA65B503\n" , "tree " },
32
+ { "tree 173E7BF00EA5C33447E99E6C1255954A13026BE4\n" , "tree " },
33
+ { NULL , NULL }
34
34
};
35
35
36
36
static parse_test_case failing_header_cases [] = {
37
- { "parent 05452d6349abcd67aa396dfb28660d765d8b2a36" , "parent " },
38
- { "05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
39
- { "parent05452d6349abcd67aa396dfb28660d765d8b2a6a\n" , "parent " },
40
- { "parent 05452d6349abcd67aa396dfb280d765d8b2a6\n" , "parent " },
41
- { "tree 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
42
- { "parent 0545xd6349abcd67aa396dfb28660d765d8b2a36\n" , "parent " },
43
- { "parent 0545xd6349abcd67aa396dfb28660d765d8b2a36FF\n" , "parent " },
44
- { "" , "tree " },
45
- { "" , "" },
46
- { NULL , NULL }
37
+ { "parent 05452d6349abcd67aa396dfb28660d765d8b2a36" , "parent " },
38
+ { "05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
39
+ { "parent05452d6349abcd67aa396dfb28660d765d8b2a6a\n" , "parent " },
40
+ { "parent 05452d6349abcd67aa396dfb280d765d8b2a6\n" , "parent " },
41
+ { "tree 05452d6349abcd67aa396dfb28660d765d8b2a36\n" , "tree " },
42
+ { "parent 0545xd6349abcd67aa396dfb28660d765d8b2a36\n" , "parent " },
43
+ { "parent 0545xd6349abcd67aa396dfb28660d765d8b2a36FF\n" , "parent " },
44
+ { "" , "tree " },
45
+ { "" , "" },
46
+ { NULL , NULL }
47
47
};
48
48
49
49
void test_commit_parse__header (void )
50
50
{
51
- git_oid oid ;
51
+ git_oid oid ;
52
52
53
- parse_test_case * testcase ;
54
- for (testcase = passing_header_cases ; testcase -> line != NULL ; testcase ++ )
55
- {
56
- const char * line = testcase -> line ;
57
- const char * line_end = line + strlen (line );
53
+ parse_test_case * testcase ;
54
+ for (testcase = passing_header_cases ; testcase -> line != NULL ; testcase ++ )
55
+ {
56
+ const char * line = testcase -> line ;
57
+ const char * line_end = line + strlen (line );
58
58
59
- cl_git_pass (git_oid__parse (& oid , & line , line_end , testcase -> header ));
60
- cl_assert (line == line_end );
61
- }
59
+ cl_git_pass (git_oid__parse (& oid , & line , line_end , testcase -> header ));
60
+ cl_assert (line == line_end );
61
+ }
62
62
63
- for (testcase = failing_header_cases ; testcase -> line != NULL ; testcase ++ )
64
- {
65
- const char * line = testcase -> line ;
66
- const char * line_end = line + strlen (line );
63
+ for (testcase = failing_header_cases ; testcase -> line != NULL ; testcase ++ )
64
+ {
65
+ const char * line = testcase -> line ;
66
+ const char * line_end = line + strlen (line );
67
67
68
- cl_git_fail (git_oid__parse (& oid , & line , line_end , testcase -> header ));
69
- }
68
+ cl_git_fail (git_oid__parse (& oid , & line , line_end , testcase -> header ));
69
+ }
70
70
}
71
71
72
72
73
73
// Signature parsing
74
74
typedef struct {
75
- const char * string ;
76
- const char * header ;
77
- const char * name ;
78
- const char * email ;
79
- git_time_t time ;
80
- int offset ;
75
+ const char * string ;
76
+ const char * header ;
77
+ const char * name ;
78
+ const char * email ;
79
+ git_time_t time ;
80
+ int offset ;
81
81
} passing_signature_test_case ;
82
82
83
83
passing_signature_test_case passing_signature_cases [] = {
@@ -122,12 +122,12 @@ passing_signature_test_case passing_signature_cases[] = {
122
122
{
"author Vicent Marti <[email protected] > 4294967296 \n" ,
"author " ,
"Vicent Marti" ,
"[email protected] " ,
4294967296 ,
0 },
123
123
{
"author Vicent Marti <[email protected] > 8589934592 \n" ,
"author " ,
"Vicent Marti" ,
"[email protected] " ,
8589934592 ,
0 },
124
124
125
- {NULL ,NULL ,NULL ,NULL ,0 ,0 }
125
+ {NULL ,NULL ,NULL ,NULL ,0 ,0 }
126
126
};
127
127
128
128
typedef struct {
129
- const char * string ;
130
- const char * header ;
129
+ const char * string ;
130
+ const char * header ;
131
131
} failing_signature_test_case ;
132
132
133
133
failing_signature_test_case failing_signature_cases [] = {
@@ -143,31 +143,31 @@ failing_signature_test_case failing_signature_cases[] = {
143
143
144
144
void test_commit_parse__signature (void )
145
145
{
146
- passing_signature_test_case * passcase ;
147
- failing_signature_test_case * failcase ;
148
-
149
- for (passcase = passing_signature_cases ; passcase -> string != NULL ; passcase ++ )
150
- {
151
- const char * str = passcase -> string ;
152
- size_t len = strlen (passcase -> string );
153
- struct git_signature person = {0 };
154
-
155
- cl_git_pass (git_signature__parse (& person , & str , str + len , passcase -> header , '\n' ));
156
- cl_assert_equal_s (passcase -> name , person .name );
157
- cl_assert_equal_s (passcase -> email , person .email );
158
- cl_assert_equal_i ((int )passcase -> time , (int )person .when .time );
159
- cl_assert_equal_i (passcase -> offset , person .when .offset );
160
- git__free (person .name ); git__free (person .email );
161
- }
162
-
163
- for (failcase = failing_signature_cases ; failcase -> string != NULL ; failcase ++ )
164
- {
165
- const char * str = failcase -> string ;
166
- size_t len = strlen (failcase -> string );
167
- git_signature person = {0 };
168
- cl_git_fail (git_signature__parse (& person , & str , str + len , failcase -> header , '\n' ));
169
- git__free (person .name ); git__free (person .email );
170
- }
146
+ passing_signature_test_case * passcase ;
147
+ failing_signature_test_case * failcase ;
148
+
149
+ for (passcase = passing_signature_cases ; passcase -> string != NULL ; passcase ++ )
150
+ {
151
+ const char * str = passcase -> string ;
152
+ size_t len = strlen (passcase -> string );
153
+ struct git_signature person = {0 };
154
+
155
+ cl_git_pass (git_signature__parse (& person , & str , str + len , passcase -> header , '\n' ));
156
+ cl_assert_equal_s (passcase -> name , person .name );
157
+ cl_assert_equal_s (passcase -> email , person .email );
158
+ cl_assert_equal_i ((int )passcase -> time , (int )person .when .time );
159
+ cl_assert_equal_i (passcase -> offset , person .when .offset );
160
+ git__free (person .name ); git__free (person .email );
161
+ }
162
+
163
+ for (failcase = failing_signature_cases ; failcase -> string != NULL ; failcase ++ )
164
+ {
165
+ const char * str = failcase -> string ;
166
+ size_t len = strlen (failcase -> string );
167
+ git_signature person = {0 };
168
+ cl_git_fail (git_signature__parse (& person , & str , str + len , failcase -> header , '\n' ));
169
+ git__free (person .name ); git__free (person .email );
170
+ }
171
171
}
172
172
173
173
@@ -312,17 +312,17 @@ void test_commit_parse__entire_commit(void)
312
312
313
313
// query the details on a parsed commit
314
314
void test_commit_parse__details0 (void ) {
315
- static const char * commit_ids [] = {
316
- "a4a7dce85cf63874e984719f4fdd239f5145052f" , /* 0 */
317
- "9fd738e8f7967c078dceed8190330fc8648ee56a" , /* 1 */
318
- "4a202b346bb0fb0db7eff3cffeb3c70babbd2045" , /* 2 */
319
- "c47800c7266a2be04c571c04d5a6614691ea99bd" , /* 3 */
320
- "8496071c1b46c854b31185ea97743be6a8774479" , /* 4 */
321
- "5b5b025afb0b4c913b4c338a42934a3863bf3644" , /* 5 */
322
- "a65fedf39aefe402d3bb6e24df4d4f5fe4547750" , /* 6 */
323
- };
315
+ static const char * commit_ids [] = {
316
+ "a4a7dce85cf63874e984719f4fdd239f5145052f" , /* 0 */
317
+ "9fd738e8f7967c078dceed8190330fc8648ee56a" , /* 1 */
318
+ "4a202b346bb0fb0db7eff3cffeb3c70babbd2045" , /* 2 */
319
+ "c47800c7266a2be04c571c04d5a6614691ea99bd" , /* 3 */
320
+ "8496071c1b46c854b31185ea97743be6a8774479" , /* 4 */
321
+ "5b5b025afb0b4c913b4c338a42934a3863bf3644" , /* 5 */
322
+ "a65fedf39aefe402d3bb6e24df4d4f5fe4547750" , /* 6 */
323
+ };
324
324
const size_t commit_count = sizeof (commit_ids ) / sizeof (const char * );
325
- unsigned int i ;
325
+ unsigned int i ;
326
326
327
327
for (i = 0 ; i < commit_count ; ++ i ) {
328
328
git_oid id ;
0 commit comments