kernel32: Test GetPrivateProfileString with empty string as key and section.

This commit is contained in:
Stefan Leichter 2009-08-21 13:03:37 +02:00 committed by Alexandre Julliard
parent 9c0a3eab97
commit 88a019956e
1 changed files with 30 additions and 0 deletions

View File

@ -92,14 +92,23 @@ static void test_profile_int(void)
static void test_profile_string(void)
{
static WCHAR emptyW[] = { 0 };
static WCHAR keyW[] = { 'k','e','y',0 };
static WCHAR sW[] = { 's',0 };
static WCHAR TESTFILE2W[] = {'.','\\','t','e','s','t','w','i','n','e','2','.','i','n','i',0};
static WCHAR valsectionW[] = {'v','a','l','_','e','_','s','e','c','t','i','o','n',0 };
static WCHAR valnokeyW[] = {'v','a','l','_','n','o','_','k','e','y',0};
HANDLE h;
int ret;
DWORD count;
char buf[100];
WCHAR bufW[100];
char *p;
/* test that lines without an '=' will not be enumerated */
/* in the case below, name2 is a key while name3 is not. */
char content[]="[s]\r\nname1=val1\r\nname2=\r\nname3\r\nname4=val4\r\n";
char content2[]="\r\nkey=val_no_section\r\n[]\r\nkey=val_e_section\r\n"
"[s]\r\n=val_no_key\r\n[t]\r\n";
DeleteFileA( TESTFILE2);
h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
@ -126,6 +135,27 @@ static void test_profile_string(void)
ok( ret == 24 && !strcmp( buf, "name1,name2,name4,name5"), "wrong keys returned(%d): %s\n",
ret, buf);
h = CreateFileA( TESTFILE2, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
ok( h != INVALID_HANDLE_VALUE, " cannot create %s\n", TESTFILE2);
if( h == INVALID_HANDLE_VALUE) return;
WriteFile( h, content2, sizeof(content2), &count, NULL);
CloseHandle( h);
/* works only in unicode, ascii crashes */
ret=GetPrivateProfileStringW(emptyW, keyW, emptyW, bufW,
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine
ok(!lstrcmpW(valsectionW,bufW), "expected %s, got %s\n",
wine_dbgstr_w(valsectionW), wine_dbgstr_w(bufW) );
/* works only in unicode, ascii crashes */
ret=GetPrivateProfileStringW(sW, emptyW, emptyW, bufW,
sizeof(bufW)/sizeof(bufW[0]), TESTFILE2W);
todo_wine
ok(!lstrcmpW(valnokeyW,bufW), "expected %s, got %s\n",
wine_dbgstr_w(valnokeyW), wine_dbgstr_w(bufW) );
DeleteFileA( TESTFILE2);
}