diff options
author | kh1 <karsten.heimrich@digia.com> | 2013-05-27 15:41:15 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@digia.com> | 2013-05-28 11:58:16 +0200 |
commit | a29a95a606047f7b8111a89f06da7dd1e41cdb5a (patch) | |
tree | 966e6f1a36af0b000aa86770436482a5b555598a /src | |
parent | 82d7347ab9da7ea7e7575d2816bcdd6e7854f6cc (diff) |
Remove superfluous unit tests.
Change-Id: I4a792c50b2dcf438d41fa1ffef9d01be8227bc40
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Reviewed-by: Niels Weber <niels.weber@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/kdtools/kdgenericfactory.cpp | 95 | ||||
-rw-r--r-- | src/libs/kdtools/kdlockfile.cpp | 34 | ||||
-rw-r--r-- | src/libs/kdtools/kdsavefile.cpp | 70 |
3 files changed, 0 insertions, 199 deletions
diff --git a/src/libs/kdtools/kdgenericfactory.cpp b/src/libs/kdtools/kdgenericfactory.cpp index 9352f83cd..df419c1f4 100644 --- a/src/libs/kdtools/kdgenericfactory.cpp +++ b/src/libs/kdtools/kdgenericfactory.cpp @@ -153,98 +153,3 @@ type T, identified by \a name. When a product is registered via this method, it will be created by calling create(). */ - -#ifdef KDTOOLSCORE_UNITTESTS - -#include <KDUnitTest/test.h> - -#include <QStringList> -#include <QMap> - -class Fruit -{ -public: - virtual ~Fruit() {} -}; - -class Apple : public Fruit -{ -}; - -class Pear : public Fruit -{ -}; - -std::ostream& operator<<( std::ostream& stream, const QStringList& list ) -{ - stream << "QStringList("; - for( QStringList::const_iterator it = list.begin(); it != list.end(); ++it ) - { - stream << " " << it->toLocal8Bit().data(); - if( it + 1 != list.end() ) - stream << ","; - } - stream << " )"; - return stream; -} - -class KDGenericFactoryTest : public KDUnitTest::Test { -public: - KDGenericFactoryTest() : Test( "KDGenericFactory" ) {} - void run() { - doRun<QHash>(); - doRun<QMap>(); - } - - template <template <typename U, typename V> class T_Map> - void doRun(); -}; - -KDAB_EXPORT_UNITTEST( KDGenericFactoryTest, "kdcoretools" ) - -template <template <typename U, typename V> class T_Map> -void KDGenericFactoryTest::doRun() { - - { - KDGenericFactory< Fruit, QString, T_Map > fruitPlantation; - assertEqual( fruitPlantation.productCount(), 0U ); - assertEqual( fruitPlantation.availableProducts(), QStringList() ); - - fruitPlantation.template registerProduct< Apple >( QLatin1String( "Apple" ) ); - assertEqual( fruitPlantation.productCount(), 1U ); - assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Apple" ) ) ); - - fruitPlantation.template registerProduct< Pear >( QLatin1String( "Pear" ) ); - assertEqual( fruitPlantation.productCount(), 2U ); - - Fruit* fruit = 0; - fruit = fruitPlantation.create( QLatin1String( "Apple" ) ); - assertNotNull( fruit ); - assertNotNull( dynamic_cast< Apple* >( fruit ) ); - - fruit = fruitPlantation.create( QLatin1String( "Pear" ) ); - assertNotNull( fruit ); - assertNotNull( dynamic_cast< Pear* >( fruit ) ); - - fruit = fruitPlantation.create( QLatin1String( "Cherry" ) ); - assertNull( fruit ); - - fruitPlantation.unregisterProduct( QLatin1String( "Apple" ) ); - assertEqual( fruitPlantation.productCount(), 1U ); - assertEqual( fruitPlantation.availableProducts(), QStringList( QLatin1String( "Pear" ) ) ); - fruit = fruitPlantation.create( QLatin1String( "Apple" ) ); - assertNull( fruit ); - - fruit = fruitPlantation.create( QLatin1String( "Pear" ) ); - assertNotNull( fruit ); - assertNotNull( dynamic_cast< Pear* >( fruit ) ); - - - fruitPlantation.unregisterProduct( QLatin1String( "Pear" ) ); - assertEqual( fruitPlantation.productCount(), 0U ); - fruit = fruitPlantation.create( QLatin1String( "Pear" ) ); - assertNull( fruit ); - } - -} -#endif // KDTOOLSCORE_UNITTESTS diff --git a/src/libs/kdtools/kdlockfile.cpp b/src/libs/kdtools/kdlockfile.cpp index 3a440b6b0..0b1853e99 100644 --- a/src/libs/kdtools/kdlockfile.cpp +++ b/src/libs/kdtools/kdlockfile.cpp @@ -55,37 +55,3 @@ bool KDLockFile::unlock() { return d->unlock(); } - - -#ifdef KDTOOLSCORE_UNITTESTS - -#include <KDUnitTest/Test> -#include <QDebug> -#include <QDir> - -KDAB_UNITTEST_SIMPLE( KDLockFile, "kdcoretools" ) { - { - KDLockFile f( QLatin1String("/jlksdfdsfjkldsf-doesnotexist/file") ); - const bool locked = f.lock(); - assertFalse( locked ); - qDebug() << f.errorString(); - assertTrue( !f.errorString().isEmpty() ); - if ( !locked ) - assertTrue( f.unlock() ); - } - { - KDLockFile f( QDir::currentPath() + QLatin1String("/kdlockfile-test") ); - const bool locked = f.lock(); - assertTrue( locked ); - if ( !locked ) - qDebug() << f.errorString(); - assertEqual( locked, f.errorString().isEmpty() ); - const bool unlocked = f.unlock(); - assertTrue( unlocked ); - if ( !unlocked ) - qDebug() << f.errorString(); - assertEqual( unlocked, f.errorString().isEmpty() ); - } -} - -#endif // KDTOOLSCORE_UNITTESTS diff --git a/src/libs/kdtools/kdsavefile.cpp b/src/libs/kdtools/kdsavefile.cpp index 849eef393..450f29e83 100644 --- a/src/libs/kdtools/kdsavefile.cpp +++ b/src/libs/kdtools/kdsavefile.cpp @@ -458,73 +458,3 @@ QString KDSaveFile::backupExtension() const { return d->backupExtension; } - -/** - * TODO - * - * - */ - -#ifdef KDTOOLSCORE_UNITTESTS - -#include <KDUnitTest/Test> - -KDAB_UNITTEST_SIMPLE( KDSaveFile, "kdcoretools" ) { - //TODO test contents (needs blocking and checked write() ) - { - const QString testfile1 = QLatin1String("kdsavefile-test1"); - QByteArray testData("lalalala"); - KDSaveFile saveFile( testfile1 ); - assertTrue( saveFile.open( QIODevice::WriteOnly ) ); - saveFile.write( testData.constData(), testData.size() ); - assertTrue( saveFile.commit() ); - assertTrue( QFile::exists( testfile1 ) ); - assertTrue( QFile::remove( testfile1 ) ); - } - { - const QString testfile1 = QLatin1String("kdsavefile-test1"); - QByteArray testData("lalalala"); - KDSaveFile saveFile( testfile1 ); - assertTrue( saveFile.open( QIODevice::WriteOnly ) ); - saveFile.write( testData.constData(), testData.size() ); - saveFile.close(); - assertFalse( QFile::exists( testfile1 ) ); - } - { - const QString testfile1 = QLatin1String("kdsavefile-test1"); - QByteArray testData("lalalala"); - KDSaveFile saveFile( testfile1 ); - assertTrue( saveFile.open( QIODevice::WriteOnly ) ); - saveFile.write( testData.constData(), testData.size() ); - assertTrue( saveFile.commit() ); - assertTrue( QFile::exists( testfile1 ) ); - - KDSaveFile sf2( testfile1 ); - sf2.setBackupExtension( QLatin1String(".bak") ); - assertTrue( sf2.open( QIODevice::WriteOnly ) ); - sf2.write( testData.constData(), testData.size() ); - sf2.commit(); //commit in backup mode (default) - const QString backup = testfile1 + sf2.backupExtension(); - assertTrue( QFile::exists( backup ) ); - assertTrue( QFile::remove( backup ) ); - - KDSaveFile sf3( testfile1 ); - sf3.setBackupExtension( QLatin1String(".bak") ); - assertTrue( sf3.open( QIODevice::WriteOnly ) ); - sf3.write( testData.constData(), testData.size() ); - sf3.commit( KDSaveFile::OverwriteExistingFile ); - const QString backup2 = testfile1 + sf3.backupExtension(); - assertFalse( QFile::exists( backup2 ) ); - - assertTrue( QFile::remove( testfile1 ) ); - } - { - const QString testfile1 = QLatin1String("kdsavefile-test1"); - KDSaveFile sf( testfile1 ); - assertFalse( sf.open( QIODevice::ReadOnly ) ); - assertFalse( sf.open( QIODevice::WriteOnly|QIODevice::Append ) ); - assertTrue( sf.open( QIODevice::ReadWrite ) ); - } -} - -#endif // KDTOOLSCORE_UNITTESTS |