Commit 18e30524 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

setupapi/tests: Add some tests for the last error returned.

parent f8ea9ec1
......@@ -480,6 +480,124 @@ static void test_pSetupGetField(void)
SetupCloseInfFile( hinf );
}
static void test_GLE(void)
{
static const char *inf =
"[Version]\n"
"Signature=\"$Windows NT$\"\n"
"[Sectionname]\n"
"Keyname1=Field1,Field2,Field3\n"
"\n"
"Keyname2=Field4,Field5\n";
HINF hinf;
UINT err;
INFCONTEXT context;
BOOL retb;
LONG retl;
char buf[MAX_INF_STRING_LENGTH];
int bufsize = MAX_INF_STRING_LENGTH;
DWORD retsize;
hinf = test_file_contents( inf, &err );
ok( hinf != NULL, "Expected valid INF file\n" );
SetLastError(0xdeadbeef);
retb = SetupFindFirstLineA( hinf, "ImNotThere", NULL, &context );
ok(!retb, "Expected failure\n");
todo_wine
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindFirstLineA( hinf, "ImNotThere", "ImNotThere", &context );
ok(!retb, "Expected failure\n");
todo_wine
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindFirstLineA( hinf, "Sectionname", NULL, &context );
ok(retb, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindFirstLineA( hinf, "Sectionname", "ImNotThere", &context );
ok(!retb, "Expected failure\n");
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindFirstLineA( hinf, "Sectionname", "Keyname1", &context );
ok(retb, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindNextMatchLineA( &context, "ImNotThere", &context );
ok(!retb, "Expected failure\n");
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupFindNextMatchLineA( &context, "Keyname2", &context );
ok(retb, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retl = SetupGetLineCountA( hinf, "ImNotThere");
ok(retl == -1, "Expected -1, got %d\n", retl);
ok(GetLastError() == ERROR_SECTION_NOT_FOUND,
"Expected ERROR_SECTION_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retl = SetupGetLineCountA( hinf, "Sectionname");
ok(retl == 2, "Expected 2, got %d\n", retl);
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineTextA( NULL, hinf, "ImNotThere", "ImNotThere", buf, bufsize, &retsize);
ok(!retb, "Expected failure\n");
todo_wine
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineTextA( NULL, hinf, "Sectionname", "ImNotThere", buf, bufsize, &retsize);
ok(!retb, "Expected failure\n");
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineTextA( NULL, hinf, "Sectionname", "Keyname1", buf, bufsize, &retsize);
ok(retb, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineByIndexA( hinf, "ImNotThere", 1, &context );
ok(!retb, "Expected failure\n");
todo_wine
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineByIndexA( hinf, "Sectionname", 1, &context );
ok(retb, "Expected success\n");
ok(GetLastError() == ERROR_SUCCESS,
"Expected ERROR_SUCCESS, got %08x\n", GetLastError());
SetLastError(0xdeadbeef);
retb = SetupGetLineByIndexA( hinf, "Sectionname", 3, &context );
ok(!retb, "Expected failure\n");
ok(GetLastError() == ERROR_LINE_NOT_FOUND,
"Expected ERROR_LINE_NOT_FOUND, got %08x\n", GetLastError());
SetupCloseInfFile( hinf );
}
START_TEST(parser)
{
init_function_pointers();
......@@ -488,5 +606,6 @@ START_TEST(parser)
test_key_names();
test_close_inf_file();
test_pSetupGetField();
test_GLE();
DeleteFileA( tmpfilename );
}
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