[PATCH] Add some tests for the last error returned

Paul Vriens Paul.Vriens.Wine at gmail.com
Thu Mar 27 06:17:35 CDT 2008


---
 dlls/setupapi/tests/parser.c |  119 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 119 insertions(+), 0 deletions(-)

diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 1c3ca49..86f987b 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -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;
+    int 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 );
 }
-- 
1.5.4.1


--------------000408070101090105010906--



More information about the wine-patches mailing list