From 1a159dfddc90fb5a734f58014ef5600dc1f3d78d Mon Sep 17 00:00:00 2001 From: Matijn Woudt Date: Thu, 3 Jun 2010 15:21:31 +0200 Subject: [PATCH] msi/tests: Testcases for CREATE TABLE. --- dlls/msi/tests/db.c | 107 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 5571a71e4fc..56fa0f08e68 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -8845,6 +8845,112 @@ static void test_columnorder(void) DeleteFileA(msifile); } +static void test_createtable(void) +{ + MSIHANDLE hdb, htab = 0, hrec = 0; + LPCSTR query; + UINT res; + DWORD size; + char buffer[0x20]; + + hdb = create_db(); + ok(hdb, "failed to create db\n"); + + query = "CREATE TABLE `blah` (`foo` CHAR(72) NOT NULL PRIMARY KEY `foo`)"; + res = MsiDatabaseOpenView( hdb, query, &htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + if(res == ERROR_SUCCESS ) + { + res = MsiViewExecute( htab, hrec ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec ); + todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + size = sizeof(buffer); + res = MsiRecordGetString(hrec, 1, buffer, &size ); + todo_wine ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewClose( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + } + + query = "CREATE TABLE `a` (`b` INT PRIMARY KEY `b`)"; + res = MsiDatabaseOpenView( hdb, query, &htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + if(res == ERROR_SUCCESS ) + { + res = MsiViewExecute( htab, 0 ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewClose( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + query = "SELECT * FROM `a`"; + res = MsiDatabaseOpenView( hdb, query, &htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + size = sizeof(buffer); + res = MsiRecordGetString(hrec, 1, buffer, &size ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + ok(!strcmp(buffer,"b"), "b != %s\n", buffer); + + res = MsiViewClose( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiDatabaseCommit(hdb); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle(hdb); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiOpenDatabase(msifile, MSIDBOPEN_TRANSACT, &hdb ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + query = "SELECT * FROM `a`"; + res = MsiDatabaseOpenView( hdb, query, &htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewGetColumnInfo( htab, MSICOLINFO_NAMES, &hrec ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + size = sizeof(buffer); + res = MsiRecordGetString(hrec, 1, buffer, &size ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + todo_wine ok(!strcmp(buffer,"b"), "b != %s\n", buffer); + + res = MsiCloseHandle( hrec ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiViewClose( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle( htab ); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + } + + res = MsiDatabaseCommit(hdb); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + res = MsiCloseHandle(hdb); + ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); + + DeleteFileA(msifile); +} + + START_TEST(db) { test_msidatabase(); @@ -8896,4 +9002,5 @@ START_TEST(db) test_insertorder(); test_columnorder(); test_suminfo_import(); + test_createtable(); }