[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r38109 - in trunk/subversion/tests: . libsvn_wc

From: Hyrum K. Wright <hyrum_at_hyrumwright.org>
Date: Fri, 19 Jun 2009 16:22:01 -0500

On Jun 19, 2009, at 4:19 PM, Bert Huijben wrote:

>> -----Original Message-----
>> From: Hyrum K. Wright [mailto:hyrum_at_hyrumwright.org]
>> Sent: vrijdag 19 juni 2009 23:10
>> To: svn_at_subversion.tigris.org
>> Subject: svn commit: r38109 - in trunk/subversion/tests: . libsvn_wc
>>
>> Author: hwright
>> Date: Fri Jun 19 14:09:59 2009
>> New Revision: 38109
>>
>> Log:
>> Add a macro for testing string equality in the C testsuite.
>>
>> This could probably use some improvement, but I think it better to
>> commit
>> and let the many eyes do their magic.
>>
>> * subversion/tests/libsvn_wc/db-test.c
>> (test_getting_info, test_working_info, test_scan_addition,
>> test_op_relocate): Use the new macro.
>>
>> * subversion/tests/svn_test.h
>> (SVN_TEST_STRING_ASSERT): New.
>>
>> Modified:
>> trunk/subversion/tests/libsvn_wc/db-test.c
>> trunk/subversion/tests/svn_test.h
>>
>
> <snip />
>
>> Modified: trunk/subversion/tests/svn_test.h
>> URL:
>> http://svn.collab.net/viewvc/svn/trunk/subversion/tests/svn_test.h?path
>> rev=38109&r1=38108&r2=38109
>> =
>> =
>> =====================================================================
>> =======
>> --- trunk/subversion/tests/svn_test.h Fri Jun 19 14:03:28 2009
>> (r38108)
>> +++ trunk/subversion/tests/svn_test.h Fri Jun 19 14:09:59 2009
>> (r38109)
>> @@ -46,6 +46,26 @@ extern "C" {
>> return svn_error_create(SVN_ERR_TEST_FAILED, 0, #expr); \
>> } while (0)
>>
>> +/** Handy macro for testing string equality.
>> + *
>> + * Note: This assumes there is an a pool available for use somewhere
>> in
>> + * in the variable namespace.
>> + */
>> +#define SVN_TEST_STRING_ASSERT(expr,
>> expected_expr) \
>> + do
>> { \
>> + const char *tst_str1 =
>> (expr); \
>> + const char *tst_str2 =
>> (expected_expr); \
>> +
>> \
>> + if (tst_str2 == NULL && tst_str1 ==
>> NULL) \
>> +
>> break; \
>> + if ( (tst_str2 != NULL && tst_str1 ==
>> NULL) \
>> + || (strcmp(tst_str2, tst_str1) !=
>> 0) ) \
>> + return svn_error_create(SVN_ERR_TEST_FAILED,
>> 0, \
>> +
>> apr_psprintf(pool, \
>> + "Strings not equal\n Expected: '%s'\n Found:
>> '%s'", \
>> + tst_str2,
>> tst_str1)); \
>> + } while(0)
>
> Using svn_error_createf() allows removing the pool requirement. (And
> I think
> the second argument to svn_error_create() should be NULL)

Oh excellent! I'll use svn_error_createf() posthaste.

As for the second argument, I was just following the precedent of
SVN_TEST_ASSERT(), and will fix both shortly.

-Hyrum

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2363693
Received on 2009-06-19 23:22:23 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.