setupapi/tests: Add some tests for the last error returned.
This commit is contained in:
parent
f8ea9ec163
commit
18e305241d
|
@ -480,6 +480,124 @@ static void test_pSetupGetField(void)
|
||||||
SetupCloseInfFile( hinf );
|
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)
|
START_TEST(parser)
|
||||||
{
|
{
|
||||||
init_function_pointers();
|
init_function_pointers();
|
||||||
|
@ -488,5 +606,6 @@ START_TEST(parser)
|
||||||
test_key_names();
|
test_key_names();
|
||||||
test_close_inf_file();
|
test_close_inf_file();
|
||||||
test_pSetupGetField();
|
test_pSetupGetField();
|
||||||
|
test_GLE();
|
||||||
DeleteFileA( tmpfilename );
|
DeleteFileA( tmpfilename );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue