summaryrefslogtreecommitdiffstats
path: root/kutils/tests
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
commitffe8a83e053396df448e9413828527613ca3bd46 (patch)
treea73d4169e02df4a50f9a12cb165fcd0ab5bac7c6 /kutils/tests
parent682bf3bfdcbcbb1fca85e8a36ed03e062e0555d5 (diff)
downloadtdelibs-ffe8a83e053396df448e9413828527613ca3bd46.tar.gz
tdelibs-ffe8a83e053396df448e9413828527613ca3bd46.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1157647 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kutils/tests')
-rw-r--r--kutils/tests/kfindtest.cpp40
-rw-r--r--kutils/tests/kfindtest.h22
-rw-r--r--kutils/tests/kreplacetest.cpp64
-rw-r--r--kutils/tests/kreplacetest.h20
4 files changed, 73 insertions, 73 deletions
diff --git a/kutils/tests/kfindtest.cpp b/kutils/tests/kfindtest.cpp
index 17e8da7ee..1652eb625 100644
--- a/kutils/tests/kfindtest.cpp
+++ b/kutils/tests/kfindtest.cpp
@@ -28,12 +28,12 @@
#include <stdlib.h>
#include <assert.h>
-static bool check(QString txt, QString a, QString b) // from kurltest
+static bool check(TQString txt, TQString a, TQString b) // from kurltest
{
if (a.isEmpty())
- a = QString::null;
+ a = TQString::null;
if (b.isEmpty())
- b = QString::null;
+ b = TQString::null;
if (a == b) {
kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
}
@@ -44,7 +44,7 @@ static bool check(QString txt, QString a, QString b) // from kurltest
return true;
}
-void KFindTest::changeText(uint line, const QString &text)
+void KFindTest::changeText(uint line, const TQString &text)
{
Q_ASSERT(line < m_text.count());
Q_ASSERT(m_find != 0);
@@ -54,15 +54,15 @@ void KFindTest::changeText(uint line, const QString &text)
m_find->setData(line, text);
}
-void KFindTest::find(const QString &pattern, long options)
+void KFindTest::find(const TQString &pattern, long options)
{
delete m_find;
m_find = new KFind(pattern, options, 0);
- connect(m_find, SIGNAL(highlight(const QString &, int, int)),
- SLOT(slotHighlight(const QString &, int, int)));
- connect(m_find, SIGNAL(highlight(int, int, int)),
- SLOT(slotHighlight(int, int, int)));
+ connect(m_find, TQT_SIGNAL(highlight(const TQString &, int, int)),
+ TQT_SLOT(slotHighlight(const TQString &, int, int)));
+ connect(m_find, TQT_SIGNAL(highlight(int, int, int)),
+ TQT_SLOT(slotHighlight(int, int, int)));
m_line = 0;
KFind::Result result = KFind::NoMatch;
@@ -79,7 +79,7 @@ void KFindTest::find(const QString &pattern, long options)
} while(result == KFind::NoMatch && m_line < m_text.count());
}
-void KFindTest::findNext(const QString &pattern)
+void KFindTest::findNext(const TQString &pattern)
{
Q_ASSERT(m_find != 0);
@@ -109,16 +109,16 @@ void KFindTest::findNext(const QString &pattern)
//kdDebug() << "find next completed" << m_line << endl;
}
-void KFindTest::slotHighlight(const QString &text, int index, int matchedLength)
+void KFindTest::slotHighlight(const TQString &text, int index, int matchedLength)
{
- m_hits.append("line: \"" + text + "\", index: " + QString::number(index) +
- ", length: " + QString::number(matchedLength) + "\n");
+ m_hits.append("line: \"" + text + "\", index: " + TQString::number(index) +
+ ", length: " + TQString::number(matchedLength) + "\n");
}
void KFindTest::slotHighlight(int id, int index, int matchedLength)
{
- m_hits.append("line: \"" + m_text[id] + "\", index: " + QString::number(index) +
- ", length: " + QString::number(matchedLength) + "\n");
+ m_hits.append("line: \"" + m_text[id] + "\", index: " + TQString::number(index) +
+ ", length: " + TQString::number(matchedLength) + "\n");
}
int main(int argc, char **argv)
@@ -126,7 +126,7 @@ int main(int argc, char **argv)
KCmdLineArgs::init(argc, argv, "kfindtest", "KFindTest", 0, 0, false);
KApplication app;
- QString text = "This file is part of the KDE project.\n"
+ TQString text = "This file is part of the KDE project.\n"
"This library is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU Library General Public\n"
"License version 2, as published by the Free Software Foundation.\n"
@@ -141,12 +141,12 @@ int main(int argc, char **argv)
" the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n"
" Boston, MA 02110-1301, USA.\n";
- QString output1 = "line: \"This file is part of the KDE project.\", index: 0, length: 4\n"
+ TQString output1 = "line: \"This file is part of the KDE project.\", index: 0, length: 4\n"
"line: \"This library is free software; you can redistribute it and/or\", index: 0, length: 4\n"
"line: \" This library is distributed in the hope that it will be useful,\", index: 4, length: 4\n"
"line: \" along with this library; see the file COPYING.LIB. If not, write to\", index: 15, length: 4\n";
- QString output2 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n"
+ TQString output2 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n"
"line: \"This file is part of the KDE project.\", index: 2, length: 1\n"
"line: \"This file is part of the KDE project.\", index: 2, length: 2\n"
"line: \"This library is free software; you can redistribute it and/or\", index: 42, length: 3\n"
@@ -161,7 +161,7 @@ int main(int argc, char **argv)
"line: \"This library is free software; you can redistribute it and/or\", index: 16, length: 4\n"
"line: \"License version 2, as published by the Free Software Foundation.\", index: 44, length: 19\n";
- QString output3 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n"
+ TQString output3 = "line: \"This file is part of the KDE project.\", index: 0, length: 0\n"
"line: \"This file is part of the KDE project.\", index: 2, length: 1\n"
"line: \"This file is part of the KDE project.\", index: 2, length: 2\n"
"line: \"This library is free software; you can redistribute it and/or\", index: 42, length: 3\n"
@@ -179,7 +179,7 @@ int main(int argc, char **argv)
"line: \"License version 2, as published by the Free Software Foundation.\", index: 39, length: 4\n"
"line: \"License version 2, as published by the Free Software Foundation.\", index: 44, length: 19\n";
- KFindTest *test = new KFindTest(QStringList::split('\n', text, true));
+ KFindTest *test = new KFindTest(TQStringList::split('\n', text, true));
kdDebug() << "Plain static search..." << endl;
diff --git a/kutils/tests/kfindtest.h b/kutils/tests/kfindtest.h
index 2cb60ed76..b3be84a8b 100644
--- a/kutils/tests/kfindtest.h
+++ b/kutils/tests/kfindtest.h
@@ -20,8 +20,8 @@
#ifndef KFINDTEST_H
#define KFINDTEST_H
-#include <qobject.h>
-#include <qstringlist.h>
+#include <tqobject.h>
+#include <tqstringlist.h>
class KFind;
@@ -30,30 +30,30 @@ class KFindTest : public QObject
Q_OBJECT
public:
- KFindTest(const QStringList &text) :
- QObject(0),
+ KFindTest(const TQStringList &text) :
+ TQObject(0),
m_find(0),
m_text(text),
m_line(0)
{}
- void find(const QString &pattern, long options = 0);
- void findNext(const QString &pattern = QString::null);
+ void find(const TQString &pattern, long options = 0);
+ void findNext(const TQString &pattern = TQString::null);
- void changeText(uint line, const QString &text);
+ void changeText(uint line, const TQString &text);
- const QStringList &hits() const { return m_hits; }
+ const TQStringList &hits() const { return m_hits; }
void clearHits() { m_hits.clear(); }
public slots:
- void slotHighlight(const QString &text, int index, int matchedLength);
+ void slotHighlight(const TQString &text, int index, int matchedLength);
void slotHighlight(int id, int index, int matchedLengthlength);
private:
KFind *m_find;
- QStringList m_text;
+ TQStringList m_text;
uint m_line;
- QStringList m_hits;
+ TQStringList m_hits;
};
#endif
diff --git a/kutils/tests/kreplacetest.cpp b/kutils/tests/kreplacetest.cpp
index 9c6f67b3a..a810b7706 100644
--- a/kutils/tests/kreplacetest.cpp
+++ b/kutils/tests/kreplacetest.cpp
@@ -21,7 +21,7 @@
#include <kcmdlineargs.h>
#include <kapplication.h>
-#include <qeventloop.h>
+#include <tqeventloop.h>
#include <kpushbutton.h>
#include "../kreplace.h"
#include "../kreplacedialog.h"
@@ -30,7 +30,7 @@
#include <kdebug.h>
#include <stdlib.h>
-void KReplaceTest::replace( const QString &pattern, const QString &replacement, long options )
+void KReplaceTest::replace( const TQString &pattern, const TQString &replacement, long options )
{
m_needEventLoop = false;
// This creates a replace-next-prompt dialog if needed.
@@ -38,14 +38,14 @@ void KReplaceTest::replace( const QString &pattern, const QString &replacement,
// Connect highlight signal to code which handles highlighting
// of found text.
- connect(m_replace, SIGNAL( highlight( const QString &, int, int ) ),
- this, SLOT( slotHighlight( const QString &, int, int ) ) );
+ connect(m_replace, TQT_SIGNAL( highlight( const TQString &, int, int ) ),
+ this, TQT_SLOT( slotHighlight( const TQString &, int, int ) ) );
// Connect findNext signal - called when pressing the button in the dialog
- connect(m_replace, SIGNAL( findNext() ),
- this, SLOT( slotReplaceNext() ) );
+ connect(m_replace, TQT_SIGNAL( findNext() ),
+ this, TQT_SLOT( slotReplaceNext() ) );
// Connect replace signal - called when doing a replacement
- connect(m_replace, SIGNAL( replace(const QString &, int, int, int) ),
- this, SLOT( slotReplace(const QString &, int, int, int) ) );
+ connect(m_replace, TQT_SIGNAL( replace(const TQString &, int, int, int) ),
+ this, TQT_SLOT( slotReplace(const TQString &, int, int, int) ) );
// Go to initial position
if ( (options & KReplaceDialog::FromCursor) == 0 )
@@ -63,7 +63,7 @@ void KReplaceTest::replace( const QString &pattern, const QString &replacement,
qApp->eventLoop()->enterLoop();
}
-void KReplaceTest::slotHighlight( const QString &str, int matchingIndex, int matchedLength )
+void KReplaceTest::slotHighlight( const TQString &str, int matchingIndex, int matchedLength )
{
kdDebug() << "slotHighlight Index:" << matchingIndex << " Length:" << matchedLength
<< " Substr:" << str.mid(matchingIndex, matchedLength)
@@ -79,7 +79,7 @@ void KReplaceTest::slotHighlight( const QString &str, int matchingIndex, int mat
}
-void KReplaceTest::slotReplace(const QString &text, int replacementIndex, int replacedLength, int matchedLength)
+void KReplaceTest::slotReplace(const TQString &text, int replacementIndex, int replacedLength, int matchedLength)
{
kdDebug() << "slotReplace index=" << replacementIndex << " replacedLength=" << replacedLength << " matchedLength=" << matchedLength << " text=" << text.left( 50 ) << endl;
*m_currentPos = text; // KReplace hacked the replacement into 'text' in already.
@@ -120,7 +120,7 @@ void KReplaceTest::slotReplaceNext()
void KReplaceTest::print()
{
- QStringList::Iterator it = m_text.begin();
+ TQStringList::Iterator it = m_text.begin();
for ( ; it != m_text.end() ; ++it )
kdDebug() << *it << endl;
}
@@ -130,9 +130,9 @@ void KReplaceTest::print()
static void testReplaceSimple( int options, int button = 0 )
{
kdDebug() << "testReplaceSimple: " << options << endl;
- KReplaceTest test( QString( "hellohello" ), button );
+ KReplaceTest test( TQString( "hellohello" ), button );
test.replace( "hello", "HELLO", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( textLines[ 0 ] != "HELLOHELLO" ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'HELLOHELLO'" << endl;
@@ -145,9 +145,9 @@ static void testReplaceSimple( int options, int button = 0 )
static void testReplaceBlank( int options, int button = 0 )
{
kdDebug() << "testReplaceBlank: " << options << endl;
- KReplaceTest test( QString( "aaaaaa" ), button );
+ KReplaceTest test( TQString( "aaaaaa" ), button );
test.replace( "a", "", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( !textLines[ 0 ].isEmpty() ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of ''" << endl;
@@ -160,9 +160,9 @@ static void testReplaceBlank( int options, int button = 0 )
static void testReplaceBlankSearch( int options, int button = 0 )
{
kdDebug() << "testReplaceBlankSearch: " << options << endl;
- KReplaceTest test( QString( "bbbb" ), button );
+ KReplaceTest test( TQString( "bbbb" ), button );
test.replace( "", "foo", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( textLines[ 0 ] != "foobfoobfoobfoobfoo" ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'foobfoobfoobfoobfoo'" << endl;
@@ -174,9 +174,9 @@ static void testReplaceLonger( int options, int button = 0 )
{
kdDebug() << "testReplaceLonger: " << options << endl;
// Standard test of a replacement string longer than the matched string
- KReplaceTest test( QString( "aaaa" ), button );
+ KReplaceTest test( TQString( "aaaa" ), button );
test.replace( "a", "bb", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( textLines[ 0 ] != "bbbbbbbb" ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'bbbbbbbb'" << endl;
@@ -188,9 +188,9 @@ static void testReplaceLongerInclude( int options, int button = 0 )
{
kdDebug() << "testReplaceLongerInclude: " << options << endl;
// Similar test, where the replacement string includes the search string
- KReplaceTest test( QString( "a foo b" ), button );
+ KReplaceTest test( TQString( "a foo b" ), button );
test.replace( "foo", "foobar", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( textLines[ 0 ] != "a foobar b" ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'a foobar b'" << endl;
@@ -202,9 +202,9 @@ static void testReplaceLongerInclude2( int options, int button = 0 )
{
kdDebug() << "testReplaceLongerInclude2: " << options << endl;
// Similar test, but with more chances of matches inside the replacement string
- KReplaceTest test( QString( "aaaa" ), button );
+ KReplaceTest test( TQString( "aaaa" ), button );
test.replace( "a", "aa", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
if ( textLines[ 0 ] != "aaaaaaaa" ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of 'aaaaaaaa'" << endl;
@@ -216,18 +216,18 @@ static void testReplaceLongerInclude2( int options, int button = 0 )
static void testReplaceBackRef( int options, int button = 0 )
{
kdDebug() << "testReplaceBackRef: " << options << endl;
- KReplaceTest test( QString( "abc def" ), button );
+ KReplaceTest test( TQString( "abc def" ), button );
test.replace( "abc", "(\\0)", options );
- QStringList textLines = test.textLines();
+ TQStringList textLines = test.textLines();
assert( textLines.count() == 1 );
- QString expected = options & KReplaceDialog::BackReference ? "(abc) def" : "(\\0) def";
+ TQString expected = options & KReplaceDialog::BackReference ? "(abc) def" : "(\\0) def";
if ( textLines[ 0 ] != expected ) {
kdError() << "ASSERT FAILED: replaced text is '" << textLines[ 0 ] << "' instead of '"<< expected << "'" << endl;
exit(1);
}
}
-static void testReplacementHistory( const QStringList& findHistory, const QStringList& replaceHistory )
+static void testReplacementHistory( const TQStringList& findHistory, const TQStringList& replaceHistory )
{
KReplaceDialog dlg( 0, 0, 0, findHistory, replaceHistory );
dlg.show();
@@ -237,8 +237,8 @@ static void testReplacementHistory( const QStringList& findHistory, const QStrin
static void testReplacementHistory()
{
- QStringList findHistory;
- QStringList replaceHistory;
+ TQStringList findHistory;
+ TQStringList replaceHistory;
findHistory << "foo" << "bar";
replaceHistory << "FOO" << "BAR";
testReplacementHistory( findHistory, replaceHistory );
@@ -246,7 +246,7 @@ static void testReplacementHistory()
findHistory.clear();
replaceHistory.clear();
findHistory << "foo" << "bar";
- replaceHistory << QString::null << "baz"; // #130831
+ replaceHistory << TQString::null << "baz"; // #130831
testReplacementHistory( findHistory, replaceHistory );
}
@@ -311,7 +311,7 @@ int main( int argc, char **argv )
testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User3 ); // replace
testReplaceBackRef( KReplaceDialog::BackReference | KReplaceDialog::FindBackwards | KReplaceDialog::PromptOnReplace, KDialogBase::User1 ); // replace all
- QString text = "This file is part of the KDE project.\n"
+ TQString text = "This file is part of the KDE project.\n"
"This library is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU Library General Public\n"
"License version 2, as published by the Free Software Foundation.\n"
@@ -329,7 +329,7 @@ int main( int argc, char **argv )
"ThisThis This, This. This\n"
"aGNU\n"
"free";
- KReplaceTest test( QStringList::split( '\n', text, true ), 0 );
+ KReplaceTest test( TQStringList::split( '\n', text, true ), 0 );
test.replace( "GNU", "KDE", 0 );
test.replace( "free", "*free*", 0 );
diff --git a/kutils/tests/kreplacetest.h b/kutils/tests/kreplacetest.h
index a60563e77..ff85ca34b 100644
--- a/kutils/tests/kreplacetest.h
+++ b/kutils/tests/kreplacetest.h
@@ -20,8 +20,8 @@
#ifndef KREPLACETEST_H
#define KREPLACETEST_H
-#include <qobject.h>
-#include <qstringlist.h>
+#include <tqobject.h>
+#include <tqstringlist.h>
class KReplace;
@@ -29,21 +29,21 @@ class KReplaceTest : public QObject
{
Q_OBJECT
public:
- KReplaceTest( const QStringList& text, int button )
- : QObject( 0L ), m_text( text ), m_replace( 0 ), m_button( button ) {}
+ KReplaceTest( const TQStringList& text, int button )
+ : TQObject( 0L ), m_text( text ), m_replace( 0 ), m_button( button ) {}
- void replace( const QString &pattern, const QString &replacement, long options );
+ void replace( const TQString &pattern, const TQString &replacement, long options );
void print();
- const QStringList& textLines() const { return m_text; }
+ const TQStringList& textLines() const { return m_text; }
public slots:
- void slotHighlight( const QString &, int, int );
+ void slotHighlight( const TQString &, int, int );
void slotReplaceNext();
- void slotReplace(const QString &text, int replacementIndex, int replacedLength, int matchedLength);
+ void slotReplace(const TQString &text, int replacementIndex, int replacedLength, int matchedLength);
private:
- QStringList::Iterator m_currentPos;
- QStringList m_text;
+ TQStringList::Iterator m_currentPos;
+ TQStringList m_text;
KReplace* m_replace;
bool m_needEventLoop;
int m_button;