Added tests for FoldStringA/W.
This commit is contained in:
parent
4938f6b993
commit
13a5d6e627
|
@ -28,11 +28,37 @@
|
|||
|
||||
#include "wine/test.h"
|
||||
#include "windef.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "winbase.h"
|
||||
#include "winerror.h"
|
||||
#include "winnls.h"
|
||||
|
||||
static inline unsigned int strlenW( const WCHAR *str )
|
||||
{
|
||||
const WCHAR *s = str;
|
||||
while (*s) s++;
|
||||
return s - str;
|
||||
}
|
||||
|
||||
static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n )
|
||||
{
|
||||
if (n <= 0) return 0;
|
||||
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
|
||||
return *str1 - *str2;
|
||||
}
|
||||
|
||||
static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch )
|
||||
{
|
||||
for ( ; *str; str++) if (*str == ch) return (WCHAR *)str;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline static int isdigitW( WCHAR wc )
|
||||
{
|
||||
WORD type;
|
||||
GetStringTypeW( CT_CTYPE1, &wc, 1, &type );
|
||||
return type & C1_DIGIT;
|
||||
}
|
||||
|
||||
/* Some functions are only in later versions of kernel32.dll */
|
||||
static HMODULE hKernel32;
|
||||
|
||||
|
@ -43,6 +69,10 @@ typedef BOOL (WINAPI *EnumLanguageGroupLocalesAFn)(LANGGROUPLOCALE_ENUMPROC,
|
|||
LGRPID, DWORD, LONG_PTR);
|
||||
static EnumLanguageGroupLocalesAFn pEnumLanguageGroupLocalesA;
|
||||
|
||||
typedef INT (WINAPI *FoldStringAFn)(DWORD, LPCSTR, INT, LPSTR, INT);
|
||||
static FoldStringAFn pFoldStringA;
|
||||
typedef INT (WINAPI *FoldStringWFn)(DWORD, LPCWSTR, INT, LPWSTR, INT);
|
||||
static FoldStringWFn pFoldStringW;
|
||||
|
||||
static void InitFunctionPointers(void)
|
||||
{
|
||||
|
@ -51,7 +81,9 @@ static void InitFunctionPointers(void)
|
|||
if (hKernel32)
|
||||
{
|
||||
pEnumSystemLanguageGroupsA = (void*)GetProcAddress(hKernel32, "EnumSystemLanguageGroupsA");
|
||||
pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
|
||||
pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
|
||||
pFoldStringA = (void*)GetProcAddress(hKernel32, "FoldStringA");
|
||||
pFoldStringW = (void*)GetProcAddress(hKernel32, "FoldStringW");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +95,7 @@ static void InitFunctionPointers(void)
|
|||
char GlobalBuffer[BUFFER_SIZE]; /* Buffer used by callback function */
|
||||
#define COUNTOF(x) (sizeof(x)/sizeof(x)[0])
|
||||
|
||||
#define EXPECT_LEN(len) ok(ret == len, "Expected Len %d, got %d\n", len, ret)
|
||||
#define EXPECT_LEN(len) ok(ret == (len), "Expected Len %d, got %d\n", (len), ret)
|
||||
#define EXPECT_INVALID ok(GetLastError() == ERROR_INVALID_PARAMETER, \
|
||||
"Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError())
|
||||
#define EXPECT_BUFFER ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, \
|
||||
|
@ -77,14 +109,14 @@ char GlobalBuffer[BUFFER_SIZE]; /* Buffer used by callback function */
|
|||
"Expected GetLastError() == 0, got %ld\n", GetLastError())
|
||||
|
||||
#define STRINGSA(x,y) strcpy(input, x); strcpy(Expected, y); SetLastError(0); buffer[0] = '\0'
|
||||
#define EXPECT_LENA EXPECT_LEN(strlen(Expected)+1)
|
||||
#define EXPECT_LENA EXPECT_LEN((int)strlen(Expected)+1)
|
||||
#define EXPECT_EQA ok(strncmp(buffer, Expected, strlen(Expected)) == 0, \
|
||||
"Expected '%s', got '%s'", Expected, buffer)
|
||||
|
||||
#define STRINGSW(x,y) MultiByteToWideChar(CP_ACP,0,x,-1,input,COUNTOF(input)); \
|
||||
MultiByteToWideChar(CP_ACP,0,y,-1,Expected,COUNTOF(Expected)); \
|
||||
SetLastError(0); buffer[0] = '\0'
|
||||
#define EXPECT_LENW EXPECT_LEN(strlenW(Expected)+1)
|
||||
#define EXPECT_LENW EXPECT_LEN((int)strlenW(Expected)+1)
|
||||
#define EXPECT_EQW ok(strncmpW(buffer, Expected, strlenW(Expected)) == 0, "Bad conversion\n")
|
||||
|
||||
#define NUO LOCALE_NOUSEROVERRIDE
|
||||
|
@ -1039,6 +1071,481 @@ void test_LCMapStringW(void)
|
|||
ok(!lstrcmpW(buf, symbols_stripped), "string comparison mismatch\n");
|
||||
}
|
||||
|
||||
void test_FoldStringA(void)
|
||||
{
|
||||
int ret, i;
|
||||
char src[256], dst[256];
|
||||
static const char digits_src[] = { 0xB9,0xB2,0xB3,'\0' };
|
||||
static const char digits_dst[] = { '1','2','3','\0' };
|
||||
static const char composite_src[] =
|
||||
{
|
||||
0x8a,0x8e,0x9a,0x9e,0x9f,0xc0,0xc1,0xc2,
|
||||
0xc3,0xc4,0xc5,0xc7,0xc8,0xc9,0xca,0xcb,
|
||||
0xcc,0xcd,0xce,0xcf,0xd1,0xd2,0xd3,0xd4,
|
||||
0xd5,0xd6,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,
|
||||
0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe7,0xe8,
|
||||
0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,0xf1,
|
||||
0xf2,0xf3,0xf4,0xf5,0xf6,0xf8,0xf9,0xfa,
|
||||
0xfb,0xfc,0xfd,0xff,'\0'
|
||||
};
|
||||
static const char composite_dst[] =
|
||||
{
|
||||
0x53,0x3f,0x5a,0x3f,0x73,0x3f,0x7a,0x3f,
|
||||
0x59,0xa8,0x41,0x60,0x41,0xb4,0x41,0x5e,
|
||||
0x41,0x7e,0x41,0xa8,0x41,0xb0,0x43,0xb8,
|
||||
0x45,0x60,0x45,0xb4,0x45,0x5e,0x45,0xa8,
|
||||
0x49,0x60,0x49,0xb4,0x49,0x5e,0x49,0xa8,
|
||||
0x4e,0x7e,0x4f,0x60,0x4f,0xb4,0x4f,0x5e,
|
||||
0x4f,0x7e,0x4f,0xa8,0x4f,0x3f,0x55,0x60,
|
||||
0x55,0xb4,0x55,0x5e,0x55,0xa8,0x59,0xb4,
|
||||
0x61,0x60,0x61,0xb4,0x61,0x5e,0x61,0x7e,
|
||||
0x61,0xa8,0x61,0xb0,0x63,0xb8,0x65,0x60,
|
||||
0x65,0xb4,0x65,0x5e,0x65,0xa8,0x69,0x60,
|
||||
0x69,0xb4,0x69,0x5e,0x69,0xa8,0x6e,0x7e,
|
||||
0x6f,0x60,0x6f,0xb4,0x6f,0x5e,0x6f,0x7e,
|
||||
0x6f,0xa8,0x6f,0x3f,0x75,0x60,0x75,0xb4,
|
||||
0x75,0x5e,0x75,0xa8,0x79,0xb4,0x79,0xa8,'\0'
|
||||
};
|
||||
static const char ligatures_src[] =
|
||||
{
|
||||
0x8C,0x9C,0xC6,0xDE,0xDF,0xE6,0xFE,'\0'
|
||||
};
|
||||
static const char ligatures_dst[] =
|
||||
{
|
||||
'O','E','o','e','A','E','T','H','s','s','a','e','t','h','\0'
|
||||
};
|
||||
|
||||
if (!pFoldStringA)
|
||||
return; /* FoldString is present in NT v3.1+, but not 95/98/Me */
|
||||
|
||||
/* MAP_FOLDDIGITS */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_FOLDDIGITS, digits_src, -1, dst, 256);
|
||||
EXPECT_LEN(4); EXPECT_VALID;
|
||||
ok(strcmp(dst, digits_dst) == 0,
|
||||
"MAP_FOLDDIGITS: Expected '%s', got '%s'\n", digits_dst, dst);
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
if (!strchr(digits_src, i))
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_FOLDDIGITS, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == src[0],
|
||||
"MAP_FOLDDIGITS: Expected '%s', got '%s'\n", src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
/* MAP_EXPAND_LIGATURES */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_EXPAND_LIGATURES, ligatures_src, -1, dst, 256);
|
||||
EXPECT_LEN(sizeof(ligatures_dst)); EXPECT_VALID;
|
||||
ok(strcmp(dst, ligatures_dst) == 0,
|
||||
"MAP_EXPAND_LIGATURES: Expected '%s', got '%s'\n", ligatures_dst, dst);
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
if (!strchr(ligatures_src, i))
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_EXPAND_LIGATURES, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == src[0],
|
||||
"MAP_EXPAND_LIGATURES: Expected '%s', got '%s'\n", src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
/* MAP_COMPOSITE */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_COMPOSITE, composite_src, -1, dst, 256);
|
||||
EXPECT_VALID;
|
||||
todo_wine
|
||||
{
|
||||
/* Wine gets close, but doesn't produce quite the same result as native */
|
||||
EXPECT_LEN(121);
|
||||
ok(strcmp(dst, composite_dst) == 0,
|
||||
"MAP_COMPOSITE: Expected '%s', got '%s'\n", composite_dst, dst);
|
||||
}
|
||||
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
if (!strchr(composite_src, i))
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = pFoldStringA(MAP_COMPOSITE, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == src[0],
|
||||
"0x%02x, 0x%02x,0x%02x,0x%02x,\n", (unsigned char)src[0],
|
||||
(unsigned char)dst[0],(unsigned char)dst[1],(unsigned char)dst[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* MAP_FOLDCZONE */
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = FoldStringA(MAP_FOLDCZONE, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(src[0] == dst[0],
|
||||
"MAP_FOLDCZONE: Expected 0x%02x, got 0x%02x\n",
|
||||
(unsigned char)src[0], (unsigned char)dst[0]);
|
||||
}
|
||||
|
||||
/* MAP_PRECOMPOSED */
|
||||
for (i = 1; i < 256; i++)
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = FoldStringA(MAP_PRECOMPOSED, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(src[0] == dst[0],
|
||||
"MAP_PRECOMPOSED: Expected 0x%02x, got 0x%02x\n",
|
||||
(unsigned char)src[0], (unsigned char)dst[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void test_FoldStringW(void)
|
||||
{
|
||||
int ret;
|
||||
size_t i, j;
|
||||
WCHAR src[256], dst[256], ch, prev_ch = 1;
|
||||
static const DWORD badFlags[] =
|
||||
{
|
||||
0,
|
||||
MAP_PRECOMPOSED|MAP_COMPOSITE,
|
||||
MAP_PRECOMPOSED|MAP_EXPAND_LIGATURES,
|
||||
MAP_COMPOSITE|MAP_EXPAND_LIGATURES
|
||||
};
|
||||
/* Ranges of digits 0-9 : Must be sorted! */
|
||||
static const WCHAR digitRanges[] =
|
||||
{
|
||||
0x0030, /* '0'-'9' */
|
||||
0x0660, /* Eastern Arabic */
|
||||
0x06F0, /* Arabic - Hindu */
|
||||
0x0966, /* Devengari */
|
||||
0x09E6, /* Bengalii */
|
||||
0x0A66, /* Gurmukhi */
|
||||
0x0AE6, /* Gujarati */
|
||||
0x0B66, /* Oriya */
|
||||
0x0BE6, /* Tamil - No 0 */
|
||||
0x0C66, /* Telugu */
|
||||
0x0CE6, /* Kannada */
|
||||
0x0D66, /* Maylayalam */
|
||||
0x0E50, /* Thai */
|
||||
0x0ED0, /* Laos */
|
||||
0x2070, /* Superscript - 1, 2, 3 are out of sequence */
|
||||
0x2080, /* Subscript */
|
||||
0x245F, /* Circled - 0 is out of sequence */
|
||||
0x2473, /* Bracketed */
|
||||
0x2487, /* Full stop */
|
||||
0x2775, /* Inverted circled - No 0 */
|
||||
0x277F, /* Patterned circled - No 0 */
|
||||
0x2789, /* Inverted Patterned circled - No 0 */
|
||||
0xff10, /* Pliene chasse (?) */
|
||||
0xffff /* Terminator */
|
||||
};
|
||||
/* Digits which are represented, but out of sequence */
|
||||
static const WCHAR outOfSequenceDigits[] =
|
||||
{
|
||||
0xB9, /* Superscript 1 */
|
||||
0xB2, /* Superscript 2 */
|
||||
0xB3, /* Superscript 3 */
|
||||
0x24EA, /* Circled 0 */
|
||||
'\0' /* Terminator */
|
||||
};
|
||||
/* Digits in digitRanges for which no representation is available */
|
||||
static const WCHAR noDigitAvailable[] =
|
||||
{
|
||||
0x0BE6, /* No Tamil 0 */
|
||||
0x2473, /* No Bracketed 0 */
|
||||
0x2487, /* No 0 Full stop */
|
||||
0x2775, /* No inverted circled 0 */
|
||||
0x277F, /* No patterned circled */
|
||||
0x2789, /* No inverted Patterned circled */
|
||||
'\0' /* Terminator */
|
||||
};
|
||||
/* Compatability conversion results */
|
||||
static const WCHAR compat_F900_FA2F[256+48] =
|
||||
{
|
||||
0x8c48, 0x66f4, 0x8eca, 0x8cc8, 0x6ed1, 0x4e32, 0x53e5, 0x9f9c,
|
||||
0x9f9c, 0x5951, 0x91d1, 0x5587, 0x5948, 0x61f6, 0x7669, 0x7f85,
|
||||
0x863f, 0x87ba, 0x88f8, 0x908f, 0x6a02, 0x6d1b, 0x70d9, 0x73de,
|
||||
0x843d, 0x916a, 0x99f1, 0x4e82, 0x5375, 0x6b04, 0x721b, 0x862d,
|
||||
0x9e1e, 0x5d50, 0x6feb, 0x85cd, 0x8964, 0x62c9, 0x81d8, 0x881f,
|
||||
0x5eca, 0x6717, 0x6d6a, 0x72fc, 0x0000, 0x4f86, 0x51b7, 0x52de,
|
||||
0x64c4, 0x6ad3, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def,
|
||||
0x9732, 0x9b6f, 0x9dfa, 0x788c, 0x797f, 0x7da0, 0x83c9, 0x9304,
|
||||
0x9e7f, 0x8ad6, 0x58df, 0x5f04, 0x7c60, 0x807e, 0x7262, 0x78ca,
|
||||
0x8cc2, 0x96f7, 0x58d8, 0x5c62, 0x6a13, 0x6dda, 0x6f0f, 0x7d2f,
|
||||
0x7e37, 0x964b, 0x52d2, 0x808b, 0x51dc, 0x51cc, 0x7a1c, 0x7dbe,
|
||||
0x83f1, 0x9675, 0x8b80, 0x62cf, 0x6a02, 0x8afe, 0x4e39, 0x5be7,
|
||||
0x6012, 0x7387, 0x7570, 0x5317, 0x78fb, 0x4fbf, 0x5fa9, 0x4e0d,
|
||||
0x6ccc, 0x6578, 0x7d22, 0x53c3, 0x585e, 0x7701, 0x8449, 0x8aaa,
|
||||
0x6bba, 0x8fb0, 0x6c88, 0x62fe, 0x82e5, 0x63a0, 0x7565, 0x4eae,
|
||||
0x5169, 0x0000, 0x6881, 0x7ce7, 0x826f, 0x8ad2, 0x91cf, 0x52f5,
|
||||
0x5442, 0x5973, 0x5eec, 0x65c5, 0x6ffe, 0x792a, 0x95ad, 0x9a6a,
|
||||
0x9e97, 0x9ece, 0x529b, 0x66c6, 0x6b77, 0x8f62, 0x5e74, 0x6190,
|
||||
0x6200, 0x649a, 0x6f23, 0x7149, 0x7489, 0x0000, 0x7df4, 0x806f,
|
||||
0x8f26, 0x84ee, 0x9023, 0x934a, 0x5217, 0x52a3, 0x54bd, 0x70c8,
|
||||
0x88c2, 0x8aaa, 0x5ec9, 0x5ff5, 0x637b, 0x6bae, 0x7c3e, 0x7375,
|
||||
0x4ee4, 0x56f9, 0x5be7, 0x5dba, 0x601c, 0x73b2, 0x7469, 0x7f9a,
|
||||
0x8046, 0x9234, 0x96f6, 0x9748, 0x9818, 0x4f8b, 0x79ae, 0x91b4,
|
||||
0x96b8, 0x60e1, 0x4e86, 0x50da, 0x5bee, 0x5c3f, 0x6599, 0x6a02,
|
||||
0x71ce, 0x7642, 0x84fc, 0x907c, 0x9f8d, 0x6688, 0x962e, 0x5289,
|
||||
0x677b, 0x67f3, 0x6d41, 0x6e9c, 0x7409, 0x7559, 0x786b, 0x7d10,
|
||||
0x985e, 0x516d, 0x622e, 0x9678, 0x502b, 0x5d19, 0x6dea, 0x8f2a,
|
||||
0x5f8b, 0x6144, 0x6817, 0x7387, 0x9686, 0x5229, 0x540f, 0x5c65,
|
||||
0x6613, 0x674e, 0x68a8, 0x6ce5, 0x7406, 0x75e2, 0x7f79, 0x0000,
|
||||
0x88e1, 0x91cc, 0x96e2, 0x533f, 0x6eba, 0x541d, 0x71d0, 0x7498,
|
||||
0x85fa, 0x0000, 0x9c57, 0x9e9f, 0x6797, 0x6dcb, 0x81e8, 0x7acb,
|
||||
0x7b20, 0x7c92, 0x72c0, 0x7099, 0x8b58, 0x4ec0, 0x8336, 0x523a,
|
||||
0x5207, 0x5ea6, 0x62d3, 0x7cd6, 0x5b85, 0x6d1e, 0x66b4, 0x8f3b,
|
||||
0x884c, 0x964d, 0x898b, 0x5ed3, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x585a, 0x0000, 0x6674, 0x0000, 0x0000, 0x51de, 0x8c6c, 0x76ca,
|
||||
0x0000, 0x795e, 0x7965, 0x798f, 0x9756, 0x7cbe, 0x7fbd, 0x0000,
|
||||
0x0000, 0x0000, 0x8af8, 0x0000, 0x0000, 0x9038, 0x90fd, 0x0000,
|
||||
0x0000, 0x0000, 0x98ef, 0x98fc, 0x9928, 0x9db4, 0x0000, 0x0000
|
||||
};
|
||||
static const WCHAR compat_FE30_FEF7[200] =
|
||||
{
|
||||
0x2025, 0x2014, 0x2013, 0x005f, 0x005f, 0x0028, 0x0029, 0x007b,
|
||||
0x007d, 0x3014, 0x3015, 0x3010, 0x3011, 0x300a, 0x300b, 0x3008,
|
||||
0x3009, 0x300c, 0x300d, 0x300e, 0x300f, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x203e, 0x203e, 0x203e, 0x203e, 0x005f, 0x005f, 0x005f,
|
||||
0x002c, 0x3001, 0x002e, 0x0000, 0x003b, 0x003a, 0x003f, 0x0021,
|
||||
0x2014, 0x0028, 0x0029, 0x007b, 0x007d, 0x3014, 0x3015, 0x0023,
|
||||
0x0026, 0x002a, 0x002b, 0x002d, 0x003c, 0x003e, 0x003d, 0x0000,
|
||||
0x0000, 0x0024, 0x0025, 0x0040, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x064b, 0x064b, 0x064c, 0x0000, 0x064d, 0x0000, 0x064e, 0x064e,
|
||||
0x064f, 0x064f, 0x0650, 0x0650, 0x0651, 0x0651, 0x0652, 0x0652,
|
||||
0x0621, 0x0622, 0x0622, 0x0623, 0x0623, 0x0624, 0x0624, 0x0625,
|
||||
0x0625, 0x0626, 0x0626, 0x0626, 0x0626, 0x0627, 0x0627, 0x0628,
|
||||
0x0628, 0x0628, 0x0628, 0x0629, 0x0629, 0x062a, 0x062a, 0x062a,
|
||||
0x062a, 0x062b, 0x062b, 0x062b, 0x062b, 0x062c, 0x062c, 0x062c,
|
||||
0x062c, 0x062d, 0x062d, 0x062d, 0x062d, 0x062e, 0x062e, 0x062e,
|
||||
0x062e, 0x062f, 0x062f, 0x0630, 0x0630, 0x0631, 0x0631, 0x0632,
|
||||
0x0632, 0x0633, 0x0633, 0x0633, 0x0633, 0x0634, 0x0634, 0x0634,
|
||||
0x0634, 0x0635, 0x0635, 0x0635, 0x0635, 0x0636, 0x0636, 0x0636,
|
||||
0x0636, 0x0637, 0x0637, 0x0637, 0x0637, 0x0638, 0x0638, 0x0638,
|
||||
0x0638, 0x0639, 0x0639, 0x0639, 0x0639, 0x063a, 0x063a, 0x063a,
|
||||
0x063a, 0x0641, 0x0641, 0x0641, 0x0641, 0x0642, 0x0642, 0x0642,
|
||||
0x0642, 0x0643, 0x0643, 0x0643, 0x0643, 0x0644, 0x0644, 0x0644,
|
||||
0x0644, 0x0645, 0x0645, 0x0645, 0x0645, 0x0646, 0x0646, 0x0646,
|
||||
0x0646, 0x0647, 0x0647, 0x0647, 0x0647, 0x0648, 0x0648, 0x0649,
|
||||
0x0649, 0x064a, 0x064a, 0x064a, 0x064a, 0x0000, 0x0000, 0x0000
|
||||
};
|
||||
static const WCHAR compat_FF00_FFEF[240] =
|
||||
{
|
||||
0x0000, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
|
||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005a, 0x005b, 0x0000, 0x005d, 0x005e, 0x005f,
|
||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
||||
0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x0000,
|
||||
0x0000, 0x3002, 0x300c, 0x300d, 0x3001, 0x30fb, 0x30f2, 0x30a1,
|
||||
0x30a3, 0x30a5, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3,
|
||||
0x30fc, 0x30a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad,
|
||||
0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd,
|
||||
0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc,
|
||||
0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de,
|
||||
0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8, 0x30e9,
|
||||
0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c,
|
||||
0x3164, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137,
|
||||
0x3138, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f,
|
||||
0x3140, 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147,
|
||||
0x3148, 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x0000,
|
||||
0x0000, 0x0000, 0x314f, 0x3150, 0x3151, 0x3152, 0x3153, 0x3154,
|
||||
0x0000, 0x0000, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a,
|
||||
0x0000, 0x0000, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160,
|
||||
0x0000, 0x0000, 0x3161, 0x3162, 0x3163, 0x0000, 0x0000, 0x0000,
|
||||
0x00a2, 0x00a3, 0x00ac, 0x00af, 0x00a6, 0x00a5, 0x20a9, 0x0000,
|
||||
0x2502, 0x2190, 0x2191, 0x2192, 0x2193, 0x25a0, 0x25cb, 0x0000
|
||||
};
|
||||
static const WCHAR ligatures_src[] =
|
||||
{
|
||||
0x00c6, 0x00de, 0x00df, 0x00e6, 0x00fe, 0x0132, 0x0133, 0x0152,
|
||||
0x0153, 0x01c4, 0x01c5, 0x01c6, 0x01c7, 0x01c8, 0x01c9, 0x01ca,
|
||||
0x01cb, 0x01cc, 0x01e2, 0x01e3, 0x01f1, 0x01f2, 0x01f3, 0x01fc,
|
||||
0x01fd, 0x05f0, 0x05f1, 0x05f2, 0xfb00, 0xfb01, 0xfb02, 0xfb03,
|
||||
0xfb04, 0xfb05, 0xfb06, '\0'
|
||||
};
|
||||
static const WCHAR ligatures_dst[] =
|
||||
{
|
||||
'A','E','T','H','s','s','a','e','t','h','I','J','i','j','O','E','o','e',
|
||||
'D',0x017d,'D',0x017e,'d',0x017e,'L','J','L','j','l','j','N','J','N','j',
|
||||
'n','j',0x0100,0x0112,0x0101,0x0113,'D','Z','D','z','d','z',0x00c1,0x00c9,
|
||||
0x00e1,0x00e9,0x05d5,0x05d5,0x05d5,0x05d9,0x05d9,0x05d9,'f','f','f','i',
|
||||
'f','l','f','f','i','f','f','l',0x017f,'t','s','t','\0'
|
||||
};
|
||||
|
||||
if (!pFoldStringW)
|
||||
return; /* FoldString is present in NT v3.1+, but not 95/98/Me */
|
||||
|
||||
/* Invalid flag combinations */
|
||||
for (i = 0; i < sizeof(badFlags)/sizeof(badFlags[0]); i++)
|
||||
{
|
||||
src[0] = dst[0] = '\0';
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(badFlags[i], src, 256, dst, 256);
|
||||
EXPECT_LEN(0); EXPECT_FLAGS;
|
||||
}
|
||||
|
||||
/* src & dst cannot be the same */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, -1, src, 256);
|
||||
EXPECT_LEN(0); EXPECT_INVALID;
|
||||
|
||||
/* src can't be NULL */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, NULL, -1, dst, 256);
|
||||
EXPECT_LEN(0); EXPECT_INVALID;
|
||||
|
||||
/* srclen can't be 0 */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, 0, dst, 256);
|
||||
EXPECT_LEN(0); EXPECT_INVALID;
|
||||
|
||||
/* dstlen can't be < 0 */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, -1, dst, -1);
|
||||
EXPECT_LEN(0); EXPECT_INVALID;
|
||||
|
||||
/* Ret includes terminating NUL which is appended if srclen = -1 */
|
||||
SetLastError(0);
|
||||
src[0] = 'A';
|
||||
src[1] = '\0';
|
||||
dst[0] = '\0';
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == 'A' && dst[1] == '\0',
|
||||
"srclen=-1: Expected ret=2 [%d,%d], got ret=%d [%d,%d], err=%ld\n",
|
||||
'A', '\0', ret, dst[0], dst[1], GetLastError());
|
||||
|
||||
/* If size is given, result is not NUL terminated */
|
||||
SetLastError(0);
|
||||
src[0] = 'A';
|
||||
src[1] = 'A';
|
||||
dst[0] = 'X';
|
||||
dst[1] = 'X';
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, 1, dst, 256);
|
||||
EXPECT_LEN(1); EXPECT_VALID;
|
||||
ok(dst[0] == 'A' && dst[1] == 'X',
|
||||
"srclen=1: Expected ret=1, [%d,%d], got ret=%d,[%d,%d], err=%ld\n",
|
||||
'A','X', ret, dst[0], dst[1], GetLastError());
|
||||
|
||||
/* MAP_FOLDDIGITS */
|
||||
for (j = 0; j < sizeof(digitRanges)/sizeof(digitRanges[0]); j++)
|
||||
{
|
||||
/* Check everything before this range */
|
||||
for (ch = prev_ch; ch < digitRanges[j]; ch++)
|
||||
{
|
||||
SetLastError(0);
|
||||
src[0] = ch;
|
||||
src[1] = dst[0] = '\0';
|
||||
ret = pFoldStringW(MAP_FOLDDIGITS, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
|
||||
ok(dst[0] == ch || strchrW(outOfSequenceDigits, ch) ||
|
||||
/* Wine (correctly) maps all Unicode 4.0+ digits */
|
||||
isdigitW(ch) || (ch >= 0x24F5 && ch <= 0x24FD) || ch == 0x24FF,
|
||||
"MAP_FOLDDIGITS: ch %d 0x%04x Expected unchanged got %d\n", ch, ch, dst[0]);
|
||||
}
|
||||
|
||||
if (digitRanges[j] == 0xffff)
|
||||
break; /* Finished the whole code point space */
|
||||
|
||||
for (ch = digitRanges[j]; ch < digitRanges[j] + 10; ch++)
|
||||
{
|
||||
WCHAR c;
|
||||
|
||||
/* Map out of sequence characters */
|
||||
if (ch == 0x2071) c = 0x00B9; /* Superscript 1 */
|
||||
else if (ch == 0x2072) c = 0x00B2; /* Superscript 2 */
|
||||
else if (ch == 0x2073) c = 0x00B3; /* Superscript 3 */
|
||||
else if (ch == 0x245F) c = 0x24EA; /* Circled 0 */
|
||||
else c = ch;
|
||||
SetLastError(0);
|
||||
src[0] = c;
|
||||
src[1] = dst[0] = '\0';
|
||||
ret = pFoldStringW(MAP_FOLDDIGITS, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
|
||||
ok((dst[0] == '0' + ch - digitRanges[j] && dst[1] == '\0') ||
|
||||
strchrW(noDigitAvailable, c),
|
||||
"MAP_FOLDDIGITS: ch %d Expected %d got %d\n",
|
||||
ch, '0' + digitRanges[j] - ch, dst[0]);
|
||||
}
|
||||
prev_ch = ch;
|
||||
}
|
||||
|
||||
/* MAP_FOLDCZONE */
|
||||
for (ch = 1; ch <0xffff; ch++)
|
||||
{
|
||||
WCHAR expected = 0;
|
||||
|
||||
if (ch >= 0xF900 && ch <= 0xFA2F)
|
||||
expected = compat_F900_FA2F[ch - 0xF900];
|
||||
else if (ch >= 0xFE30 && ch <= 0xFEF7)
|
||||
expected = compat_FE30_FEF7[ch - 0xFE30];
|
||||
else if (ch >= 0xFF00 && ch <= 0xFFEF)
|
||||
expected = compat_FF00_FFEF[ch - 0xFF00];
|
||||
|
||||
if (!expected)
|
||||
expected = ch;
|
||||
|
||||
SetLastError(0);
|
||||
src[0] = ch;
|
||||
src[1] = dst[0] = '\0';
|
||||
ret = pFoldStringW(MAP_FOLDCZONE, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == expected ||
|
||||
/* Wine (correctly) uses updated mappings for some Unicode 4.0 chars */
|
||||
(ch >= 0xFA0D && ch <= 0xFA47) ||
|
||||
0xf92c || ch == 0xf979 || ch == 0xf995 || ch == 0xf9e7 || ch == 0xf9f1,
|
||||
"MAP_FOLDCZONE: ch %d 0x%04x Expected 0x%04x got 0x%04x\n",
|
||||
ch, ch, expected, dst[0]);
|
||||
}
|
||||
|
||||
/* MAP_EXPAND_LIGATURES */
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_EXPAND_LIGATURES, ligatures_src, -1, dst, 256);
|
||||
EXPECT_LEN(sizeof(ligatures_dst)/sizeof(ligatures_dst[0])); EXPECT_VALID;
|
||||
ok(!memcmp(dst, ligatures_dst, sizeof(ligatures_dst)),
|
||||
"MAP_EXPAND_LIGATURES: Expanded incorrrectly\n");
|
||||
for (i = 1; i <= 0xffff; i++)
|
||||
{
|
||||
if (!strchrW(ligatures_src, i))
|
||||
{
|
||||
src[0] = i;
|
||||
src[1] = '\0';
|
||||
SetLastError(0);
|
||||
ret = pFoldStringW(MAP_EXPAND_LIGATURES, src, -1, dst, 256);
|
||||
EXPECT_LEN(2); EXPECT_VALID;
|
||||
ok(dst[0] == src[0],
|
||||
"MAP_EXPAND_LIGATURES: 0x%02x : Expected 0x%02x, got 0x%02x\n",
|
||||
i, src[0], dst[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: MAP_PRECOMPOSED : MAP_COMPOSITE */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define LCID_OK(l) \
|
||||
ok(lcid == l, "Expected lcid = %08lx, got %08lx\n", l, lcid)
|
||||
#define MKLCID(x,y,z) MAKELCID(MAKELANGID(x, y), z)
|
||||
|
@ -1197,6 +1704,8 @@ START_TEST(locale)
|
|||
test_CompareStringA();
|
||||
test_LCMapStringA();
|
||||
test_LCMapStringW();
|
||||
test_FoldStringA();
|
||||
test_FoldStringW();
|
||||
test_ConvertDefaultLocale();
|
||||
test_EnumSystemLanguageGroupsA();
|
||||
test_EnumLanguageGroupLocalesA();
|
||||
|
|
Loading…
Reference in New Issue