msi: Add tests for using single quotes in an INSERT query.

This commit is contained in:
James Hawkins 2008-02-04 11:26:58 -06:00 committed by Alexandre Julliard
parent 972c61d311
commit 56574c7c6e
1 changed files with 129 additions and 0 deletions

View File

@ -5053,6 +5053,134 @@ static void test_deleterow()
DeleteFileA(msifile); DeleteFileA(msifile);
} }
static const CHAR import_dat[] = "A\n"
"s72\n"
"Table\tA\n"
"This is a new 'string' ok\n";
static void test_quotes(void)
{
MSIHANDLE hdb, hview, hrec;
const char *query;
char buf[MAX_PATH];
UINT r;
DWORD size;
DeleteFile(msifile);
r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "CREATE TABLE `Table` ( `A` CHAR(72) NOT NULL PRIMARY KEY `A` )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a 'string' ok' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( \"This is a 'string' ok\" )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( \"test\" )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX,
"Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a ''string'' ok' )";
r = run_query(hdb, 0, query);
todo_wine
{
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
}
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a '''string''' ok' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a \'string\' ok' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
query = "INSERT INTO `Table` ( `A` ) VALUES ( 'This is a \"string\" ok' )";
r = run_query(hdb, 0, query);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
query = "SELECT * FROM `Table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
size = MAX_PATH;
r = MsiRecordGetString(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmp(buf, "This is a \"string\" ok"),
"Expected \"This is a \"string\" ok\", got %s\n", buf);
}
MsiCloseHandle(hrec);
r = MsiViewFetch(hview, &hrec);
todo_wine
{
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
}
MsiCloseHandle(hview);
write_file("import.idt", import_dat, (sizeof(import_dat) - 1) * sizeof(char));
r = MsiDatabaseImportA(hdb, CURR_DIR, "import.idt");
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
}
DeleteFileA("import.idt");
query = "SELECT * FROM `Table`";
r = MsiDatabaseOpenView(hdb, query, &hview);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewExecute(hview, 0);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
r = MsiViewFetch(hview, &hrec);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
size = MAX_PATH;
r = MsiRecordGetString(hrec, 1, buf, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmp(buf, "This is a new 'string' ok"),
"Expected \"This is a new 'string' ok\", got %s\n", buf);
}
MsiCloseHandle(hrec);
r = MsiViewFetch(hview, &hrec);
todo_wine
{
ok(r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %d\n", r);
}
MsiCloseHandle(hview);
MsiCloseHandle(hdb);
DeleteFileA(msifile);
}
START_TEST(db) START_TEST(db)
{ {
test_msidatabase(); test_msidatabase();
@ -5084,4 +5212,5 @@ START_TEST(db)
test_order(); test_order();
test_viewmodify_delete_temporary(); test_viewmodify_delete_temporary();
test_deleterow(); test_deleterow();
test_quotes();
} }