kernel32: Make the locale test pass without errors under XP SP2.

This commit is contained in:
Dmitry Timoshkov 2006-12-31 21:11:50 +08:00 committed by Alexandre Julliard
parent b5cce1e525
commit ebd57713aa
1 changed files with 39 additions and 12 deletions

View File

@ -116,8 +116,9 @@ static void InitFunctionPointers(void)
#define EXPECT_INVALIDFLAGS ok(GetLastError() == ERROR_INVALID_FLAGS || \
GetLastError() == ERROR_INVALID_PARAMETER, \
"Expected ERROR_INVALID_FLAGS, got %d\n", GetLastError())
#define EXPECT_VALID ok(GetLastError() == 0, \
#define EXPECT_LASTERROR_0 ok(GetLastError() == 0, \
"Expected GetLastError() == 0, got %d\n", GetLastError())
#define EXPECT_VALID ok(ret, "Expected ret != 0, got %d, error %d\n", ret, GetLastError())
#define STRINGSA(x,y) strcpy(input, x); strcpy(Expected, y); SetLastError(0); buffer[0] = '\0'
#define EXPECT_LENA EXPECT_LEN((int)strlen(Expected)+1)
@ -169,6 +170,7 @@ static void test_GetTimeFormatA(void)
memset(&curtime, 2, sizeof(SYSTEMTIME));
STRINGSA("tt HH':'mm'@'ss", ""); /* Invalid time */
SetLastError(0xdeadbeef);
ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
@ -177,15 +179,18 @@ static void test_GetTimeFormatA(void)
curtime.wSecond = 13;
curtime.wMilliseconds = 22;
STRINGSA("tt HH':'mm'@'ss", "AM 08:56@13"); /* Valid time */
SetLastError(0xdeadbeef);
ret = GetTimeFormatA(lcid, NUO|TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("tt HH':'mm'@'ss", "A"); /* Insufficent buffer */
ret = GetTimeFormatA(lcid, NUO|TIME_FORCE24HOURFORMAT, &curtime, input, buffer, 2);
SetLastError(0xdeadbeef);
ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, 2);
EXPECT_BUFFER; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("tt HH':'mm'@'ss", "AM 08:56@13"); /* Calculate length only */
ret = GetTimeFormatA(lcid, NUO|TIME_FORCE24HOURFORMAT, &curtime, input, NULL, 0);
ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, NULL, 0);
EXPECT_VALID; EXPECT_LENA;
STRINGSA("", "8 AM"); /* TIME_NOMINUTESORSECONDS, default format */
@ -202,11 +207,11 @@ static void test_GetTimeFormatA(void)
STRINGSA("h:m:s tt", "8:56 AM"); /* TIME_NOSECONDS */
strcpy(Expected, "8:56 AM");
ret = GetTimeFormatA(lcid, NUO|TIME_NOSECONDS, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, TIME_NOSECONDS, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("h.@:m.@:s.@:tt", "8.@:56AM"); /* Multiple delimiters */
ret = GetTimeFormatA(lcid, NUO|TIME_NOSECONDS, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, TIME_NOSECONDS, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("s1s2s3", ""); /* Duplicate tokens */
@ -214,12 +219,12 @@ static void test_GetTimeFormatA(void)
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("t/tt", "A/AM"); /* AM time marker */
ret = GetTimeFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
curtime.wHour = 13;
STRINGSA("t/tt", "P/PM"); /* PM time marker */
ret = GetTimeFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("h1t2tt3m", "156"); /* TIME_NOTIMEMARKER: removes text around time marker token */
@ -227,7 +232,7 @@ static void test_GetTimeFormatA(void)
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("h:m:s tt", "13:56:13 PM"); /* TIME_FORCE24HOURFORMAT */
ret = GetTimeFormatA(lcid, NUO|TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, TIME_FORCE24HOURFORMAT, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("h:m:s", "13:56:13"); /* TIME_FORCE24HOURFORMAT doesn't add time marker */
@ -238,7 +243,7 @@ static void test_GetTimeFormatA(void)
curtime.wMinute = 5;
curtime.wSecond = 3;
STRINGSA("h hh H HH m mm s ss t tt", "2 02 14 14 5 05 3 03 P PM"); /* 24 hrs, leading 0 */
ret = GetTimeFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
curtime.wHour = 0;
@ -247,7 +252,7 @@ static void test_GetTimeFormatA(void)
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("h:m:s tt", "12:5:3 AM"); /* non-zero flags should fail with format, doesn't */
ret = GetTimeFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
/* try to convert formatting strings with more than two letters
@ -272,7 +277,7 @@ static void test_GetTimeFormatA(void)
STRINGSA("h 'h' H 'H' HH 'HH' m 'm' s 's' t 't' tt 'tt'",
"8 h 8 H 08 HH 56 m 13 s A t AM tt"); /* "'" preserves tokens */
ret = GetTimeFormatA(lcid, NUO, &curtime, input, buffer, COUNTOF(buffer));
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_VALID; EXPECT_LENA; EXPECT_EQA;
STRINGSA("'''", "'"); /* invalid quoted string */
@ -303,6 +308,7 @@ static void test_GetTimeFormatA(void)
curtime.wHour = 25;
STRINGSA("'123'tt", ""); /* Invalid time */
SetLastError(0xdeadbeef);
ret = GetTimeFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
@ -322,6 +328,7 @@ static void test_GetDateFormatA(void)
memset(&curtime, 2, sizeof(SYSTEMTIME)); /* Invalid time */
STRINGSA("ddd',' MMM dd yy","");
SetLastError(0xdeadbeef);
ret = GetDateFormatA(lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
@ -347,6 +354,7 @@ static void test_GetDateFormatA(void)
EXPECT_VALID; EXPECT_LEN(16); EXPECT_EQA;
STRINGSA("ddd',' MMM dd ''''yy",""); /* Buffer too small */
SetLastError(0xdeadbeef);
ret = GetDateFormatA(lcid, 0, &curtime, input, buffer, 2);
EXPECT_BUFFER; EXPECT_LEN(0); EXPECT_EQA;
@ -389,6 +397,7 @@ static void test_GetDateFormatW(void)
EXPECT_FLAGS; EXPECT_LEN(0); EXPECT_EQW;
STRINGSW("",""); /* NULL buffer, len > 0 */
SetLastError(0xdeadbeef);
ret = GetDateFormatW (lcid, 0, NULL, input, NULL, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQW;
@ -428,38 +437,47 @@ static void test_GetCurrencyFormatA(void)
memset(&format, 0, sizeof(format));
STRINGSA("23",""); /* NULL output, length > 0 --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, NULL, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("23,53",""); /* Invalid character --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("--",""); /* Double '-' --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("0-",""); /* Trailing '-' --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("0..",""); /* Double '.' --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA(" 0.1",""); /* Leading space --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("1234","$"); /* Length too small --> Write up to length chars */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, NUO, input, NULL, buffer, 2);
EXPECT_BUFFER; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("2353",""); /* Format and flags given --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, NUO, input, &format, buffer, COUNTOF(buffer));
EXPECT_INVALIDFLAGS; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("2353",""); /* Invalid format --> Error */
SetLastError(0xdeadbeef);
ret = GetCurrencyFormatA(lcid, 0, input, &format, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
@ -625,38 +643,47 @@ static void test_GetNumberFormatA(void)
memset(&format, 0, sizeof(format));
STRINGSA("23",""); /* NULL output, length > 0 --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, NULL, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("23,53",""); /* Invalid character --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("--",""); /* Double '-' --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("0-",""); /* Trailing '-' --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("0..",""); /* Double '.' --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA(" 0.1",""); /* Leading space --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, NULL, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("1234","1"); /* Length too small --> Write up to length chars */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, NUO, input, NULL, buffer, 2);
EXPECT_BUFFER; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("2353",""); /* Format and flags given --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, NUO, input, &format, buffer, COUNTOF(buffer));
EXPECT_INVALIDFLAGS; EXPECT_LEN(0); EXPECT_EQA;
STRINGSA("2353",""); /* Invalid format --> Error */
SetLastError(0xdeadbeef);
ret = GetNumberFormatA(lcid, 0, input, &format, buffer, COUNTOF(buffer));
EXPECT_INVALID; EXPECT_LEN(0); EXPECT_EQA;
@ -1973,7 +2000,7 @@ static void test_EnumSystemLanguageGroupsA(void)
/* No flags - defaults to LGRPID_INSTALLED */
SetLastError(0);
pEnumSystemLanguageGroupsA(langgrp_procA, 0, 1);
EXPECT_VALID;
EXPECT_LASTERROR_0;
pEnumSystemLanguageGroupsA(langgrp_procA, LGRPID_INSTALLED, 0);
pEnumSystemLanguageGroupsA(langgrp_procA, LGRPID_SUPPORTED, 0);