Commit d0e9fbf6 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

wininet/tests: Add more tests for InternetTimeToSystemTime().

parent 2a863f40
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "winineti.h" #include "winineti.h"
#include "winerror.h" #include "winerror.h"
#include "winreg.h" #include "winreg.h"
#include "winnls.h"
#include "wine/test.h" #include "wine/test.h"
...@@ -896,60 +897,73 @@ static void InternetTimeFromSystemTimeW_test(void) ...@@ -896,60 +897,73 @@ static void InternetTimeFromSystemTimeW_test(void)
error ); error );
} }
static void InternetTimeToSystemTimeA_test(void) static void test_InternetTimeToSystemTime(void)
{ {
BOOL ret; BOOL ret;
unsigned int i;
SYSTEMTIME time; SYSTEMTIME time;
static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 }; WCHAR buffer[64];
static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT"; static const SYSTEMTIME expect1 = { 2005, 1, 5, 7, 12, 6, 35, 0 };
static const char string2[] = " fri 7 jan 2005 12 06 35"; static const SYSTEMTIME expect2 = { 2022, 1, 2, 11, 11, 13, 5, 0 };
ret = pInternetTimeToSystemTimeA( string, &time, 0 );
ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
ok( !memcmp( &time, &expect, sizeof(expect) ),
"InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
ok( !memcmp( &time, &expect, sizeof(expect) ),
"InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
}
static void InternetTimeToSystemTimeW_test(void)
{
BOOL ret;
SYSTEMTIME time;
static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
'1','2',':','0','6',':','3','5',' ','G','M','T',0 };
static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
'1','2',' ','0','6',' ','3','5',0 };
static const WCHAR string3[] = { 'F','r',0 };
ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
ret = pInternetTimeToSystemTimeW( string, NULL, 0 ); static const struct test_data
ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() ); {
const char *string;
ret = pInternetTimeToSystemTimeW( string, &time, 0 ); const SYSTEMTIME *expect;
ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); BOOL match;
BOOL todo;
ret = pInternetTimeToSystemTimeW( string, &time, 0 ); }
ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); test_data[] =
ok( !memcmp( &time, &expect, sizeof(expect) ), {
"InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); { "Fri, 07 Jan 2005 12:06:35 GMT", &expect1, TRUE },
{ " fri, 7 jan 2005 12 06 35", &expect1, TRUE },
{ "Fri, 07-01-2005 12:06:35", &expect1, TRUE, TRUE },
{ "5, 07-01-2005 12:06:35 GMT", &expect1, TRUE, TRUE },
{ "5, 07-01-2005 12:06:35 GMT;", &expect1, TRUE, TRUE },
{ "5, 07-01-2005 12:06:35 GMT123", &expect1, TRUE, TRUE },
{ "2, 11 01 2022 11 13 05", &expect2, TRUE, TRUE },
{ "2, 11-01-2022 11#13^05", &expect2, TRUE, TRUE },
{ "2, 11*01/2022 11+13=05", &expect2, TRUE, TRUE },
{ "2, 11-Jan-2022 11:13:05", &expect2, TRUE, TRUE },
{ "Fr", NULL, FALSE },
};
ret = pInternetTimeToSystemTimeW( string2, &time, 0 ); ret = pInternetTimeToSystemTimeA(NULL, NULL, 0);
ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); ok(!ret, "InternetTimeToSystemTimeA succeeded.\n");
ok( !memcmp( &time, &expect, sizeof(expect) ), ret = pInternetTimeToSystemTimeA(NULL, &time, 0);
"InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); ok(!ret, "InternetTimeToSystemTimeA succeeded.\n");
ret = pInternetTimeToSystemTimeW(NULL, NULL, 0);
ok(!ret, "InternetTimeToSystemTimeW succeeded.\n");
ret = pInternetTimeToSystemTimeW(NULL, &time, 0);
ok(!ret, "InternetTimeToSystemTimeW succeeded.\n");
ret = pInternetTimeToSystemTimeW( string3, &time, 0 ); for (i = 0; i < ARRAY_SIZE(test_data); ++i)
ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() ); {
const struct test_data *test = &test_data[i];
winetest_push_context("Test %u", i);
memset(&time, 0, sizeof(time));
ret = pInternetTimeToSystemTimeA(test->string, NULL, 0);
ok(!ret, "InternetTimeToSystemTimeA succeeded.\n");
ret = pInternetTimeToSystemTimeA(test->string, &time, 0);
ok(ret, "InternetTimeToSystemTimeA failed: %u.\n", GetLastError());
todo_wine_if(test->todo)
ok(!test->match || !memcmp(&time, test->expect, sizeof(*test->expect)),
"Got unexpected system time.\n");
MultiByteToWideChar(CP_ACP, 0, test->string, -1, buffer, ARRAY_SIZE(buffer));
memset(&time, 0, sizeof(time));
ret = pInternetTimeToSystemTimeW(buffer, NULL, 0);
ok(!ret, "InternetTimeToSystemTimeW succeeded.\n");
ret = pInternetTimeToSystemTimeW(buffer, &time, 0);
ok(ret, "InternetTimeToSystemTimeW failed: %u.\n", GetLastError());
todo_wine_if(test->todo)
ok(!test->match || !memcmp(&time, test->expect, sizeof(*test->expect)),
"Got unexpected system time.\n");
winetest_pop_context();
}
} }
static void test_IsDomainLegalCookieDomainW(void) static void test_IsDomainLegalCookieDomainW(void)
...@@ -1922,8 +1936,7 @@ START_TEST(internet) ...@@ -1922,8 +1936,7 @@ START_TEST(internet)
{ {
InternetTimeFromSystemTimeA_test(); InternetTimeFromSystemTimeA_test();
InternetTimeFromSystemTimeW_test(); InternetTimeFromSystemTimeW_test();
InternetTimeToSystemTimeA_test(); test_InternetTimeToSystemTime();
InternetTimeToSystemTimeW_test();
} }
if (pIsDomainLegalCookieDomainW && if (pIsDomainLegalCookieDomainW &&
((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA || ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment