From ced6ba7eee785caa7ba89d50f1a02f7f3994c839 Mon Sep 17 00:00:00 2001 From: Derick Hawcroft Date: Mon, 15 Jun 2009 16:29:38 +1000 Subject: unit test for task 229811 --- tests/auto/qsqlquery/tst_qsqlquery.cpp | 62 ++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 7f97972..ab0c43c 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -177,6 +177,9 @@ private slots: #ifdef NOT_READY_YET void task_217003_data() { generic_data(); } void task_217003(); + + void task_229811(); + void task_229811_data() { generic_data(); } #endif void task_250026_data() { generic_data("QODBC"); } void task_250026(); @@ -184,7 +187,6 @@ private slots: void task_205701(); - private: // returns all database connections void generic_data(const QString &engine=QString()); @@ -2715,12 +2717,12 @@ void tst_QSqlQuery::task_250026() void tst_QSqlQuery::task_205701() { - QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); - qsdb.setHostName("test"); - qsdb.setDatabaseName("test"); - qsdb.setUserName("test"); - qsdb.setPassword("test"); - qsdb.open(); + QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest"); + qsdb.setHostName("test"); + qsdb.setDatabaseName("test"); + qsdb.setUserName("test"); + qsdb.setPassword("test"); + qsdb.open(); // { QSqlQuery query(qsdb); @@ -2728,6 +2730,52 @@ void tst_QSqlQuery::task_205701() QSqlDatabase::removeDatabase("atest"); } +#ifdef NOT_READY_YET +// For task: 229811 +void tst_QSqlQuery::task_229811() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + + if (!db.driverName().startsWith( "QODBC" )) return; + + QSqlQuery q( db ); + + QString tableName = qTableName( "task_229811" ); + + if ( !q.exec( "CREATE TABLE " + tableName + " (Word varchar(20))" ) ) { + qDebug() << "Warning" << q.lastError(); + } + + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Albert')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Beehive')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Alimony')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('Bohemian')" ) ); + QVERIFY_SQL( q, exec( "INSERT INTO " + tableName + " values ('AllStars')" ) ); + + + QString stmt = "SELECT * FROM " + tableName + " WHERE Word LIKE :name"; + QVERIFY_SQL(q,prepare(stmt)); + q.bindValue(":name", "A%"); + QVERIFY_SQL(q,exec()); + + QVERIFY(q.isActive()); + QVERIFY(q.isSelect()); + QVERIFY(q.first()); + + QSqlRecord rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Albert")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(), QString("Alimony")); + QVERIFY(q.next()); + rec = q.record(); + QCOMPARE(rec.field(0).value().toString(),QString("AllStars")); + + q.exec("DROP TABLE " + tableName ); +} +#endif QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" -- cgit v0.12