From b2b149a09ecd408b661991c1cdbcaceafe97ab6a Mon Sep 17 00:00:00 2001 From: winesync Date: Sat, 12 Mar 2022 15:11:56 +0100 Subject: [PATCH] [WINESYNC] msi/tests: Add tests for MsiDatabaseGetPrimaryKeys(). Signed-off-by: Zebediah Figura Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard wine commit id 3a1d9bb915952fd69f16c32cbea29983d9a5a5fc by Zebediah Figura --- modules/rostests/winetests/msi/db.c | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/modules/rostests/winetests/msi/db.c b/modules/rostests/winetests/msi/db.c index 3cbb9b3e284..e2328ab784a 100644 --- a/modules/rostests/winetests/msi/db.c +++ b/modules/rostests/winetests/msi/db.c @@ -9701,6 +9701,46 @@ static void test_select_column_names(void) ok(r == ERROR_SUCCESS , "failed to close database: %u\n", r); } +static void test_primary_keys(void) +{ + MSIHANDLE hdb, keys; + UINT r; + + hdb = create_db(); + + r = MsiDatabaseGetPrimaryKeysA(hdb, "T", &keys); + ok(r == ERROR_INVALID_TABLE, "got %u\n", r); + + r = run_query(hdb, 0, "CREATE TABLE `T` (`A` SHORT, `B` SHORT, `C` SHORT PRIMARY KEY `A`)"); + ok(!r, "got %u\n", r); + + r = MsiDatabaseGetPrimaryKeysA(hdb, "T", &keys); + ok(!r, "got %u\n", r); + + r = MsiRecordGetFieldCount(keys); + ok(r == 1, "got %d\n", r); + ok(check_record(keys, 0, "T"), "expected 'T'"); + ok(check_record(keys, 1, "A"), "expected 'A'"); + + MsiCloseHandle(keys); + + r = run_query(hdb, 0, "CREATE TABLE `U` (`A` SHORT, `B` SHORT, `C` SHORT PRIMARY KEY `B`, `C`)"); + ok(!r, "got %u\n", r); + + r = MsiDatabaseGetPrimaryKeysA(hdb, "U", &keys); + ok(!r, "got %u\n", r); + + r = MsiRecordGetFieldCount(keys); + ok(r == 2, "got %d\n", r); + ok(check_record(keys, 0, "U"), "expected 'U'"); + ok(check_record(keys, 1, "B"), "expected 'B'"); + ok(check_record(keys, 2, "C"), "expected 'C'"); + + MsiCloseHandle(keys); + MsiCloseHandle(hdb); + DeleteFileA(msifile); +} + START_TEST(db) { test_msidatabase(); @@ -9756,4 +9796,5 @@ START_TEST(db) test_collation(); test_embedded_nulls(); test_select_column_names(); + test_primary_keys(); }