Add more tests and fix InternetTimeToSystemTimeW accordingly.

This commit is contained in:
Hans Leidekker 2005-03-17 18:55:41 +00:00 committed by Alexandre Julliard
parent c9bd224f0f
commit e82731a3c7
2 changed files with 25 additions and 12 deletions

View File

@ -2155,14 +2155,17 @@ BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD r
TRACE( "%s %p 0x%08lx\n", debugstr_w(string), time, reserved ); TRACE( "%s %p 0x%08lx\n", debugstr_w(string), time, reserved );
if (!string || !time || reserved != 0) return FALSE; if (!string || !time) return FALSE;
/* Windows does this too */
GetSystemTime( time );
/* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
* a SYSTEMTIME structure. * a SYSTEMTIME structure.
*/ */
while (*s && !isalphaW( *s )) s++; while (*s && !isalphaW( *s )) s++;
if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return FALSE; if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
time->wDayOfWeek = 7; time->wDayOfWeek = 7;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
@ -2176,12 +2179,12 @@ BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD r
} }
} }
if (time->wDayOfWeek > 6) return FALSE; if (time->wDayOfWeek > 6) return TRUE;
while (*s && !isdigitW( *s )) s++; while (*s && !isdigitW( *s )) s++;
time->wDay = strtolW( s, &s, 10 ); time->wDay = strtolW( s, &s, 10 );
while (*s && !isalphaW( *s )) s++; while (*s && !isalphaW( *s )) s++;
if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return FALSE; if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
time->wMonth = 0; time->wMonth = 0;
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
@ -2194,22 +2197,22 @@ BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD r
break; break;
} }
} }
if (time->wMonth == 0) return FALSE; if (time->wMonth == 0) return TRUE;
while (*s && !isdigitW( *s )) s++; while (*s && !isdigitW( *s )) s++;
if (*s == '\0') return FALSE; if (*s == '\0') return TRUE;
time->wYear = strtolW( s, &s, 10 ); time->wYear = strtolW( s, &s, 10 );
while (*s && !isdigitW( *s )) s++; while (*s && !isdigitW( *s )) s++;
if (*s == '\0') return FALSE; if (*s == '\0') return TRUE;
time->wHour = strtolW( s, &s, 10 ); time->wHour = strtolW( s, &s, 10 );
while (*s && !isdigitW( *s )) s++; while (*s && !isdigitW( *s )) s++;
if (*s == '\0') return FALSE; if (*s == '\0') return TRUE;
time->wMinute = strtolW( s, &s, 10 ); time->wMinute = strtolW( s, &s, 10 );
while (*s && !isdigitW( *s )) s++; while (*s && !isdigitW( *s )) s++;
if (*s == '\0') return FALSE; if (*s == '\0') return TRUE;
time->wSecond = strtolW( s, &s, 10 ); time->wSecond = strtolW( s, &s, 10 );
time->wMilliseconds = 0; time->wMilliseconds = 0;

View File

@ -427,6 +427,18 @@ static void InternetTimeToSystemTimeW_test()
'1','2',' ','0','6',' ','3','5',0 }; '1','2',' ','0','6',' ','3','5',0 };
static const WCHAR string3[] = { 'F','r',0 }; static const WCHAR string3[] = { 'F','r',0 };
ret = InternetTimeToSystemTimeW( NULL, NULL, 0 );
ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
ret = InternetTimeToSystemTimeW( NULL, &time, 0 );
ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
ret = InternetTimeToSystemTimeW( string, NULL, 0 );
ok( !ret, "InternetTimeToSystemTimeW succeeded (%ld)\n", GetLastError() );
ret = InternetTimeToSystemTimeW( string, &time, 1 );
ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
ret = InternetTimeToSystemTimeW( string, &time, 0 ); ret = InternetTimeToSystemTimeW( string, &time, 0 );
ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() ); ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
ok( !memcmp( &time, &expect, sizeof(expect) ), ok( !memcmp( &time, &expect, sizeof(expect) ),
@ -438,9 +450,7 @@ static void InternetTimeToSystemTimeW_test()
"InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() ); "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
ret = InternetTimeToSystemTimeW( string3, &time, 0 ); ret = InternetTimeToSystemTimeW( string3, &time, 0 );
todo_wine { ok( ret, "InternetTimeToSystemTimeW failed (%ld)\n", GetLastError() );
ok( ret, "InternetTimeToSystemTimeW succeeds on (%ld), string3='Fr'", GetLastError() );
}
} }
START_TEST(http) START_TEST(http)