diff options
author | Bill King <bking@trolltech.com> | 2009-09-09 03:36:02 (GMT) |
---|---|---|
committer | Bill King <bking@trolltech.com> | 2009-09-09 04:56:13 (GMT) |
commit | eb2509f76c7d61564c10bfe0f4044c46e08a8979 (patch) | |
tree | 2a7704f1c996d1776b64b3e19bf49c9b3adc707f /tests/auto/qsqlrecord | |
parent | b2daad6cce4298ba438aba4b0e8bb3ea80680c6e (diff) | |
download | Qt-eb2509f76c7d61564c10bfe0f4044c46e08a8979.zip Qt-eb2509f76c7d61564c10bfe0f4044c46e08a8979.tar.gz Qt-eb2509f76c7d61564c10bfe0f4044c46e08a8979.tar.bz2 |
Fixes missing autotest, also cleanup of code.
Diffstat (limited to 'tests/auto/qsqlrecord')
-rw-r--r-- | tests/auto/qsqlrecord/tst_qsqlrecord.cpp | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/tests/auto/qsqlrecord/tst_qsqlrecord.cpp b/tests/auto/qsqlrecord/tst_qsqlrecord.cpp index e712ac8..a9f8810 100644 --- a/tests/auto/qsqlrecord/tst_qsqlrecord.cpp +++ b/tests/auto/qsqlrecord/tst_qsqlrecord.cpp @@ -188,13 +188,35 @@ void tst_QSqlRecord::clear() QVERIFY( !rec->contains( fields[0]->name() ) ); } +void tst_QSqlRecord::clearValues_data() +{ + QTest::addColumn<QString>("prefix"); + QTest::addColumn<QString>("sep"); + QTest::addColumn<int>("ival"); + QTest::addColumn<QString>("sval"); + QTest::addColumn<double>("dval"); + QTest::addColumn<int>("bval"); + + QTest::newRow( "data0" ) << QString::fromLatin1("tablename") << QString::fromLatin1(",") << 10 + << QString::fromLatin1("Trond K.") << 2222.231234441 << 0; + QTest::newRow( "data1" ) << QString::fromLatin1("mytable") << QString::fromLatin1(".") << 12 + << QString::fromLatin1("Josten") << 544444444444423232.32334441 << 1; + QTest::newRow( "data2" ) << QString::fromLatin1("tabby") << QString::fromLatin1("-") << 12 + << QString::fromLatin1("Odvin") << 899129389283.32334441 << 1; + QTest::newRow( "data3" ) << QString::fromLatin1("per") << QString::fromLatin1("00") << 12 + << QString::fromLatin1("Brge") << 29382939182.99999919 << 0; +} + void tst_QSqlRecord::clearValues() { + int i; QFETCH( int, ival ); QFETCH( QString, sval ); QFETCH( double, dval ); QFETCH( int, bval ); - delete rec; + + if(rec) + delete rec; rec = new QSqlRecord(); rec->append( QSqlField( "string", QVariant::String ) ); @@ -220,6 +242,23 @@ void tst_QSqlRecord::clearValues() QCOMPARE( rec->position( "double" ), 2 ); QCOMPARE( rec->position( "bool" ), 3 ); #endif + for ( i = 0; i < 4; ++i ) + rec->setNull( i ); + + rec->setValue( 0, sval ); + rec->setValue( 1, ival ); + rec->setValue( 2, dval ); + rec->setValue( 3, QVariant(bval) ); + QVERIFY( rec->value( 0 ) == sval ); + QVERIFY( rec->value( 1 ) == ival ); + QVERIFY( rec->value( 2 ) == dval ); + QVERIFY( rec->value( 3 ) == QVariant(bval) ); + + rec->clearValues(); + + for ( i = 0; i < 4; ++i ) + QVERIFY( rec->isNull( i ) ); + } void tst_QSqlRecord::contains() @@ -432,6 +471,11 @@ void tst_QSqlRecord::setNull() isNull(); } +void tst_QSqlRecord::setValue_data() +{ + clearValues_data(); +} + void tst_QSqlRecord::setValue() { int i; @@ -500,6 +544,11 @@ void tst_QSqlRecord::setValue() } #ifdef QT3_SUPPORT +void tst_QSqlRecord::toString_data() +{ + clearValues_data( t ); +} + void tst_QSqlRecord::toString() { createTestRecord(); @@ -521,6 +570,11 @@ void tst_QSqlRecord::toString() QCOMPARE( rec->toString( prefix, sep ), result ); } +void tst_QSqlRecord::toStringList_data() +{ + clearValues_data( t ); +} + void tst_QSqlRecord::toStringList() { createTestRecord(); @@ -539,15 +593,6 @@ void tst_QSqlRecord::toStringList() QCOMPARE(rec->toStringList( prefix ), result); } -void tst_QSqlRecord::toString_data() -{ - clearValues_data( t ); -} - -void tst_QSqlRecord::toStringList_data() -{ - clearValues_data( t ); -} #endif // QT3_SUPPORT void tst_QSqlRecord::value() @@ -559,29 +604,5 @@ void tst_QSqlRecord::value() QVERIFY( rec2.value( "string" ) == "Harry" ); } -void tst_QSqlRecord::setValue_data() -{ - clearValues_data(); -} - -void tst_QSqlRecord::clearValues_data() -{ - QTest::addColumn<QString>("prefix"); - QTest::addColumn<QString>("sep"); - QTest::addColumn<int>("ival"); - QTest::addColumn<QString>("sval"); - QTest::addColumn<double>("dval"); - QTest::addColumn<int>("bval"); - - QTest::newRow( "data0" ) << QString::fromLatin1("tablename") << QString::fromLatin1(",") << 10 - << QString::fromLatin1("Trond K.") << 2222.231234441 << 0; - QTest::newRow( "data1" ) << QString::fromLatin1("mytable") << QString::fromLatin1(".") << 12 - << QString::fromLatin1("Josten") << 544444444444423232.32334441 << 1; - QTest::newRow( "data2" ) << QString::fromLatin1("tabby") << QString::fromLatin1("-") << 12 - << QString::fromLatin1("Odvin") << 899129389283.32334441 << 1; - QTest::newRow( "data3" ) << QString::fromLatin1("per") << QString::fromLatin1("00") << 12 - << QString::fromLatin1("Brge") << 29382939182.99999919 << 0; -} - QTEST_MAIN(tst_QSqlRecord) #include "tst_qsqlrecord.moc" |