From ffe8a83e053396df448e9413828527613ca3bd46 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:46:43 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1157647 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kunittest/module.h | 12 +++---- kunittest/runner.cpp | 56 ++++++++++++++++---------------- kunittest/runner.h | 20 ++++++------ kunittest/tester.cpp | 20 ++++++------ kunittest/tester.h | 92 ++++++++++++++++++++++++++-------------------------- 5 files changed, 100 insertions(+), 100 deletions(-) (limited to 'kunittest') diff --git a/kunittest/module.h b/kunittest/module.h index e33887101..7f4b24789 100644 --- a/kunittest/module.h +++ b/kunittest/module.h @@ -31,7 +31,7 @@ #ifndef KUNITTEST_MODULE_H #define KUNITTEST_MODULE_H -#include +#include #include #include @@ -48,8 +48,8 @@ namespace KUnitTest * @code KUNITTEST_MODULE(kunittest_samplemodule,"TestSuite") @endcode */ #define KUNITTEST_MODULE(library,suite) \ - static const QString s_kunittest_suite = QString::fromLatin1(suite); \ - class library##Module : public QObject \ + static const TQString s_kunittest_suite = TQString::fromLatin1(suite); \ + class library##Module : public TQObject \ { \ public: \ library##Module() \ @@ -72,7 +72,7 @@ namespace KUnitTest class module##Factory : public KLibFactory \ { \ public: \ - QObject *createObject (QObject *, const char *, const char *, const QStringList &) \ + TQObject *createObject (TQObject *, const char *, const char *, const TQStringList &) \ { \ return new library##Module(); \ }; \ @@ -93,7 +93,7 @@ namespace KUnitTest tester##ModuleAutoregister() \ { \ KUnitTest::Tester *test = new tester(); \ - QString name = s_kunittest_suite + QString::fromLatin1("::") + QString::fromLocal8Bit(#tester); \ + TQString name = s_kunittest_suite + TQString::fromLatin1("::") + TQString::fromLocal8Bit(#tester); \ test->setName(name.local8Bit()); \ kunittest_registerModuleTester(name.local8Bit(), test ); \ } \ @@ -110,7 +110,7 @@ namespace KUnitTest public: \ tester##ModuleAutoregister() \ { \ - QString fullName = s_kunittest_suite + QString("::") + QString::fromLocal8Bit(name); \ + TQString fullName = s_kunittest_suite + TQString("::") + TQString::fromLocal8Bit(name); \ KUnitTest::Tester *test = new tester(fullName.local8Bit()); \ kunittest_registerModuleTester(fullName.local8Bit(), test); \ } \ diff --git a/kunittest/runner.cpp b/kunittest/runner.cpp index 776e01cda..580d451b8 100644 --- a/kunittest/runner.cpp +++ b/kunittest/runner.cpp @@ -29,9 +29,9 @@ #include using namespace std; -#include -#include -#include +#include +#include +#include #include #include @@ -51,10 +51,10 @@ namespace KUnitTest Runner::self()->m_registry.insert(name, test); } - void Runner::loadModules(const QString &folder, const QString &query) + void Runner::loadModules(const TQString &folder, const TQString &query) { - QRegExp reQuery(query); - QDir dir(folder, "kunittest_*.la"); + TQRegExp reQuery(query); + TQDir dir(folder, "kunittest_*.la"); // Add the folder to the "module" resource such that the KLibLoader can // find the modules in this folder. @@ -62,11 +62,11 @@ namespace KUnitTest kdDebug() << "Looking in folder: " << dir.absPath() << endl; // Get a list of all modules. - QStringList modules = dir.entryList(); + TQStringList modules = dir.entryList(); for ( uint i = 0; i < modules.count(); ++i ) { - QString module = modules[i]; + TQString module = modules[i]; kdDebug() << "Module: " << dir.absPath() + "/" + module << endl; if ( reQuery.search(module) != -1 ) @@ -174,30 +174,30 @@ namespace KUnitTest cout << " Total skipped test steps : " << globalSkipped << endl; #else unsigned int numTests = m_registry.count(); // should this be globalSteps instead? - QString str; + TQString str; if ( globalFails == 0 ) if ( globalXFails == 0 ) - str = QString( "All %1 tests passed" ).arg( numTests ); + str = TQString( "All %1 tests passed" ).arg( numTests ); else - str = QString( "All %1 tests behaved as expected (%2 expected failures)" ).arg( numTests ).arg( globalXFails ); + str = TQString( "All %1 tests behaved as expected (%2 expected failures)" ).arg( numTests ).arg( globalXFails ); else if ( globalXPasses == 0 ) - str = QString( "%1 of %2 tests failed" ).arg( globalFails ).arg( numTests ); + str = TQString( "%1 of %2 tests failed" ).arg( globalFails ).arg( numTests ); else - str = QString( "%1 of %2 tests did not behave as expected (%1 unexpected passes)" ).arg( globalFails ).arg( numTests ).arg( globalXPasses ); + str = TQString( "%1 of %2 tests did not behave as expected (%1 unexpected passes)" ).arg( globalFails ).arg( numTests ).arg( globalXPasses ); if ( globalSkipped ) - str += QString( " (%1 tests skipped)" ).arg( globalSkipped ); + str += TQString( " (%1 tests skipped)" ).arg( globalSkipped ); cout << str.local8Bit() << endl; #endif return m_registry.count(); } - void Runner::runMatchingTests(const QString &prefix) + void Runner::runMatchingTests(const TQString &prefix) { RegistryIteratorType it(m_registry); for( ; it.current(); ++it ) - if ( QString(it.currentKey()).startsWith(prefix) ) + if ( TQString(it.currentKey()).startsWith(prefix) ) runTest(it.currentKey()); } @@ -224,10 +224,10 @@ namespace KUnitTest int numXFail = 0; int numXPass = 0; int numSkip = 0; - QStringList xpassList; - QStringList errorList; - QStringList xfailList; - QStringList skipList; + TQStringList xpassList; + TQStringList errorList; + TQStringList xfailList; + TQStringList skipList; if ( test->inherits("KUnitTest::SlotTester") ) { @@ -286,29 +286,29 @@ namespace KUnitTest if ( 0 < numXPass ) { cout << " Unexpected pass" << ( ( 1 == numXPass )?"":"es") << ":" << endl; - QStringList list = xpassList; - for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { + TQStringList list = xpassList; + for ( TQStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < (numFail - numXFail) ) { cout << " Unexpected failure" << ( ( 1 == numFail )?"":"s") << ":" << endl; - QStringList list = errorList; - for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { + TQStringList list = errorList; + for ( TQStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numXFail ) { cout << " Expected failure" << ( ( 1 == numXFail)?"":"s") << ":" << endl; - QStringList list = xfailList; - for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { + TQStringList list = xfailList; + for ( TQStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } if ( 0 < numSkip ) { cout << " Skipped test" << ( ( 1 == numSkip )?"":"s") << ":" << endl; - QStringList list = skipList; - for ( QStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { + TQStringList list = skipList; + for ( TQStringList::Iterator itr = list.begin(); itr != list.end(); ++itr ) { cout << "\t" << (*itr).latin1() << endl; } } diff --git a/kunittest/runner.h b/kunittest/runner.h index be1b056c8..49bbb0a4a 100644 --- a/kunittest/runner.h +++ b/kunittest/runner.h @@ -36,9 +36,9 @@ #include using namespace std; -#include -#include -#include +#include +#include +#include #include @@ -54,7 +54,7 @@ namespace KUnitTest * defines the name of the test suite. */ #define KUNITTEST_SUITE(suite)\ - static const QString s_kunittest_suite = suite; + static const TQString s_kunittest_suite = suite; /*! @def KUNITTEST_REGISTER_TESTER( tester ) * @brief Automatic registration of Tester classes. @@ -66,16 +66,16 @@ namespace KUnitTest * You can always use the static Runner::registerTester(const char *name, Tester *test) method. */ #define KUNITTEST_REGISTER_TESTER( tester )\ - static TesterAutoregister tester##Autoregister( QString(s_kunittest_suite + QString("::") + QString::fromLocal8Bit(#tester)).local8Bit() , new tester ()) + static TesterAutoregister tester##Autoregister( TQString(s_kunittest_suite + TQString("::") + TQString::fromLocal8Bit(#tester)).local8Bit() , new tester ()) #define KUNITTEST_REGISTER_NAMEDTESTER( name, tester )\ - static TesterAutoregister tester##Autoregister( QString(s_kunittest_suite + QString("::") + QString::fromLocal8Bit(name)).local8Bit() , new tester ()) + static TesterAutoregister tester##Autoregister( TQString(s_kunittest_suite + TQString("::") + TQString::fromLocal8Bit(name)).local8Bit() , new tester ()) /*! The type of the registry. */ - typedef QAsciiDict RegistryType; + typedef TQAsciiDict RegistryType; /*! A type that can be used to iterate through the registry. */ - typedef QAsciiDictIterator RegistryIteratorType; + typedef TQAsciiDictIterator RegistryIteratorType; /*! The Runner class holds a list of registered Tester classes and is able * to run those test cases. The Runner class follows the singleton design @@ -121,7 +121,7 @@ namespace KUnitTest * @param folder The folder where to look for modules. * @param query A regular expression. Only modules which match the query will be run. */ - static void loadModules(const QString &folder, const QString &query); + static void loadModules(const TQString &folder, const TQString &query); /*! The runner can spit out special debug messages needed by the Perl script: kunittest_debughelper. * This script can attach the debug output of each suite to the results in the KUnitTest GUI. @@ -171,7 +171,7 @@ namespace KUnitTest /*! Call this slot to run tests with names starting with prefix. * @param prefix Only run tests starting with the string prefix. */ - void runMatchingTests(const QString &prefix); + void runMatchingTests(const TQString &prefix); /*! Reset the Runner in order to prepare it to run one or more tests again. */ diff --git a/kunittest/tester.cpp b/kunittest/tester.cpp index 93509716d..3faf3997e 100644 --- a/kunittest/tester.cpp +++ b/kunittest/tester.cpp @@ -26,7 +26,7 @@ #include using namespace std; -#include +#include #include "tester.h" @@ -38,23 +38,23 @@ namespace KUnitTest m_total = m_results; } - void SlotTester::invokeMember(const QString &str) + void SlotTester::invokeMember(const TQString &str) { - QString slotname = QString::number(QSLOT_CODE) + str; - connect(this, SIGNAL(invoke()), this, slotname.ascii()); + TQString slotname = TQString::number(QSLOT_CODE) + str; + connect(this, TQT_SIGNAL(invoke()), this, slotname.ascii()); emit invoke(); - disconnect(this, SIGNAL(invoke()), this, slotname.ascii()); + disconnect(this, TQT_SIGNAL(invoke()), this, slotname.ascii()); } void SlotTester::allTests() { - QStrList allSlots = metaObject()->slotNames(); + TQStrList allSlots = metaObject()->slotNames(); if ( allSlots.contains("setUp()") > 0 ) invokeMember("setUp()"); for ( char *sl = allSlots.first(); sl; sl = allSlots.next() ) { - QString str = sl; + TQString str = sl; if ( str.startsWith("test") ) { @@ -80,17 +80,17 @@ namespace KUnitTest } } -QTextStream& operator<<( QTextStream& str, const QRect& r ) { +TQTextStream& operator<<( TQTextStream& str, const TQRect& r ) { str << "[" << r.x() << "," << r.y() << " - " << r.width() << "x" << r.height() << "]"; return str; } -QTextStream& operator<<( QTextStream& str, const QPoint& r ) { +TQTextStream& operator<<( TQTextStream& str, const TQPoint& r ) { str << "(" << r.x() << "," << r.y() << ")"; return str; } -QTextStream& operator<<( QTextStream& str, const QSize& r ) { +TQTextStream& operator<<( TQTextStream& str, const TQSize& r ) { str << "[" << r.width() << "x" << r.height() << "]"; return str; } diff --git a/kunittest/tester.h b/kunittest/tester.h index f54b85982..ff3a3d453 100644 --- a/kunittest/tester.h +++ b/kunittest/tester.h @@ -96,7 +96,7 @@ * void SampleTest::allTests() * { * CHECK( 3+3, 6 ); - * CHECK( QString( "hello%1" ).arg( " world not" ), QString( "hello world" ) ); + * CHECK( TQString( "hello%1" ).arg( " world not" ), TQString( "hello world" ) ); * } * @endcode * @@ -119,7 +119,7 @@ * @verbatim SampleTest - 1 test passed, 1 test failed Unexpected failure: - sampletest.cpp[38]: failed on "QString( "hello%1" ).arg( " world not" )" + sampletest.cpp[38]: failed on "TQString( "hello%1" ).arg( " world not" )" result = 'hello world not', expected = 'hello world' @endverbatim * @@ -325,9 +325,9 @@ SampleTest - 1 test passed, 1 test failed #include using namespace std; -#include -#include -#include +#include +#include +#include #include @@ -359,7 +359,7 @@ using namespace std; * * @code SKIP("Test skipped because of lack of foo support."); @endcode */ -#define SKIP( x ) skip( __FILE__, __LINE__, QString::fromLatin1(#x)) +#define SKIP( x ) skip( __FILE__, __LINE__, TQString::fromLatin1(#x)) /*! * A macro testing that @p expression throws an exception that is catched @@ -379,11 +379,11 @@ using namespace std; } \ if(exceptionRaised()) \ { \ - success(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: passed " + #expression); \ + success(TQString(__FILE__) + "[" + TQString::number(__LINE__) + "]: passed " + #expression); \ } \ else \ { \ - failure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed to throw " \ + failure(TQString(__FILE__) + "[" + TQString::number(__LINE__) + TQString("]: failed to throw " \ "an exception on: ") + #expression); \ } \ setExceptionRaised(false); @@ -403,11 +403,11 @@ using namespace std; } \ if(exceptionRaised()) \ { \ - unexpectedSuccess(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: unexpectedly threw an exception and passed: " + #expression); \ + unexpectedSuccess(TQString(__FILE__) + "[" + TQString::number(__LINE__) + "]: unexpectedly threw an exception and passed: " + #expression); \ }\ else \ { \ - expectedFailure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed to throw an exception on: ") + #expression); \ + expectedFailure(TQString(__FILE__) + "[" + TQString::number(__LINE__) + TQString("]: failed to throw an exception on: ") + #expression); \ } \ setExceptionRaised(false); @@ -417,8 +417,8 @@ using namespace std; * as being skipped. */ #define SKIP_EXCEPTION(exceptionCatch, expression) \ - skip( __FILE__, __LINE__, QString("Exception catch: ")\ - .arg(QString(#exceptionCatch)).arg(QString(" Test expression: ")).arg(QString(#expression))) + skip( __FILE__, __LINE__, TQString("Exception catch: ")\ + .arg(TQString(#exceptionCatch)).arg(TQString(" Test expression: ")).arg(TQString(#expression))) /** * Namespace for Unit testing classes @@ -454,14 +454,14 @@ namespace KUnitTest /*! Add some debug info that can be view later. Normally you do not need to call this. * @param debug The debug info. */ - virtual void addDebugInfo(const QString &debug) + virtual void addDebugInfo(const TQString &debug) { m_debug += debug; } /*! @returns The debug info that was added to this Tester object. */ - QString debugInfo() const { return m_debug; } + TQString debugInfo() const { return m_debug; } /*! @returns The number of finished tests. */ int testsFinished() const { return m_tests; } @@ -482,34 +482,34 @@ namespace KUnitTest int passed() const { return m_successList.count(); } /*! @returns Details about the failed tests. */ - QStringList errorList() const { return m_errorList; } + TQStringList errorList() const { return m_errorList; } /*! @returns Details about tests that failed expectedly. */ - QStringList xfailList() const { return m_xfailList; } + TQStringList xfailList() const { return m_xfailList; } /*! @returns Details about tests that succeeded unexpectedly. */ - QStringList xpassList() const { return m_xpassList; } + TQStringList xpassList() const { return m_xpassList; } /*! @returns Details about which tests were skipped. */ - QStringList skipList() const { return m_skipList; } + TQStringList skipList() const { return m_skipList; } /*! @returns Details about the succeeded tests. */ - QStringList successList() const { return m_successList; } + TQStringList successList() const { return m_successList; } private: - QStringList m_errorList; - QStringList m_xfailList; - QStringList m_xpassList; - QStringList m_skipList; - QStringList m_successList; - QString m_debug; + TQStringList m_errorList; + TQStringList m_xfailList; + TQStringList m_xpassList; + TQStringList m_skipList; + TQStringList m_successList; + TQString m_debug; int m_tests; }; - typedef QAsciiDict TestResultsListType; + typedef TQAsciiDict TestResultsListType; /*! A type that can be used to iterate through the registry. */ - typedef QAsciiDictIterator TestResultsListIteratorType; + typedef TQAsciiDictIterator TestResultsListIteratorType; /*! The abstract Tester class forms the base class for all test cases. Users must * implement the void Tester::allTests() method. This method contains the actual test. @@ -523,7 +523,7 @@ namespace KUnitTest { public: Tester(const char *name = 0L) - : QObject(0L, name), m_results(new TestResults()), m_exceptionState(false) + : TQObject(0L, name), m_results(new TestResults()), m_exceptionState(false) {} virtual ~Tester() { delete m_results; } @@ -544,10 +544,10 @@ namespace KUnitTest * @param line The linenumber in the file @p file. Use the __LINE__ macro for this. * @param msg The message that identifies the skipped test. */ - void skip( const char *file, int line, QString msg ) + void skip( const char *file, int line, TQString msg ) { - QString skipEntry; - QTextStream ts( &skipEntry, IO_WriteOnly ); + TQString skipEntry; + TQTextStream ts( &skipEntry, IO_WriteOnly ); ts << file << "["<< line <<"]: " << msg; skipTest( skipEntry ); } @@ -569,8 +569,8 @@ namespace KUnitTest if ( result != expectedResult ) { - QString error; - QTextStream ts( &error, IO_WriteOnly ); + TQString error; + TQTextStream ts( &error, IO_WriteOnly ); ts << file << "["<< line <<"]: failed on \"" << str <<"\" result = '" << result << "' expected = '" << expectedResult << "'"; @@ -586,8 +586,8 @@ namespace KUnitTest // we were expecting a failure if (expectedFail) { - QString err; - QTextStream ts( &err, IO_WriteOnly ); + TQString err; + TQTextStream ts( &err, IO_WriteOnly ); ts << file << "["<< line <<"]: " <<" unexpectedly passed on \"" << str <<"\""; @@ -595,8 +595,8 @@ namespace KUnitTest } else { - QString succ; - QTextStream ts( &succ, IO_WriteOnly ); + TQString succ; + TQTextStream ts( &succ, IO_WriteOnly ); ts << file << "["<< line <<"]: " <<" passed \"" << str <<"\""; @@ -614,7 +614,7 @@ namespace KUnitTest * @param message the message describing what failed. Should be informative, * such as mentioning the expression that failed and where, the file and file number. */ - void success(const QString &message) { m_results->m_successList.append(message); } + void success(const TQString &message) { m_results->m_successList.append(message); } /*! * This function can be used to flag failing tests, when @@ -623,7 +623,7 @@ namespace KUnitTest * @param message the message describing what failed. Should be informative, * such as mentioning the expression that failed and where, the file name and file number. */ - void failure(const QString &message) { m_results->m_errorList.append(message); } + void failure(const TQString &message) { m_results->m_errorList.append(message); } /*! * This function can be used to flag expected failures, when @@ -632,7 +632,7 @@ namespace KUnitTest * @param message the message describing what failed. Should be informative, * such as mentioning the expression that failed and where, the file name and file number. */ - void expectedFailure(const QString &message) { m_results->m_xfailList.append(message); } + void expectedFailure(const TQString &message) { m_results->m_xfailList.append(message); } /*! * This function can be used to flag unexpected successes, when @@ -641,7 +641,7 @@ namespace KUnitTest * @param message the message describing what failed. Should be informative, * such as mentioning the expression that failed and where, the file name and file number. */ - void unexpectedSuccess(const QString &message) { m_results->m_xpassList.append(message); } + void unexpectedSuccess(const TQString &message) { m_results->m_xpassList.append(message); } /*! * This function can be used to flag a test as skipped, when @@ -650,7 +650,7 @@ namespace KUnitTest * @param message the message describing what failed. Should be informative, * such as mentioning the expression that failed and where, the file name and file number. */ - void skipTest(const QString &message) { m_results->m_skipList.append(message); } + void skipTest(const TQString &message) { m_results->m_skipList.append(message); } /*! * exceptionRaised and exceptionState are book-keeping functions for testing for @@ -700,17 +700,17 @@ namespace KUnitTest void invoke(); private: - void invokeMember(const QString &str); + void invokeMember(const TQString &str); TestResultsListType m_resultsList; TestResults *m_total; }; } -KUNITTEST_EXPORT QTextStream& operator<<( QTextStream& str, const QRect& r ); +KUNITTEST_EXPORT TQTextStream& operator<<( TQTextStream& str, const TQRect& r ); -KUNITTEST_EXPORT QTextStream& operator<<( QTextStream& str, const QPoint& r ); +KUNITTEST_EXPORT TQTextStream& operator<<( TQTextStream& str, const TQPoint& r ); -KUNITTEST_EXPORT QTextStream& operator<<( QTextStream& str, const QSize& r ); +KUNITTEST_EXPORT TQTextStream& operator<<( TQTextStream& str, const TQSize& r ); #endif -- cgit v1.2.1