C testing framework. ASCII/Unicode portable version
Dimitrie O. Paun
dimi at cs.toronto.edu
Wed Jan 23 11:16:18 CST 2002
On Tue, 22 Jan 2002, Alexandre Julliard wrote:
> Absolutely; but this has nothing to do with TCHAR at all, we need a
> convenient way to specify Unicode strings in any case.
Indeed, the two issues are orthogonal.
Since my Linux box is down for a few days now, here is some untested code
trying to implement the teststr() idea.
wine/tests.h:
/*-----------------------------------------------------------*/
/* The teststr() function iterates through a set of strings */
/* with a certain set of characteristics. When the set is */
/* exausted, it returns NULL. The sets are identified by a */
/* constants defined later in the header, with the prefix */
/* TSC_. Typical usage of the function is as follows: */
/* TCSTR tstr = TSC_XXX; */
/* while ( tstr = teststr(tstr) ) */
/* <code which uses tstr> */
/* Simply replate T with A/W for encoding specific code. */
/*-----------------------------------------------------------*/
LPCWSTR teststrW(LPCWSTR wstr);
LPCSTR teststrA(LPCSTR astr);
/* the TESTSTR.class field defines the class of strings */
/* in the future, we can have a union which holds additional */
/* parameters for the given class of strings. */
typedef struct tagTESTSTRW
{
int class;
LPCWSTR str;
} TESTSTRW, *LPTESTSTRW;
typedef struct tagTESTSTRA
{
int class;
LPCSTR str;
} TESTSTRA, *LPTESTSTRA;
#define _TSCT(cls, strtype, t) \
extern TESTSTR##t tsc_##cls##t; \
LPC##strtype const TSC_##cls##t = &(tsc_##cls##t.str)
#define _TSC(cls) \
_TSCT(cls, WSTR, W); \
_TSCT(cls, STR, A)
#define STR2TESTSTR(str) (LPTESTSTR)( ((void*)str) - \
((void*)&tsc_ANYA.str) - ((void*)&tsc_ANYA) )
/* constants defining the test string sets
#define TSC_ANY _TSC(ANY)
#define TSC_XXX .....
teststr.c:
#define BEGINA (LPCSTR)(-1)
#define BEGINW (LPCWSTR)(-1)
TESTSTRA tsc_ANYA = { 0, BEGINA };
TESTSTRW tsc_ANYW = { 0, BEGINW };
....
LPCSTR teststrA(LPCSTR str)
{
LPTESTSTR tstr = STR2TESTSTR(str);
if (tstr.str == BEGINA) ...
<here we can do a lot of things>
}
<similarly for teststrW>
Now, should I go more into the details of the implementation? Is everyone
convinced that the interface is
(1) simple,
(2) useful,
(3) implementable?
--
Dimi.
More information about the wine-devel
mailing list