@@ -6,14 +6,6 @@ static git_config *_config;
66
77#define TEST_URL "http://github.com/libgit2/libgit2.git"
88
9- #define cl_git_assert_cannot_create_remote (expected , creation_expr ) \
10- do { \
11- git_remote *r = NULL; \
12- int res = ((creation_expr)); \
13- cl_git_fail_with(expected, res); \
14- cl_assert_equal_p(r, NULL); \
15- } while (0);
16-
179void test_remote_create__initialize (void )
1810{
1911 cl_fixture_sandbox ("testrepo.git" );
@@ -76,23 +68,38 @@ void test_remote_create__named(void)
7668
7769void test_remote_create__named_fail_on_invalid_name (void )
7870{
79- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , NULL , TEST_URL ));
80- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , "Inv@{id" , TEST_URL ));
81- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , "" , TEST_URL ));
82- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , "/" , TEST_URL ));
83- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , "//" , TEST_URL ));
84- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , ".lock" , TEST_URL ));
85- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create (& r , _repo , "a.lock" , TEST_URL ));
71+ const char * names [] = {
72+ NULL ,
73+ "Inv@{id" ,
74+ "" ,
75+ "/" ,
76+ "//" ,
77+ ".lock" ,
78+ "a.lock" ,
79+ };
80+ size_t i ;
81+
82+ for (i = 0 ; i < ARRAY_SIZE (names ); i ++ ) {
83+ git_remote * remote = NULL ;
84+ cl_git_fail_with (GIT_EINVALIDSPEC , git_remote_create (& remote , _repo , names [i ], TEST_URL ));
85+ cl_assert_equal_p (remote , NULL );
86+ }
8687}
8788
8889void test_remote_create__named_fail_on_invalid_url (void )
8990{
90- cl_git_assert_cannot_create_remote (GIT_ERROR , git_remote_create (& r , _repo , "bad-url" , "" ));
91+ git_remote * remote = NULL ;
92+
93+ cl_git_fail_with (GIT_ERROR , git_remote_create (& remote , _repo , "bad-url" , "" ));
94+ cl_assert_equal_p (remote , NULL );
9195}
9296
9397void test_remote_create__named_fail_on_conflicting_name (void )
9498{
95- cl_git_assert_cannot_create_remote (GIT_EEXISTS , git_remote_create (& r , _repo , "test" , TEST_URL ));
99+ git_remote * remote = NULL ;
100+
101+ cl_git_fail_with (GIT_EEXISTS , git_remote_create (& remote , _repo , "test" , TEST_URL ));
102+ cl_assert_equal_p (remote , NULL );
96103}
97104
98105void test_remote_create__with_fetchspec (void )
@@ -132,12 +139,18 @@ void test_remote_create__with_empty_fetchspec(void)
132139
133140void test_remote_create__with_fetchspec_invalid_name (void )
134141{
135- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create_with_fetchspec (& r , _repo , NULL , TEST_URL , NULL ));
142+ git_remote * remote = NULL ;
143+
144+ cl_git_fail_with (GIT_EINVALIDSPEC , git_remote_create_with_fetchspec (& remote , _repo , NULL , TEST_URL , NULL ));
145+ cl_assert_equal_p (remote , NULL );
136146}
137147
138148void test_remote_create__with_fetchspec_invalid_url (void )
139149{
140- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create_with_fetchspec (& r , _repo , NULL , "" , NULL ));
150+ git_remote * remote = NULL ;
151+
152+ cl_git_fail_with (GIT_EINVALIDSPEC , git_remote_create_with_fetchspec (& remote , _repo , NULL , "" , NULL ));
153+ cl_assert_equal_p (remote , NULL );
141154}
142155
143156void test_remote_create__anonymous (void )
@@ -161,7 +174,10 @@ void test_remote_create__anonymous(void)
161174
162175void test_remote_create__anonymous_invalid_url (void )
163176{
164- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create_anonymous (& r , _repo , "" ));
177+ git_remote * remote = NULL ;
178+
179+ cl_git_fail_with (GIT_EINVALIDSPEC , git_remote_create_anonymous (& remote , _repo , "" ));
180+ cl_assert_equal_p (remote , NULL );
165181}
166182
167183void test_remote_create__detached (void )
@@ -186,7 +202,10 @@ void test_remote_create__detached(void)
186202
187203void test_remote_create__detached_invalid_url (void )
188204{
189- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , git_remote_create_detached (& r , "" ));
205+ git_remote * remote = NULL ;
206+
207+ cl_git_fail_with (GIT_EINVALIDSPEC , git_remote_create_detached (& remote , "" ));
208+ cl_assert_equal_p (remote , NULL );
190209}
191210
192211void test_remote_create__with_opts_named (void )
@@ -336,20 +355,35 @@ static int create_with_name(git_remote **remote, git_repository *repo, const cha
336355
337356void test_remote_create__with_opts_invalid_name (void )
338357{
339- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "Inv@{id" , TEST_URL ));
340- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "" , TEST_URL ));
341- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "/" , TEST_URL ));
342- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "//" , TEST_URL ));
343- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , ".lock" , TEST_URL ));
344- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "a.lock" , TEST_URL ));
358+ const char * names [] = {
359+ "Inv@{id" ,
360+ "" ,
361+ "/" ,
362+ "//" ,
363+ ".lock" ,
364+ "a.lock" ,
365+ };
366+ size_t i ;
367+
368+ for (i = 0 ; i < ARRAY_SIZE (names ); i ++ ) {
369+ git_remote * remote = NULL ;
370+ cl_git_fail_with (GIT_EINVALIDSPEC , create_with_name (& remote , _repo , names [i ], TEST_URL ));
371+ cl_assert_equal_p (remote , NULL );
372+ }
345373}
346374
347375void test_remote_create__with_opts_conflicting_name (void )
348376{
349- cl_git_assert_cannot_create_remote (GIT_EEXISTS , create_with_name (& r , _repo , "test" , TEST_URL ));
377+ git_remote * remote = NULL ;
378+
379+ cl_git_fail_with (GIT_EEXISTS , create_with_name (& remote , _repo , "test" , TEST_URL ));
380+ cl_assert_equal_p (remote , NULL );
350381}
351382
352383void test_remote_create__with_opts_invalid_url (void )
353384{
354- cl_git_assert_cannot_create_remote (GIT_EINVALIDSPEC , create_with_name (& r , _repo , "test-new" , "" ));
385+ git_remote * remote = NULL ;
386+
387+ cl_git_fail_with (GIT_EINVALIDSPEC , create_with_name (& remote , _repo , "test-new" , "" ));
388+ cl_assert_equal_p (remote , NULL );
355389}
0 commit comments