Cleanup corelib autotests

Remove literal tabs.

Change-Id: I210a0259773cceb20d35ebc80b889e3ebb88b540
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Jason McDonald 2011-11-07 19:19:27 +10:00 committed by Qt by Nokia
parent 2cd4710715
commit 8e11f7c93a
30 changed files with 3355 additions and 3380 deletions

View File

@ -351,7 +351,7 @@ void tst_QParallelAnimationGroup::stateChanged()
void tst_QParallelAnimationGroup::clearGroup() void tst_QParallelAnimationGroup::clearGroup()
{ {
QParallelAnimationGroup group; QParallelAnimationGroup group;
static const int animationCount = 10; static const int animationCount = 10;
for (int i = 0; i < animationCount; ++i) { for (int i = 0; i < animationCount; ++i) {
new QParallelAnimationGroup(&group); new QParallelAnimationGroup(&group);

View File

@ -922,8 +922,8 @@ void tst_QSequentialAnimationGroup::startDelay()
void tst_QSequentialAnimationGroup::clearGroup() void tst_QSequentialAnimationGroup::clearGroup()
{ {
QSequentialAnimationGroup group; QSequentialAnimationGroup group;
static const int animationCount = 20; static const int animationCount = 20;
for (int i = 0; i < animationCount/2; ++i) { for (int i = 0; i < animationCount/2; ++i) {
QSequentialAnimationGroup *subGroup = new QSequentialAnimationGroup(&group); QSequentialAnimationGroup *subGroup = new QSequentialAnimationGroup(&group);

View File

@ -513,8 +513,8 @@ void tst_QTextCodec::aliasForUTF16() const
void tst_QTextCodec::mibForTSCII() const void tst_QTextCodec::mibForTSCII() const
{ {
QTextCodec *codec = QTextCodec::codecForName("TSCII"); QTextCodec *codec = QTextCodec::codecForName("TSCII");
QVERIFY(codec); QVERIFY(codec);
QCOMPARE(codec->mibEnum(), 2107); QCOMPARE(codec->mibEnum(), 2107);
} }

View File

@ -203,72 +203,73 @@ void tst_QBuffer::writeBlock_data()
QTest::addColumn<QString>("str"); QTest::addColumn<QString>("str");
QTest::newRow( "small_bytearray" ) << QString("Test"); QTest::newRow( "small_bytearray" ) << QString("Test");
QTest::newRow( "large_bytearray" ) << QString("The QBuffer class is an I/O device that operates on a QByteArray.\n" QTest::newRow( "large_bytearray" ) << QString(
"QBuffer is used to read and write to a memory buffer. It is normally " "The QBuffer class is an I/O device that operates on a QByteArray.\n"
"used with a QTextStream or a QDataStream. QBuffer has an associated " "QBuffer is used to read and write to a memory buffer. It is normally "
"QByteArray which holds the buffer data. The size() of the buffer is " "used with a QTextStream or a QDataStream. QBuffer has an associated "
"automatically adjusted as data is written.\n" "QByteArray which holds the buffer data. The size() of the buffer is "
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing " "automatically adjusted as data is written.\n"
"byte array. The byte array can also be set with setBuffer(). Writing to " "The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
"the QBuffer will modify the original byte array because QByteArray is " "byte array. The byte array can also be set with setBuffer(). Writing to "
"explicitly shared.\n" "the QBuffer will modify the original byte array because QByteArray is "
"Use open() to open the buffer before use and to set the mode (read-only, " "explicitly shared.\n"
"write-only, etc.). close() closes the buffer. The buffer must be closed " "Use open() to open the buffer before use and to set the mode (read-only, "
"before reopening or calling setBuffer().\n" "write-only, etc.). close() closes the buffer. The buffer must be closed "
"A common way to use QBuffer is through QDataStream or QTextStream, which " "before reopening or calling setBuffer().\n"
"have constructors that take a QBuffer parameter. For convenience, there " "A common way to use QBuffer is through QDataStream or QTextStream, which "
"are also QDataStream and QTextStream constructors that take a QByteArray " "have constructors that take a QBuffer parameter. For convenience, there "
"parameter. These constructors create and open an internal QBuffer.\n" "are also QDataStream and QTextStream constructors that take a QByteArray "
"Note that QTextStream can also operate on a QString (a Unicode string); a " "parameter. These constructors create and open an internal QBuffer.\n"
"QBuffer cannot.\n" "Note that QTextStream can also operate on a QString (a Unicode string); a "
"You can also use QBuffer directly through the standard QIODevice functions " "QBuffer cannot.\n"
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" "You can also use QBuffer directly through the standard QIODevice functions "
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
"Classes and Input/Output and Networking.\n\n" "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
"The QBuffer class is an I/O device that operates on a QByteArray.\n" "Classes and Input/Output and Networking.\n\n"
"QBuffer is used to read and write to a memory buffer. It is normally " "The QBuffer class is an I/O device that operates on a QByteArray.\n"
"used with a QTextStream or a QDataStream. QBuffer has an associated " "QBuffer is used to read and write to a memory buffer. It is normally "
"QByteArray which holds the buffer data. The size() of the buffer is " "used with a QTextStream or a QDataStream. QBuffer has an associated "
"automatically adjusted as data is written.\n" "QByteArray which holds the buffer data. The size() of the buffer is "
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing " "automatically adjusted as data is written.\n"
"byte array. The byte array can also be set with setBuffer(). Writing to " "The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
"the QBuffer will modify the original byte array because QByteArray is " "byte array. The byte array can also be set with setBuffer(). Writing to "
"explicitly shared.\n" "the QBuffer will modify the original byte array because QByteArray is "
"Use open() to open the buffer before use and to set the mode (read-only, " "explicitly shared.\n"
"write-only, etc.). close() closes the buffer. The buffer must be closed " "Use open() to open the buffer before use and to set the mode (read-only, "
"before reopening or calling setBuffer().\n" "write-only, etc.). close() closes the buffer. The buffer must be closed "
"A common way to use QBuffer is through QDataStream or QTextStream, which " "before reopening or calling setBuffer().\n"
"have constructors that take a QBuffer parameter. For convenience, there " "A common way to use QBuffer is through QDataStream or QTextStream, which "
"are also QDataStream and QTextStream constructors that take a QByteArray " "have constructors that take a QBuffer parameter. For convenience, there "
"parameter. These constructors create and open an internal QBuffer.\n" "are also QDataStream and QTextStream constructors that take a QByteArray "
"Note that QTextStream can also operate on a QString (a Unicode string); a " "parameter. These constructors create and open an internal QBuffer.\n"
"QBuffer cannot.\n" "Note that QTextStream can also operate on a QString (a Unicode string); a "
"You can also use QBuffer directly through the standard QIODevice functions " "QBuffer cannot.\n"
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" "You can also use QBuffer directly through the standard QIODevice functions "
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
"Classes and Input/Output and Networking.\n\n" "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
"The QBuffer class is an I/O device that operates on a QByteArray.\n" "Classes and Input/Output and Networking.\n\n"
"QBuffer is used to read and write to a memory buffer. It is normally " "The QBuffer class is an I/O device that operates on a QByteArray.\n"
"used with a QTextStream or a QDataStream. QBuffer has an associated " "QBuffer is used to read and write to a memory buffer. It is normally "
"QByteArray which holds the buffer data. The size() of the buffer is " "used with a QTextStream or a QDataStream. QBuffer has an associated "
"automatically adjusted as data is written.\n" "QByteArray which holds the buffer data. The size() of the buffer is "
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing " "automatically adjusted as data is written.\n"
"byte array. The byte array can also be set with setBuffer(). Writing to " "The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
"the QBuffer will modify the original byte array because QByteArray is " "byte array. The byte array can also be set with setBuffer(). Writing to "
"explicitly shared.\n" "the QBuffer will modify the original byte array because QByteArray is "
"Use open() to open the buffer before use and to set the mode (read-only, " "explicitly shared.\n"
"write-only, etc.). close() closes the buffer. The buffer must be closed " "Use open() to open the buffer before use and to set the mode (read-only, "
"before reopening or calling setBuffer().\n" "write-only, etc.). close() closes the buffer. The buffer must be closed "
"A common way to use QBuffer is through QDataStream or QTextStream, which " "before reopening or calling setBuffer().\n"
"have constructors that take a QBuffer parameter. For convenience, there " "A common way to use QBuffer is through QDataStream or QTextStream, which "
"are also QDataStream and QTextStream constructors that take a QByteArray " "have constructors that take a QBuffer parameter. For convenience, there "
"parameter. These constructors create and open an internal QBuffer.\n" "are also QDataStream and QTextStream constructors that take a QByteArray "
"Note that QTextStream can also operate on a QString (a Unicode string); a " "parameter. These constructors create and open an internal QBuffer.\n"
"QBuffer cannot.\n" "Note that QTextStream can also operate on a QString (a Unicode string); a "
"You can also use QBuffer directly through the standard QIODevice functions " "QBuffer cannot.\n"
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n" "You can also use QBuffer directly through the standard QIODevice functions "
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection " "readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
"Classes and Input/Output and Networking."); "See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
"Classes and Input/Output and Networking.");
} }
void tst_QBuffer::writeBlock() void tst_QBuffer::writeBlock()

View File

@ -644,7 +644,7 @@ void tst_QFile::setSize()
QCOMPARE(c, 'a'); QCOMPARE(c, 'a');
QCOMPARE(f.size(), (qlonglong)1); QCOMPARE(f.size(), (qlonglong)1);
bool ok = f.resize(99); bool ok = f.resize(99);
QVERIFY(ok); QVERIFY(ok);
QCOMPARE(f.size(), (qlonglong)99); QCOMPARE(f.size(), (qlonglong)99);
@ -1492,19 +1492,19 @@ void tst_QFile::tailFile()
void tst_QFile::flush() void tst_QFile::flush()
{ {
QString fileName("stdfile.txt"); QString fileName("stdfile.txt");
QFile::remove(fileName); QFile::remove(fileName);
{ {
QFile file(fileName); QFile file(fileName);
QVERIFY(file.open(QFile::WriteOnly)); QVERIFY(file.open(QFile::WriteOnly));
QCOMPARE(file.write("abc", 3),qint64(3)); QCOMPARE(file.write("abc", 3),qint64(3));
} }
{ {
QFile file(fileName); QFile file(fileName);
QVERIFY(file.open(QFile::WriteOnly | QFile::Append)); QVERIFY(file.open(QFile::WriteOnly | QFile::Append));
QCOMPARE(file.pos(), qlonglong(3)); QCOMPARE(file.pos(), qlonglong(3));
QCOMPARE(file.write("def", 3), qlonglong(3)); QCOMPARE(file.write("def", 3), qlonglong(3));
QCOMPARE(file.pos(), qlonglong(6)); QCOMPARE(file.pos(), qlonglong(6));
@ -1516,7 +1516,7 @@ void tst_QFile::flush()
QCOMPARE(file.readAll(), QByteArray("abcdef")); QCOMPARE(file.readAll(), QByteArray("abcdef"));
} }
QFile::remove(fileName); QFile::remove(fileName);
} }
void tst_QFile::bufferedRead() void tst_QFile::bufferedRead()
@ -1529,7 +1529,7 @@ void tst_QFile::bufferedRead()
file.close(); file.close();
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r"); FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r");
#else #else
FILE *stdFile = fopen("stdfile.txt", "r"); FILE *stdFile = fopen("stdfile.txt", "r");
#endif #endif
@ -2281,7 +2281,7 @@ void tst_QFile::virtualFile()
void tst_QFile::textFile() void tst_QFile::textFile()
{ {
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toAscii() , "wt"); FILE *fs = ::fopen((QCoreApplication::applicationDirPath() + "/writeabletextfile").toAscii() , "wt");
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
FILE *fs = ::fopen("writeabletextfile", "wt"); FILE *fs = ::fopen("writeabletextfile", "wt");
#else #else
@ -2787,8 +2787,7 @@ void tst_QFile::map()
QVERIFY(file.open(QFile::ReadWrite)); QVERIFY(file.open(QFile::ReadWrite));
memory = file.map(offset, size); memory = file.map(offset, size);
if (error != QFile::NoError) { if (error != QFile::NoError) {
QVERIFY(file.error() != QFile::NoError);
QVERIFY(file.error() != QFile::NoError);
return; return;
} }
@ -2909,7 +2908,7 @@ void tst_QFile::mapOpenMode()
if (QFile::exists(fileName)) { if (QFile::exists(fileName)) {
QVERIFY(QFile::setPermissions(fileName, QVERIFY(QFile::setPermissions(fileName,
QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser)); QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser));
QFile::remove(fileName); QFile::remove(fileName);
} }
QFile file(fileName); QFile file(fileName);

View File

@ -250,10 +250,10 @@ void tst_QIODevice::unget()
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
QTcpSocket socket; QTcpSocket socket;
QIODevice *dev; QIODevice *dev;
QByteArray result; QByteArray result;
const char *lineResult; const char *lineResult;
if (i == 0) { if (i == 0) {
dev = &buffer; dev = &buffer;
result = QByteArray("ZXCV"); result = QByteArray("ZXCV");
lineResult = "ZXCV"; lineResult = "ZXCV";
@ -264,21 +264,21 @@ void tst_QIODevice::unget()
dev = &socket; dev = &socket;
result = QByteArray("HTTP"); result = QByteArray("HTTP");
lineResult = "Date"; lineResult = "Date";
} }
char ch, ch2; char ch, ch2;
dev->seek(0); dev->seek(0);
dev->getChar(&ch); dev->getChar(&ch);
dev->ungetChar(ch); dev->ungetChar(ch);
QCOMPARE(dev->peek(4), result); QCOMPARE(dev->peek(4), result);
dev->getChar(&ch); dev->getChar(&ch);
dev->getChar(&ch2); dev->getChar(&ch2);
dev->ungetChar(ch2); dev->ungetChar(ch2);
dev->ungetChar(ch); dev->ungetChar(ch);
QCOMPARE(dev->read(1), result.left(1)); QCOMPARE(dev->read(1), result.left(1));
QCOMPARE(dev->read(3), result.right(3)); QCOMPARE(dev->read(3), result.right(3));
if (i == 0) if (i == 0)
dev->seek(0); dev->seek(0);
else else
dev->readLine(); dev->readLine();
dev->getChar(&ch); dev->getChar(&ch);
@ -300,33 +300,33 @@ void tst_QIODevice::peek()
QFile file("peektestfile"); QFile file("peektestfile");
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer; QIODevice *device = i ? (QIODevice *)&file : (QIODevice *)&buffer;
device->open(QBuffer::ReadWrite); device->open(QBuffer::ReadWrite);
device->write("ZXCV"); device->write("ZXCV");
device->seek(0); device->seek(0);
QCOMPARE(device->peek(4), QByteArray("ZXCV")); QCOMPARE(device->peek(4), QByteArray("ZXCV"));
QCOMPARE(device->pos(), qint64(0)); QCOMPARE(device->pos(), qint64(0));
device->write("ABCDE"); device->write("ABCDE");
device->seek(3); device->seek(3);
QCOMPARE(device->peek(1), QByteArray("D")); QCOMPARE(device->peek(1), QByteArray("D"));
QCOMPARE(device->peek(5), QByteArray("DE")); QCOMPARE(device->peek(5), QByteArray("DE"));
device->seek(0); device->seek(0);
QCOMPARE(device->read(4), QByteArray("ABCD")); QCOMPARE(device->read(4), QByteArray("ABCD"));
QCOMPARE(device->pos(), qint64(4)); QCOMPARE(device->pos(), qint64(4));
device->seek(0); device->seek(0);
device->write("ZXCV"); device->write("ZXCV");
device->seek(0); device->seek(0);
char buf[5]; char buf[5];
buf[4] = 0; buf[4] = 0;
device->peek(buf, 4); device->peek(buf, 4);
QCOMPARE(static_cast<const char *>(buf), "ZXCV"); QCOMPARE(static_cast<const char *>(buf), "ZXCV");
QCOMPARE(device->pos(), qint64(0)); QCOMPARE(device->pos(), qint64(0));
device->read(buf, 4); device->read(buf, 4);
QCOMPARE(static_cast<const char *>(buf), "ZXCV"); QCOMPARE(static_cast<const char *>(buf), "ZXCV");
QCOMPARE(device->pos(), qint64(4)); QCOMPARE(device->pos(), qint64(4));
} }
QFile::remove("peektestfile"); QFile::remove("peektestfile");
} }

View File

@ -203,7 +203,7 @@ static QString settingsPath(const char *path = "")
// Temporary path for files that are specified explictly in the constructor. // Temporary path for files that are specified explictly in the constructor.
QString tempPath = QDir::tempPath(); QString tempPath = QDir::tempPath();
if (tempPath.endsWith("/")) if (tempPath.endsWith("/"))
tempPath.truncate(tempPath.size() - 1); tempPath.truncate(tempPath.size() - 1);
return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path)); return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
} }
@ -309,9 +309,9 @@ void tst_QSettings::init()
removePath(settingsPath()); removePath(settingsPath());
#else #else
if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based)
system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1()); system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1());
else else
system(QString("deltree /Y %1").arg(settingsPath()).toLatin1()); system(QString("deltree /Y %1").arg(settingsPath()).toLatin1());
#endif #endif
} }
#elif defined(Q_OS_DARWIN) #elif defined(Q_OS_DARWIN)
@ -812,16 +812,16 @@ void tst_QSettings::testIniParsing()
QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat); QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat);
if ( settings.status() == QSettings::NoError ) { // else no point proceeding if ( settings.status() == QSettings::NoError ) { // else no point proceeding
QVariant v = settings.value(key); QVariant v = settings.value(key);
QVERIFY(v.canConvert(expect.type())); QVERIFY(v.canConvert(expect.type()));
// check some types so as to give prettier error messages // check some types so as to give prettier error messages
if ( v.type() == QVariant::String ) { if ( v.type() == QVariant::String ) {
QCOMPARE(v.toString(), expect.toString()); QCOMPARE(v.toString(), expect.toString());
} else if ( v.type() == QVariant::Int ) { } else if ( v.type() == QVariant::Int ) {
QCOMPARE(v.toInt(), expect.toInt()); QCOMPARE(v.toInt(), expect.toInt());
} else { } else {
QCOMPARE(v, expect); QCOMPARE(v, expect);
} }
} }
QCOMPARE(settings.status(), status); QCOMPARE(settings.status(), status);

View File

@ -224,38 +224,36 @@ void tst_QTemporaryFile::fileNameIsEmpty()
void tst_QTemporaryFile::autoRemove() void tst_QTemporaryFile::autoRemove()
{ {
// Test auto remove // Test auto remove
QString fileName; QString fileName;
{ {
QTemporaryFile file("tempXXXXXX"); QTemporaryFile file("tempXXXXXX");
file.setAutoRemove(true); file.setAutoRemove(true);
QVERIFY(file.open()); QVERIFY(file.open());
fileName = file.fileName(); fileName = file.fileName();
file.close(); file.close();
} }
QVERIFY(!QFile::exists(fileName)); QVERIFY(!QFile::exists(fileName));
// Test if disabling auto remove works. // Test if disabling auto remove works.
{ {
QTemporaryFile file("tempXXXXXX"); QTemporaryFile file("tempXXXXXX");
file.setAutoRemove(false); file.setAutoRemove(false);
QVERIFY(file.open()); QVERIFY(file.open());
fileName = file.fileName(); fileName = file.fileName();
file.close(); file.close();
} }
QVERIFY(QFile::exists(fileName)); QVERIFY(QFile::exists(fileName));
QVERIFY(QFile::remove(fileName)); QVERIFY(QFile::remove(fileName));
// Do not explicitly call setAutoRemove (tests if it really is the default as documented)
{
QTemporaryFile file("tempXXXXXX");
QVERIFY(file.open());
fileName = file.fileName();
file.close();
}
QVERIFY(!QFile::exists(fileName));
// Do not explicitly call setAutoRemove (tests if it really is the default as documented)
{
QTemporaryFile file("tempXXXXXX");
QVERIFY(file.open());
fileName = file.fileName();
file.close();
}
QVERIFY(!QFile::exists(fileName));
} }
void tst_QTemporaryFile::nonWritableCurrentDir() void tst_QTemporaryFile::nonWritableCurrentDir()

View File

@ -796,84 +796,83 @@ void tst_QUrl::resolving()
QCOMPARE(url.resolved(relativeUrl).toString(), relsolvedUrl); QCOMPARE(url.resolved(relativeUrl).toString(), relsolvedUrl);
} }
void tst_QUrl::toString_data() void tst_QUrl::toString_data()
{ {
QTest::addColumn<QString>("urlString"); QTest::addColumn<QString>("urlString");
QTest::addColumn<uint>("options"); QTest::addColumn<uint>("options");
QTest::addColumn<QString>("string"); QTest::addColumn<QString>("string");
QTest::newRow("data0") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data0") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme) << uint(QUrl::RemoveScheme)
<< QString::fromLatin1("//ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("//ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top");
QTest::newRow("data2") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data2") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemovePassword) << uint(QUrl::RemovePassword)
<< QString::fromLatin1("http://ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("http://ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top");
QTest::newRow("data3") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data3") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveUserInfo) << uint(QUrl::RemoveUserInfo)
<< QString::fromLatin1("http://www.troll.no:9090/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("http://www.troll.no:9090/index.html?ole=semann&gud=hei#top");
QTest::newRow("data4") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data4") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemovePort) << uint(QUrl::RemovePort)
<< QString::fromLatin1("http://ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("http://ole:password@www.troll.no/index.html?ole=semann&gud=hei#top");
QTest::newRow("data5") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data5") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveAuthority) << uint(QUrl::RemoveAuthority)
<< QString::fromLatin1("http:/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("http:/index.html?ole=semann&gud=hei#top");
QTest::newRow("data6") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data6") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemovePath) << uint(QUrl::RemovePath)
<< QString::fromLatin1("http://ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); << QString::fromLatin1("http://ole:password@www.troll.no:9090?ole=semann&gud=hei#top");
QTest::newRow("data7") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data7") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveQuery) << uint(QUrl::RemoveQuery)
<< QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html#top"); << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html#top");
QTest::newRow("data8") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data8") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveFragment) << uint(QUrl::RemoveFragment)
<< QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei"); << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei");
QTest::newRow("data9") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data9") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemovePassword) << uint(QUrl::RemoveScheme | QUrl::RemovePassword)
<< QString::fromLatin1("//ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("//ole@www.troll.no:9090/index.html?ole=semann&gud=hei#top");
QTest::newRow("data10") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data10") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo) << uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo)
<< QString::fromLatin1("//www.troll.no:9090/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("//www.troll.no:9090/index.html?ole=semann&gud=hei#top");
QTest::newRow("data11") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data11") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemovePort) << uint(QUrl::RemoveScheme | QUrl::RemovePort)
<< QString::fromLatin1("//ole:password@www.troll.no/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("//ole:password@www.troll.no/index.html?ole=semann&gud=hei#top");
QTest::newRow("data12") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data12") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority) << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority)
<< QString::fromLatin1("/index.html?ole=semann&gud=hei#top"); << QString::fromLatin1("/index.html?ole=semann&gud=hei#top");
QTest::newRow("data13") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data13") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemovePath) << uint(QUrl::RemoveScheme | QUrl::RemovePath)
<< QString::fromLatin1("//ole:password@www.troll.no:9090?ole=semann&gud=hei#top"); << QString::fromLatin1("//ole:password@www.troll.no:9090?ole=semann&gud=hei#top");
QTest::newRow("data14") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data14") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment) << uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment)
<< QString::fromLatin1("/index.html?ole=semann&gud=hei"); << QString::fromLatin1("/index.html?ole=semann&gud=hei");
QTest::newRow("data15") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data15") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveAuthority | QUrl::RemoveQuery) << uint(QUrl::RemoveAuthority | QUrl::RemoveQuery)
<< QString::fromLatin1("http:/index.html#top"); << QString::fromLatin1("http:/index.html#top");
QTest::newRow("data16") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data16") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemovePassword | QUrl::RemovePort << uint(QUrl::RemovePassword | QUrl::RemovePort
| QUrl::RemovePath | QUrl::RemoveQuery | QUrl::RemovePath | QUrl::RemoveQuery
| QUrl::RemoveFragment) | QUrl::RemoveFragment)
<< QString::fromLatin1("http://ole@www.troll.no"); << QString::fromLatin1("http://ole@www.troll.no");
QTest::newRow("data17") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top") QTest::newRow("data17") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
<< uint(QUrl::RemoveScheme | QUrl::RemovePassword << uint(QUrl::RemoveScheme | QUrl::RemovePassword
| QUrl::RemovePort | QUrl::RemovePath | QUrl::RemovePort | QUrl::RemovePath
| QUrl::RemoveQuery | QUrl::RemoveFragment) | QUrl::RemoveQuery | QUrl::RemoveFragment)
<< QString::fromLatin1("//ole@www.troll.no"); << QString::fromLatin1("//ole@www.troll.no");
QTest::newRow("data18") << QString::fromLatin1("http://andreas:hemmelig@www.vg.no/?my=query&your=query#yougotfragged") QTest::newRow("data18") << QString::fromLatin1("http://andreas:hemmelig@www.vg.no/?my=query&your=query#yougotfragged")
<< uint(QUrl::None) << uint(QUrl::None)
@ -911,18 +910,16 @@ void tst_QUrl::isParentOf_data()
QTest::addColumn<QString>("child"); QTest::addColumn<QString>("child");
QTest::addColumn<bool>("trueFalse"); QTest::addColumn<bool>("trueFalse");
QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d") QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d")
<< QString::fromLatin1("http://a.b.c/d/e?f") << true; << QString::fromLatin1("http://a.b.c/d/e?f") << true;
QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d") QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d")
<< QString::fromLatin1("http://a.b.c/d") << false; << QString::fromLatin1("http://a.b.c/d") << false;
QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d") QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d")
<< QString::fromLatin1("http://a.b.c/de") << false; << QString::fromLatin1("http://a.b.c/de") << false;
QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/") QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/")
<< QString::fromLatin1("http://a.b.c/de") << false; << QString::fromLatin1("http://a.b.c/de") << false;
QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/") QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/")
<< QString::fromLatin1("http://a.b.c/d/e") << true; << QString::fromLatin1("http://a.b.c/d/e") << true;
} }
void tst_QUrl::toString_constructed_data() void tst_QUrl::toString_constructed_data()
@ -941,16 +938,16 @@ void tst_QUrl::toString_constructed_data()
QString n(""); QString n("");
QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt.nokia.com") << -1 << QString::fromLatin1("index.html") QTest::newRow("data1") << n << n << n << QString::fromLatin1("qt.nokia.com") << -1 << QString::fromLatin1("index.html")
<< QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html") << QByteArray() << n << QString::fromLatin1("//qt.nokia.com/index.html")
<< QByteArray("//qt.nokia.com/index.html"); << QByteArray("//qt.nokia.com/index.html");
QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray() QTest::newRow("data2") << QString::fromLatin1("file") << n << n << n << -1 << QString::fromLatin1("/root") << QByteArray()
<< n << QString::fromLatin1("file:///root") << QByteArray("file:///root"); << n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde") QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde")
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
<< QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/"); << QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/");
QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde") QTest::newRow("PassWithoutUser") << QString::fromLatin1("http") << n << QString::fromLatin1("kde")
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n << "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
<< QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/"); << QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
} }
void tst_QUrl::toString_constructed() void tst_QUrl::toString_constructed()
@ -968,21 +965,21 @@ void tst_QUrl::toString_constructed()
QUrl url; QUrl url;
if (!scheme.isEmpty()) if (!scheme.isEmpty())
url.setScheme(scheme); url.setScheme(scheme);
if (!userName.isEmpty()) if (!userName.isEmpty())
url.setUserName(userName); url.setUserName(userName);
if (!password.isEmpty()) if (!password.isEmpty())
url.setPassword(password); url.setPassword(password);
if (!host.isEmpty()) if (!host.isEmpty())
url.setHost(host); url.setHost(host);
if (port != -1) if (port != -1)
url.setPort(port); url.setPort(port);
if (!path.isEmpty()) if (!path.isEmpty())
url.setPath(path); url.setPath(path);
if (!query.isEmpty()) if (!query.isEmpty())
url.setEncodedQuery(query); url.setEncodedQuery(query);
if (!fragment.isEmpty()) if (!fragment.isEmpty())
url.setFragment(fragment); url.setFragment(fragment);
QVERIFY(url.isValid()); QVERIFY(url.isValid());
QCOMPARE(url.toString(), asString); QCOMPARE(url.toString(), asString);
@ -1006,14 +1003,14 @@ void tst_QUrl::toLocalFile_data()
QTest::addColumn<QString>("theUrl"); QTest::addColumn<QString>("theUrl");
QTest::addColumn<QString>("theFile"); QTest::addColumn<QString>("theFile");
QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt"); QTest::newRow("data0") << QString::fromLatin1("file:/a.txt") << QString::fromLatin1("/a.txt");
QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); QTest::newRow("data4") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt");
QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt"); QTest::newRow("data5") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("c:/a.txt");
QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); QTest::newRow("data6") << QString::fromLatin1("file://somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile");
QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/");
QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost");
QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile");
QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt");
// and some that result in empty (i.e., not local) // and some that result in empty (i.e., not local)
QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString();
@ -1039,16 +1036,16 @@ void tst_QUrl::fromLocalFile_data()
QTest::addColumn<QString>("theUrl"); QTest::addColumn<QString>("theUrl");
QTest::addColumn<QString>("thePath"); QTest::addColumn<QString>("thePath");
QTest::newRow("data0") << QString::fromLatin1("/a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt"); QTest::newRow("data0") << QString::fromLatin1("/a.txt") << QString::fromLatin1("file:///a.txt") << QString::fromLatin1("/a.txt");
QTest::newRow("data1") << QString::fromLatin1("a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt"); QTest::newRow("data1") << QString::fromLatin1("a.txt") << QString::fromLatin1("file:a.txt") << QString::fromLatin1("a.txt");
QTest::newRow("data2") << QString::fromLatin1("/a/b.txt") << QString::fromLatin1("file:///a/b.txt") << QString::fromLatin1("/a/b.txt"); QTest::newRow("data2") << QString::fromLatin1("/a/b.txt") << QString::fromLatin1("file:///a/b.txt") << QString::fromLatin1("/a/b.txt");
QTest::newRow("data3") << QString::fromLatin1("c:/a.txt") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt"); QTest::newRow("data3") << QString::fromLatin1("c:/a.txt") << QString::fromLatin1("file:///c:/a.txt") << QString::fromLatin1("/c:/a.txt");
QTest::newRow("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile") QTest::newRow("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile")
<< QString::fromLatin1("/somedir/somefile"); << QString::fromLatin1("/somedir/somefile");
QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost") QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost")
<< QString::fromLatin1(""); << QString::fromLatin1("");
QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/") QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/")
<< QString::fromLatin1("/"); << QString::fromLatin1("/");
} }
void tst_QUrl::fromLocalFile() void tst_QUrl::fromLocalFile()
@ -1066,32 +1063,32 @@ void tst_QUrl::fromLocalFile()
void tst_QUrl::compat_legacy() void tst_QUrl::compat_legacy()
{ {
{ {
QUrl u( "file:bar" ); QUrl u( "file:bar" );
QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") ); QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") );
} }
/* others /* others
*/ */
{ {
QUrl u( "http://qt.nokia.com/images/ban/pgs_front.jpg" ); QUrl u( "http://qt.nokia.com/images/ban/pgs_front.jpg" );
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
} }
{ {
QUrl tmp( "http://qt.nokia.com/images/ban/" ); QUrl tmp( "http://qt.nokia.com/images/ban/" );
QUrl u = tmp.resolved(QString("pgs_front.jpg")); QUrl u = tmp.resolved(QString("pgs_front.jpg"));
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
} }
{ {
QUrl tmp; QUrl tmp;
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") ); QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
} }
{ {
QUrl tmp; QUrl tmp;
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg")); QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
QFileInfo fi(u.path()); QFileInfo fi(u.path());
u.setPath(fi.path()); u.setPath(fi.path());
QCOMPARE( u.path(), QString("/images/ban") ); QCOMPARE( u.path(), QString("/images/ban") );
} }
} }
@ -1124,16 +1121,16 @@ void tst_QUrl::compat_constructor_01()
QFETCH( QString, urlStr ); QFETCH( QString, urlStr );
{ {
QUrl empty; QUrl empty;
QUrl u = empty.resolved(urlStr); QUrl u = empty.resolved(urlStr);
QTEST( u.toString(), "res" ); QTEST( u.toString(), "res" );
} }
{ {
QUrl empty; QUrl empty;
QUrl u = empty.resolved(urlStr); QUrl u = empty.resolved(urlStr);
QTEST( u.toString(), "res" ); QTEST( u.toString(), "res" );
} }
} }
@ -1277,17 +1274,17 @@ void tst_QUrl::compat_isValid_02()
QUrl url; QUrl url;
if ( !protocol.isEmpty() ) if ( !protocol.isEmpty() )
url.setScheme( protocol ); url.setScheme( protocol );
if ( !user.isEmpty() ) if ( !user.isEmpty() )
url.setUserName( user ); url.setUserName( user );
if ( !password.isEmpty() ) if ( !password.isEmpty() )
url.setPassword( password ); url.setPassword( password );
if ( !host.isEmpty() ) if ( !host.isEmpty() )
url.setHost( host ); url.setHost( host );
if ( port != -1 ) if ( port != -1 )
url.setPort( port ); url.setPort( port );
if ( !path.isEmpty() ) if ( !path.isEmpty() )
url.setPath( path ); url.setPath( path );
QVERIFY( url.isValid() == res ); QVERIFY( url.isValid() == res );
} }

View File

@ -450,7 +450,7 @@ void tst_QMetaObject::invokeMetaMember()
QCOMPARE(obj.slotResult, QString("testReference:whatever")); QCOMPARE(obj.slotResult, QString("testReference:whatever"));
QCOMPARE(refStr, QString("gotcha")); QCOMPARE(refStr, QString("gotcha"));
qint64 ll1 = -1; qint64 ll1 = -1;
quint64 ll2 = 0; quint64 ll2 = 0;
QVERIFY(QMetaObject::invokeMethod(&obj, QVERIFY(QMetaObject::invokeMethod(&obj,
"testLongLong", "testLongLong",
@ -559,7 +559,7 @@ void tst_QMetaObject::invokeQueuedMetaMember()
QVERIFY(!QMetaObject::invokeMethod(&obj, "sig1", Qt::QueuedConnection, Q_RETURN_ARG(QString, exp), QVERIFY(!QMetaObject::invokeMethod(&obj, "sig1", Qt::QueuedConnection, Q_RETURN_ARG(QString, exp),
Q_ARG(QString, "nono"))); Q_ARG(QString, "nono")));
qint64 ll1 = -1; qint64 ll1 = -1;
quint64 ll2 = 0; quint64 ll2 = 0;
QVERIFY(QMetaObject::invokeMethod(&obj, QVERIFY(QMetaObject::invokeMethod(&obj,
"testLongLong", "testLongLong",

View File

@ -49,106 +49,99 @@
static int Step = 0; static int Step = 0;
Sender RandomSender (0, 0); Sender RandomSender (0, 0);
void TRACE (int step, const char *name) void TRACE (int step, const char *name)
{ {
for (int t = 0; t < step - 1; t++) for (int t = 0; t < step - 1; t++)
fprintf (stderr, "\t"); fprintf (stderr, "\t");
fprintf (stderr, "Step %d: %s\n", step, name); fprintf (stderr, "Step %d: %s\n", step, name);
return; return;
} }
Receiver::Receiver () Receiver::Receiver ()
: QObject () : QObject ()
{ {
} }
void Receiver::received () void Receiver::received ()
{ {
::Step++; ::Step++;
const int stepCopy = ::Step; const int stepCopy = ::Step;
TRACE (stepCopy, "Receiver::received()"); TRACE (stepCopy, "Receiver::received()");
if (::Step != 2 && ::Step != 4) if (::Step != 2 && ::Step != 4)
qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step); qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step);
if (::Step == 2) if (::Step == 2)
s->fire (); s->fire ();
fprintf (stderr, "Receiver<%s>::received() sender=%s\n", fprintf (stderr, "Receiver<%s>::received() sender=%s\n",
(const char *) objectName ().toAscii (), sender ()->metaObject()->className()); (const char *) objectName ().toAscii (), sender ()->metaObject()->className());
TRACE (stepCopy, "ends Receiver::received()"); TRACE (stepCopy, "ends Receiver::received()");
} }
Disconnector::Disconnector () Disconnector::Disconnector ()
: QObject () : QObject ()
{ {
} }
void Disconnector::received () void Disconnector::received ()
{ {
::Step++; ::Step++;
const int stepCopy = ::Step; const int stepCopy = ::Step;
TRACE (stepCopy, "Disconnector::received()"); TRACE (stepCopy, "Disconnector::received()");
if (::Step != 5 && ::Step != 6) if (::Step != 5 && ::Step != 6)
qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step); qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n", fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
(const char *) objectName ().toAscii (), sender ()->metaObject()->className()); (const char *) objectName ().toAscii (), sender ()->metaObject()->className());
if (sender () == 0) if (sender () == 0)
fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n"); fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");
if (::Step == 5) if (::Step == 5)
{ {
disconnect (s, SIGNAL (fired ()), s->d, SLOT (received ())); disconnect (s, SIGNAL (fired ()), s->d, SLOT (received ()));
connect (&RandomSender, SIGNAL (fired ()), s->d, SLOT (received ())); connect (&RandomSender, SIGNAL (fired ()), s->d, SLOT (received ()));
} }
TRACE (stepCopy, "ends Disconnector::received()"); TRACE (stepCopy, "ends Disconnector::received()");
} }
Sender::Sender (Receiver *r, Disconnector *d) Sender::Sender (Receiver *r, Disconnector *d)
: QObject () : QObject ()
{ {
this->r = r; this->d = d; this->r = r; this->d = d;
if (r) if (r)
connect (this, SIGNAL (fired ()), r, SLOT (received ())); connect (this, SIGNAL (fired ()), r, SLOT (received ()));
if (d) if (d)
connect (this, SIGNAL (fired ()), d, SLOT (received ())); connect (this, SIGNAL (fired ()), d, SLOT (received ()));
}; };
void Sender::fire () void Sender::fire ()
{ {
::Step++; ::Step++;
const int stepCopy = ::Step; const int stepCopy = ::Step;
TRACE (stepCopy, "Sender::fire()"); TRACE (stepCopy, "Sender::fire()");
if (::Step != 1 && ::Step != 3) if (::Step != 1 && ::Step != 3)
qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step); qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);
emit fired (); emit fired ();
TRACE (stepCopy, "ends Sender::fire()"); TRACE (stepCopy, "ends Sender::fire()");
} }
int main (int argc, char *argv []) int main (int argc, char *argv [])
{ {
QCoreApplication app (argc, argv); QCoreApplication app (argc, argv);
Receiver r; Receiver r;
Disconnector d; Disconnector d;
Sender s (&r, &d); Sender s (&r, &d);
r.s = &s; r.s = &s;
d.s = &s; d.s = &s;
::Step = 0;
::Step = 0; s.fire ();
s.fire (); return 0;
return 0;
} }

View File

@ -54,50 +54,47 @@ class Receiver : public QObject
Q_OBJECT Q_OBJECT
public: public:
Receiver (); Receiver ();
virtual ~Receiver () {} virtual ~Receiver () {}
protected slots: protected slots:
void received (); void received ();
public: public:
Sender *s; Sender *s;
}; };
class Disconnector : public QObject class Disconnector : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Disconnector (); Disconnector ();
virtual ~Disconnector () {} virtual ~Disconnector () {}
protected slots: protected slots:
void received (); void received ();
public: public:
Sender *s; Sender *s;
}; };
class Sender : public QObject class Sender : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Sender (Receiver *r, Disconnector *d); Sender (Receiver *r, Disconnector *d);
virtual ~Sender () {} virtual ~Sender () {}
void fire (); void fire ();
signals: signals:
void fired (); void fired ();
public: public:
Receiver *r; Receiver *r;
Disconnector *d; Disconnector *d;
}; };
#endif // SIGNAL_BUG_H #endif // SIGNAL_BUG_H

View File

@ -173,16 +173,19 @@ class ReceiverObject : public QObject
Q_OBJECT Q_OBJECT
public: public:
ReceiverObject() : sequence_slot1( 0 ), ReceiverObject()
sequence_slot2( 0 ), : sequence_slot1( 0 )
sequence_slot3( 0 ), , sequence_slot2( 0 )
sequence_slot4( 0 ) {} , sequence_slot3( 0 )
, sequence_slot4( 0 )
{}
void reset() { void reset()
sequence_slot4 = 0; {
sequence_slot3 = 0; sequence_slot4 = 0;
sequence_slot2 = 0; sequence_slot3 = 0;
sequence_slot1 = 0; sequence_slot2 = 0;
sequence_slot1 = 0;
count_slot1 = 0; count_slot1 = 0;
count_slot2 = 0; count_slot2 = 0;
count_slot3 = 0; count_slot3 = 0;
@ -198,7 +201,8 @@ public:
int count_slot3; int count_slot3;
int count_slot4; int count_slot4;
bool called(int slot) { bool called(int slot)
{
switch (slot) { switch (slot) {
case 1: return sequence_slot1; case 1: return sequence_slot1;
case 2: return sequence_slot2; case 2: return sequence_slot2;
@ -759,13 +763,13 @@ public:
protected: protected:
void connectNotify( const char *signal ) void connectNotify( const char *signal )
{ {
org_signal = signal; org_signal = signal;
nw_signal = QMetaObject::normalizedSignature(signal); nw_signal = QMetaObject::normalizedSignature(signal);
}; };
void disconnectNotify( const char *signal ) void disconnectNotify( const char *signal )
{ {
org_signal = signal; org_signal = signal;
nw_signal = QMetaObject::normalizedSignature(signal); nw_signal = QMetaObject::normalizedSignature(signal);
}; };
}; };

View File

@ -189,7 +189,7 @@ public:
if (++timeoutsForFirst == 1) { if (++timeoutsForFirst == 1) {
killTimer(extraTimerId); killTimer(extraTimerId);
extraTimerId = -1; extraTimerId = -1;
QCoreApplication::postEvent(this, new QEvent(static_cast<QEvent::Type>(4002))); QCoreApplication::postEvent(this, new QEvent(static_cast<QEvent::Type>(4002)));
secondTimerId = startTimer(interval); secondTimerId = startTimer(interval);
} }
} else if (te->timerId() == secondTimerId) { } else if (te->timerId() == secondTimerId) {
@ -229,10 +229,10 @@ void tst_QTimer::livelock()
QCOMPARE(tester.timeoutsForExtra, 0); QCOMPARE(tester.timeoutsForExtra, 0);
QTRY_COMPARE(tester.timeoutsForSecond, 1); QTRY_COMPARE(tester.timeoutsForSecond, 1);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP) if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue); QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
#elif defined(Q_OS_WINCE) #elif defined(Q_OS_WINCE)
QEXPECT_FAIL("non-zero timer", "Windows CE devices often too slow", Continue); QEXPECT_FAIL("non-zero timer", "Windows CE devices often too slow", Continue);
#endif #endif
QVERIFY(tester.postEventAtRightTime); QVERIFY(tester.postEventAtRightTime);
} }

View File

@ -199,13 +199,12 @@ void tst_QLibrary::version()
VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion"); VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion");
QVERIFY(fnVersion); QVERIFY(fnVersion);
QCOMPARE(fnVersion(), resultversion); QCOMPARE(fnVersion(), resultversion);
QVERIFY(library.unload()); QVERIFY(library.unload());
#else #else
Q_UNUSED(lib); Q_UNUSED(lib);
Q_UNUSED(loadversion); Q_UNUSED(loadversion);
Q_UNUSED(resultversion); Q_UNUSED(resultversion);
#endif #endif
} }
void tst_QLibrary::load_data() void tst_QLibrary::load_data()
@ -242,10 +241,10 @@ void tst_QLibrary::load()
QLibrary library( lib ); QLibrary library( lib );
bool ok = library.load(); bool ok = library.load();
if ( result ) { if ( result ) {
QVERIFY( ok ); QVERIFY( ok );
QVERIFY(library.unload()); QVERIFY(library.unload());
} else { } else {
QVERIFY( !ok ); QVERIFY( !ok );
} }
} }
@ -273,9 +272,9 @@ void tst_QLibrary::unload()
library.load(); library.load();
bool ok = library.unload(); bool ok = library.unload();
if ( result ) { if ( result ) {
QVERIFY( ok ); QVERIFY( ok );
} else { } else {
QVERIFY( !ok ); QVERIFY( !ok );
} }
} }
@ -312,11 +311,11 @@ void tst_QLibrary::resolve()
QLibrary library( lib ); QLibrary library( lib );
testFunc func = (testFunc) library.resolve( symbol.toLatin1() ); testFunc func = (testFunc) library.resolve( symbol.toLatin1() );
if ( goodPointer ) { if ( goodPointer ) {
QVERIFY( func != 0 ); QVERIFY( func != 0 );
} else { } else {
QVERIFY( func == 0 ); QVERIFY( func == 0 );
} }
library.unload(); library.unload();
} }
void tst_QLibrary::library_data() void tst_QLibrary::library_data()
@ -435,7 +434,7 @@ void tst_QLibrary::errorString()
break; break;
} }
QRegExp re(errorString); QRegExp re(errorString);
QString libErrorString = lib.errorString(); QString libErrorString = lib.errorString();
QVERIFY(!lib.isLoaded() || lib.unload()); QVERIFY(!lib.isLoaded() || lib.unload());
QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString)); QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
QCOMPARE(ok, success); QCOMPARE(ok, success);
@ -489,7 +488,7 @@ void tst_QLibrary::loadHints()
bool ok = library.load(); bool ok = library.load();
if ( result ) { if ( result ) {
QVERIFY( ok ); QVERIFY( ok );
QVERIFY(library.unload()); QVERIFY(library.unload());
} else { } else {
QVERIFY( !ok ); QVERIFY( !ok );
} }
@ -539,29 +538,29 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QString lib = QDir::currentPath() + "/mylib"; QString lib = QDir::currentPath() + "/mylib";
{ {
QLibrary lib1(lib); QLibrary lib1(lib);
QLibrary lib2(lib); QLibrary lib2(lib);
QCOMPARE(lib1.isLoaded(), false); QCOMPARE(lib1.isLoaded(), false);
QCOMPARE(lib2.isLoaded(), false); QCOMPARE(lib2.isLoaded(), false);
lib1.load(); lib1.load();
QCOMPARE(lib1.isLoaded(), true); QCOMPARE(lib1.isLoaded(), true);
QCOMPARE(lib2.isLoaded(), true); QCOMPARE(lib2.isLoaded(), true);
QCOMPARE(lib1.unload(), true); QCOMPARE(lib1.unload(), true);
QCOMPARE(lib1.isLoaded(), false); QCOMPARE(lib1.isLoaded(), false);
QCOMPARE(lib2.isLoaded(), false); QCOMPARE(lib2.isLoaded(), false);
lib1.load(); lib1.load();
lib2.load(); lib2.load();
QCOMPARE(lib1.isLoaded(), true); QCOMPARE(lib1.isLoaded(), true);
QCOMPARE(lib2.isLoaded(), true); QCOMPARE(lib2.isLoaded(), true);
QCOMPARE(lib1.unload(), false); QCOMPARE(lib1.unload(), false);
QCOMPARE(lib1.isLoaded(), true); QCOMPARE(lib1.isLoaded(), true);
QCOMPARE(lib2.isLoaded(), true); QCOMPARE(lib2.isLoaded(), true);
QCOMPARE(lib2.unload(), true); QCOMPARE(lib2.unload(), true);
QCOMPARE(lib1.isLoaded(), false); QCOMPARE(lib1.isLoaded(), false);
QCOMPARE(lib2.isLoaded(), false); QCOMPARE(lib2.isLoaded(), false);
// Finally; unload on that is already unloaded // Finally; unload on that is already unloaded
QCOMPARE(lib1.unload(), false); QCOMPARE(lib1.unload(), false);
} }
//now let's try with a 3rd one that will go out of scope //now let's try with a 3rd one that will go out of scope
@ -570,9 +569,9 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
QCOMPARE(lib1.isLoaded(), false); QCOMPARE(lib1.isLoaded(), false);
lib1.load(); lib1.load();
QCOMPARE(lib1.isLoaded(), true); QCOMPARE(lib1.isLoaded(), true);
} }
QLibrary lib2(lib); QLibrary lib2(lib);
//lib2 should be loaded because lib1 was loaded and never unloaded //lib2 should be loaded because lib1 was loaded and never unloaded
QCOMPARE(lib2.isLoaded(), true); QCOMPARE(lib2.isLoaded(), true);
/* /*

View File

@ -314,16 +314,16 @@ public:
void run() void run()
{ {
test_mutex.lock(); test_mutex.lock();
mutex.lock(); mutex.lock();
for (int i = 0; i < iterations; ++i) { for (int i = 0; i < iterations; ++i) {
cond.wakeOne(); cond.wakeOne();
cond.wait(&mutex); cond.wait(&mutex);
} }
mutex.unlock(); mutex.unlock();
test_mutex.unlock(); test_mutex.unlock();
} }
}; };
@ -339,22 +339,22 @@ public:
void run() void run()
{ {
test_mutex.lock(); test_mutex.lock();
test_mutex.lock(); test_mutex.lock();
test_mutex.lock(); test_mutex.lock();
test_mutex.lock(); test_mutex.lock();
mutex.lock(); mutex.lock();
for (int i = 0; i < iterations; ++i) { for (int i = 0; i < iterations; ++i) {
cond.wakeOne(); cond.wakeOne();
cond.wait(&mutex); cond.wait(&mutex);
} }
mutex.unlock(); mutex.unlock();
test_mutex.unlock(); test_mutex.unlock();
test_mutex.unlock(); test_mutex.unlock();
test_mutex.unlock(); test_mutex.unlock();
test_mutex.unlock(); test_mutex.unlock();
} }
}; };
@ -368,60 +368,60 @@ void tst_QMutex::lock_unlock_locked_tryLock()
rmutex_Thread rthread(rmutex); rmutex_Thread rthread(rmutex);
for (int i = 0; i < iterations; ++i) { for (int i = 0; i < iterations; ++i) {
// normal mutex // normal mutex
QVERIFY(mutex.tryLock()); QVERIFY(mutex.tryLock());
mutex.unlock(); mutex.unlock();
thread.mutex.lock(); thread.mutex.lock();
thread.start(); thread.start();
for (int j = 0; j < iterations; ++j) { for (int j = 0; j < iterations; ++j) {
QVERIFY(thread.cond.wait(&thread.mutex, 10000)); QVERIFY(thread.cond.wait(&thread.mutex, 10000));
QVERIFY(!mutex.tryLock()); QVERIFY(!mutex.tryLock());
thread.cond.wakeOne(); thread.cond.wakeOne();
} }
thread.mutex.unlock(); thread.mutex.unlock();
QVERIFY(thread.wait(10000)); QVERIFY(thread.wait(10000));
QVERIFY(mutex.tryLock()); QVERIFY(mutex.tryLock());
mutex.unlock(); mutex.unlock();
// recursive mutex // recursive mutex
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
rthread.mutex.lock(); rthread.mutex.lock();
rthread.start(); rthread.start();
for (int k = 0; k < iterations; ++k) { for (int k = 0; k < iterations; ++k) {
QVERIFY(rthread.cond.wait(&rthread.mutex, 10000)); QVERIFY(rthread.cond.wait(&rthread.mutex, 10000));
QVERIFY(!rmutex.tryLock()); QVERIFY(!rmutex.tryLock());
rthread.cond.wakeOne(); rthread.cond.wakeOne();
} }
rthread.mutex.unlock(); rthread.mutex.unlock();
QVERIFY(rthread.wait(10000)); QVERIFY(rthread.wait(10000));
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
QVERIFY(rmutex.tryLock()); QVERIFY(rmutex.tryLock());
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
rmutex.unlock(); rmutex.unlock();
} }
} }

View File

@ -70,12 +70,12 @@ public:
protected: protected:
void run() void run()
{ {
int i = 0; int i = 0;
while ( i < 100 ) { while ( i < 100 ) {
semaphore->acquire(); semaphore->acquire();
i++; i++;
semaphore->release(); semaphore->release();
} }
} }
}; };
@ -89,12 +89,12 @@ public:
protected: protected:
void run() void run()
{ {
int i = 0; int i = 0;
while ( i < 100 ) { while ( i < 100 ) {
semaphore->acquire(N); semaphore->acquire(N);
i++; i++;
semaphore->release(N); semaphore->release(N);
} }
} }
}; };

View File

@ -544,7 +544,7 @@ ostream &operator<<(ostream &out, const StableSortTest& obj) { out << obj.Major
QVector<StableSortTest> createStableTestVector() QVector<StableSortTest> createStableTestVector()
{ {
QVector<StableSortTest> stableTestVector; QVector<StableSortTest> stableTestVector;
for (int i=500; i>=0; --i) { for (int i=500; i>=0; --i) {
for (int j=0; j<10; ++j) { for (int j=0; j<10; ++j) {
stableTestVector.append(StableSortTest(i, j)); stableTestVector.append(StableSortTest(i, j));
} }

View File

@ -138,11 +138,11 @@ void tst_QBitArray::size()
a.fill(1); a.fill(1);
int len = a.size(); int len = a.size();
for (int j=0; j<len; j++) { for (int j=0; j<len; j++) {
bool b = a[j]; bool b = a[j];
if (b) if (b)
S+= "1"; S+= "1";
else else
S+= "0"; S+= "0";
} }
QTEST(S,"res"); QTEST(S,"res");
} }

View File

@ -161,11 +161,11 @@ void tst_QByteArray::qCompress_data()
int i; int i;
for ( i=0; i<size1; i++ ) for ( i=0; i<size1; i++ )
ba1[i] = (char)( i / 1024 ); ba1[i] = (char)( i / 1024 );
QTest::newRow( "01" ) << ba1; QTest::newRow( "01" ) << ba1;
for ( i=0; i<size1; i++ ) for ( i=0; i<size1; i++ )
ba1[i] = (char)( i % 256 ); ba1[i] = (char)( i % 256 );
QTest::newRow( "02" ) << ba1; QTest::newRow( "02" ) << ba1;
ba1.fill( 'A' ); ba1.fill( 'A' );
@ -403,8 +403,7 @@ void tst_QByteArray::split_data()
QTest::addColumn<QByteArray>("sample"); QTest::addColumn<QByteArray>("sample");
QTest::addColumn<int>("size"); QTest::addColumn<int>("size");
QTest::newRow("1") << QByteArray("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile") QTest::newRow("1") << QByteArray("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile") << 14;
<< 14;
QTest::newRow("2") << QByteArray("abcde") << 1; QTest::newRow("2") << QByteArray("abcde") << 1;
QTest::newRow("one empty") << QByteArray("") << 1; QTest::newRow("one empty") << QByteArray("") << 1;
QTest::newRow("two empty") << QByteArray(" ") << 2; QTest::newRow("two empty") << QByteArray(" ") << 2;
@ -956,31 +955,31 @@ void tst_QByteArray::lastIndexOf()
if (!hasNull) if (!hasNull)
QCOMPARE( haystack.lastIndexOf(needle.data(), startpos), expected ); QCOMPARE( haystack.lastIndexOf(needle.data(), startpos), expected );
if (needle.size() == 1) if (needle.size() == 1)
QCOMPARE( haystack.lastIndexOf(needle.at(0), startpos), expected ); QCOMPARE( haystack.lastIndexOf(needle.at(0), startpos), expected );
if (startpos == -1) { if (startpos == -1) {
QCOMPARE( haystack.lastIndexOf(needle), expected ); QCOMPARE( haystack.lastIndexOf(needle), expected );
if (!hasNull) if (!hasNull)
QCOMPARE( haystack.lastIndexOf(needle.data()), expected ); QCOMPARE( haystack.lastIndexOf(needle.data()), expected );
if (needle.size() == 1) if (needle.size() == 1)
QCOMPARE( haystack.lastIndexOf(needle.at(0)), expected ); QCOMPARE( haystack.lastIndexOf(needle.at(0)), expected );
} }
} }
void tst_QByteArray::number() void tst_QByteArray::number()
{ {
QCOMPARE(QString(QByteArray::number((quint64) 0)), QCOMPARE(QString(QByteArray::number((quint64) 0)),
QString(QByteArray("0"))); QString(QByteArray("0")));
QCOMPARE(QString(QByteArray::number(Q_UINT64_C(0xFFFFFFFFFFFFFFFF))), QCOMPARE(QString(QByteArray::number(Q_UINT64_C(0xFFFFFFFFFFFFFFFF))),
QString(QByteArray("18446744073709551615"))); QString(QByteArray("18446744073709551615")));
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0xFFFFFFFFFFFFFFFF))), QCOMPARE(QString(QByteArray::number(Q_INT64_C(0xFFFFFFFFFFFFFFFF))),
QString(QByteArray("-1"))); QString(QByteArray("-1")));
QCOMPARE(QString(QByteArray::number(qint64(0))), QCOMPARE(QString(QByteArray::number(qint64(0))),
QString(QByteArray("0"))); QString(QByteArray("0")));
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x7FFFFFFFFFFFFFFF))), QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x7FFFFFFFFFFFFFFF))),
QString(QByteArray("9223372036854775807"))); QString(QByteArray("9223372036854775807")));
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x8000000000000000))), QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x8000000000000000))),
QString(QByteArray("-9223372036854775808"))); QString(QByteArray("-9223372036854775808")));
} }
// defined later // defined later

View File

@ -97,20 +97,20 @@ public:
// qDebug("creating MyClass count=%d", count); // qDebug("creating MyClass count=%d", count);
} }
MyClass( const QString& c) { MyClass( const QString& c) {
count++; str = c; count++; str = c;
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count); // qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
} }
~MyClass() { ~MyClass() {
count--; count--;
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count); // qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
} }
MyClass( const MyClass& c ) { MyClass( const MyClass& c ) {
count++; str = c.str; count++; str = c.str;
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count); // qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
} }
MyClass &operator =(const MyClass &o) { MyClass &operator =(const MyClass &o) {
// qDebug("copying MyClass '%s'", o.str.latin1()); // qDebug("copying MyClass '%s'", o.str.latin1());
str = o.str; return *this; str = o.str; return *this;
} }
QString str; QString str;
@ -125,145 +125,145 @@ typedef QHash<QString, MyClass> MyMap;
void tst_QHash::count() void tst_QHash::count()
{ {
{ {
MyMap map; MyMap map;
MyMap map2( map ); MyMap map2( map );
QCOMPARE( map.count(), 0 ); QCOMPARE( map.count(), 0 );
QCOMPARE( map2.count(), 0 ); QCOMPARE( map2.count(), 0 );
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
// detach // detach
map2["Hallo"] = MyClass( "Fritz" ); map2["Hallo"] = MyClass( "Fritz" );
QCOMPARE( map.count(), 0 ); QCOMPARE( map.count(), 0 );
QCOMPARE( map2.count(), 1 ); QCOMPARE( map2.count(), 1 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 1 ); QCOMPARE( MyClass::count, 1 );
#endif #endif
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
{ {
typedef QHash<QString, MyClass> Map; typedef QHash<QString, MyClass> Map;
Map map; Map map;
QCOMPARE( map.count(), 0); QCOMPARE( map.count(), 0);
map.insert( "Torben", MyClass("Weis") ); map.insert( "Torben", MyClass("Weis") );
QCOMPARE( map.count(), 1 ); QCOMPARE( map.count(), 1 );
map.insert( "Claudia", MyClass("Sorg") ); map.insert( "Claudia", MyClass("Sorg") );
QCOMPARE( map.count(), 2 ); QCOMPARE( map.count(), 2 );
map.insert( "Lars", MyClass("Linzbach") ); map.insert( "Lars", MyClass("Linzbach") );
map.insert( "Matthias", MyClass("Ettrich") ); map.insert( "Matthias", MyClass("Ettrich") );
map.insert( "Sue", MyClass("Paludo") ); map.insert( "Sue", MyClass("Paludo") );
map.insert( "Eirik", MyClass("Eng") ); map.insert( "Eirik", MyClass("Eng") );
map.insert( "Haavard", MyClass("Nord") ); map.insert( "Haavard", MyClass("Nord") );
map.insert( "Arnt", MyClass("Gulbrandsen") ); map.insert( "Arnt", MyClass("Gulbrandsen") );
map.insert( "Paul", MyClass("Tvete") ); map.insert( "Paul", MyClass("Tvete") );
QCOMPARE( map.count(), 9 ); QCOMPARE( map.count(), 9 );
map.insert( "Paul", MyClass("Tvete 1") ); map.insert( "Paul", MyClass("Tvete 1") );
map.insert( "Paul", MyClass("Tvete 2") ); map.insert( "Paul", MyClass("Tvete 2") );
map.insert( "Paul", MyClass("Tvete 3") ); map.insert( "Paul", MyClass("Tvete 3") );
map.insert( "Paul", MyClass("Tvete 4") ); map.insert( "Paul", MyClass("Tvete 4") );
map.insert( "Paul", MyClass("Tvete 5") ); map.insert( "Paul", MyClass("Tvete 5") );
map.insert( "Paul", MyClass("Tvete 6") ); map.insert( "Paul", MyClass("Tvete 6") );
QCOMPARE( map.count(), 9 ); QCOMPARE( map.count(), 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
Map map2( map ); Map map2( map );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.insert( "Kay", MyClass("Roemer") ); map2.insert( "Kay", MyClass("Roemer") );
QVERIFY( map2.count() == 10 ); QVERIFY( map2.count() == 10 );
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 ); QCOMPARE( MyClass::count, 19 );
#endif #endif
map2 = map; map2 = map;
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.insert( "Kay", MyClass("Roemer") ); map2.insert( "Kay", MyClass("Roemer") );
QVERIFY( map2.count() == 10 ); QVERIFY( map2.count() == 10 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 ); QCOMPARE( MyClass::count, 19 );
#endif #endif
map2.clear(); map2.clear();
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2 = map; map2 = map;
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.clear(); map2.clear();
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map.remove( "Lars" ); map.remove( "Lars" );
QVERIFY( map.count() == 8 ); QVERIFY( map.count() == 8 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 ); QCOMPARE( MyClass::count, 8 );
#endif #endif
map.remove( "Mist" ); map.remove( "Mist" );
QVERIFY( map.count() == 8 ); QVERIFY( map.count() == 8 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 ); QCOMPARE( MyClass::count, 8 );
#endif #endif
} }
QVERIFY( MyClass::count == 0 ); QVERIFY( MyClass::count == 0 );
{ {
typedef QHash<QString,MyClass> Map; typedef QHash<QString,MyClass> Map;
Map map; Map map;
map["Torben"] = MyClass("Weis"); map["Torben"] = MyClass("Weis");
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 1 ); QVERIFY( MyClass::count == 1 );
#endif #endif
QVERIFY( map.count() == 1 ); QVERIFY( map.count() == 1 );
(void)map["Torben"].str; (void)map["Torben"].str;
(void)map["Lars"].str; (void)map["Lars"].str;
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 ); QVERIFY( MyClass::count == 2 );
#endif #endif
QVERIFY( map.count() == 2 ); QVERIFY( map.count() == 2 );
const Map& cmap = map; const Map& cmap = map;
(void)cmap["Depp"].str; (void)cmap["Depp"].str;
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 ); QVERIFY( MyClass::count == 2 );
#endif #endif
QVERIFY( map.count() == 2 ); QVERIFY( map.count() == 2 );
QVERIFY( cmap.count() == 2 ); QVERIFY( cmap.count() == 2 );
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
{ {
for ( int i = 0; i < 100; ++i ) for ( int i = 0; i < 100; ++i )
{ {
QHash<int, MyClass> map; QHash<int, MyClass> map;
for (int j = 0; j < i; ++j) for (int j = 0; j < i; ++j)
map.insert(j, MyClass(QString::number(j))); map.insert(j, MyClass(QString::number(j)));
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
} }
@ -334,9 +334,9 @@ void tst_QHash::insert1()
QVERIFY(hash2[2] == world); QVERIFY(hash2[2] == world);
hash[1] = hash[1]; hash[1] = hash[1];
QVERIFY(hash[1] == hello); QVERIFY(hash[1] == hello);
} }
{ {
Hash hash2 = hash; Hash hash2 = hash;
hash2.detach(); hash2.detach();
hash2.remove(1); hash2.remove(1);
@ -464,8 +464,8 @@ void tst_QHash::erase()
it1 = h1.begin(); it1 = h1.begin();
int n = 0; int n = 0;
while (it1 != h1.end()) { while (it1 != h1.end()) {
it1 = h1.erase(it1); it1 = h1.erase(it1);
++n; ++n;
} }
QVERIFY(n == 3); QVERIFY(n == 3);
QHash<int, int> h2; QHash<int, int> h2;
@ -562,17 +562,17 @@ void tst_QHash::swap()
void tst_QHash::clear() void tst_QHash::clear()
{ {
{ {
MyMap map; MyMap map;
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
map.insert( "key", MyClass( "value" ) ); map.insert( "key", MyClass( "value" ) );
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
map.insert( "key0", MyClass( "value0" ) ); map.insert( "key0", MyClass( "value0" ) );
map.insert( "key0", MyClass( "value1" ) ); map.insert( "key0", MyClass( "value1" ) );
map.insert( "key1", MyClass( "value2" ) ); map.insert( "key1", MyClass( "value2" ) );
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
} }
QCOMPARE( MyClass::count, int(0) ); QCOMPARE( MyClass::count, int(0) );
} }

View File

@ -59,7 +59,7 @@
#include <windows.h> // needed for GetUserDefaultLCID #include <windows.h> // needed for GetUserDefaultLCID
#define _control87 _controlfp #define _control87 _controlfp
extern "C" DWORD GetThreadLocale(void) { extern "C" DWORD GetThreadLocale(void) {
return GetUserDefaultLCID(); return GetUserDefaultLCID();
} }
#endif #endif
@ -162,16 +162,16 @@ void tst_QLocale::ctor()
QLocale::countryToString(default_country).toLatin1().constData()); QLocale::countryToString(default_country).toLatin1().constData());
{ {
QLocale l; QLocale l;
QVERIFY(l.language() == default_lang); QVERIFY(l.language() == default_lang);
QVERIFY(l.country() == default_country); QVERIFY(l.country() == default_country);
} }
#define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \ #define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \
{ \ { \
QLocale l(QLocale::req_lang, QLocale::req_country); \ QLocale l(QLocale::req_lang, QLocale::req_country); \
QCOMPARE(l.language(), exp_lang); \ QCOMPARE(l.language(), exp_lang); \
QCOMPARE(l.country(), exp_country); \ QCOMPARE(l.country(), exp_country); \
} }
{ {
QLocale l(QLocale::C, QLocale::AnyCountry); QLocale l(QLocale::C, QLocale::AnyCountry);
@ -195,9 +195,9 @@ void tst_QLocale::ctor()
QLocale::setDefault(QLocale(QLocale::English, QLocale::France)); QLocale::setDefault(QLocale(QLocale::English, QLocale::France));
{ {
QLocale l; QLocale l;
QVERIFY(l.language() == QLocale::English); QVERIFY(l.language() == QLocale::English);
QVERIFY(l.country() == QLocale::UnitedStates); QVERIFY(l.country() == QLocale::UnitedStates);
} }
TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(French, France, QLocale::French, QLocale::France)
@ -211,9 +211,9 @@ void tst_QLocale::ctor()
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
{ {
QLocale l; QLocale l;
QVERIFY(l.language() == QLocale::English); QVERIFY(l.language() == QLocale::English);
QVERIFY(l.country() == QLocale::UnitedKingdom); QVERIFY(l.country() == QLocale::UnitedKingdom);
} }
TEST_CTOR(French, France, QLocale::French, QLocale::France) TEST_CTOR(French, France, QLocale::French, QLocale::France)
@ -225,9 +225,9 @@ void tst_QLocale::ctor()
QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::France)); QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::France));
{ {
QLocale l; QLocale l;
QVERIFY(l.language() == QLocale::English); QVERIFY(l.language() == QLocale::English);
QVERIFY(l.country() == QLocale::UnitedKingdom); QVERIFY(l.country() == QLocale::UnitedKingdom);
} }
TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom) TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom)
@ -245,12 +245,11 @@ void tst_QLocale::ctor()
QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::AnyCountry)); QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::AnyCountry));
{ {
QLocale l; QLocale l;
QVERIFY(l.language() == QLocale::English); QVERIFY(l.language() == QLocale::English);
QVERIFY(l.country() == QLocale::UnitedKingdom); QVERIFY(l.country() == QLocale::UnitedKingdom);
} }
TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom) TEST_CTOR(Aymara, AnyCountry, QLocale::English, QLocale::UnitedKingdom)
TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom) TEST_CTOR(Aymara, France, QLocale::English, QLocale::UnitedKingdom)
@ -280,12 +279,12 @@ void tst_QLocale::ctor()
#define TEST_CTOR(req_lc, exp_lang, exp_country) \ #define TEST_CTOR(req_lc, exp_lang, exp_country) \
{ \ { \
QLocale l(req_lc); \ QLocale l(req_lc); \
QVERIFY2(l.language() == QLocale::exp_lang \ QVERIFY2(l.language() == QLocale::exp_lang \
&& l.country() == QLocale::exp_country, \ && l.country() == QLocale::exp_country, \
QString("requested: \"" + QString(req_lc) + "\", got: " \ QString("requested: \"" + QString(req_lc) + "\", got: " \
+ QLocale::languageToString(l.language()) \ + QLocale::languageToString(l.language()) \
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \ + "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
} }
QLocale::setDefault(QLocale(QLocale::C)); QLocale::setDefault(QLocale(QLocale::C));
@ -442,8 +441,8 @@ void tst_QLocale::unixLocaleName()
{ {
#define TEST_NAME(req_lang, req_country, exp_name) \ #define TEST_NAME(req_lang, req_country, exp_name) \
{ \ { \
QLocale l(QLocale::req_lang, QLocale::req_country); \ QLocale l(QLocale::req_lang, QLocale::req_country); \
QCOMPARE(l.name(), QString(exp_name)); \ QCOMPARE(l.name(), QString(exp_name)); \
} }
QLocale::setDefault(QLocale(QLocale::C)); QLocale::setDefault(QLocale(QLocale::C));
@ -463,112 +462,112 @@ void tst_QLocale::double_conversion_data()
QTest::addColumn<bool>("good"); QTest::addColumn<bool>("good");
QTest::addColumn<double>("num"); QTest::addColumn<double>("num");
QTest::newRow("C 1") << QString("C") << QString("1") << true << 1.0; QTest::newRow("C 1") << QString("C") << QString("1") << true << 1.0;
QTest::newRow("C 1.0") << QString("C") << QString("1.0") << true << 1.0; QTest::newRow("C 1.0") << QString("C") << QString("1.0") << true << 1.0;
QTest::newRow("C 1.234") << QString("C") << QString("1.234") << true << 1.234; QTest::newRow("C 1.234") << QString("C") << QString("1.234") << true << 1.234;
QTest::newRow("C 1.234e-10") << QString("C") << QString("1.234e-10") << true << 1.234e-10; QTest::newRow("C 1.234e-10") << QString("C") << QString("1.234e-10") << true << 1.234e-10;
QTest::newRow("C 1.234E10") << QString("C") << QString("1.234E10") << true << 1.234e10; QTest::newRow("C 1.234E10") << QString("C") << QString("1.234E10") << true << 1.234e10;
QTest::newRow("C 1e10") << QString("C") << QString("1e10") << true << 1.0e10; QTest::newRow("C 1e10") << QString("C") << QString("1e10") << true << 1.0e10;
QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0; QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0;
QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0; QTest::newRow("C 1") << QString("C") << QString(" 1") << true << 1.0;
QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0; QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0;
QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0; QTest::newRow("C 1 ") << QString("C") << QString("1 ") << true << 1.0;
QTest::newRow("C 1,") << QString("C") << QString("1,") << false << 0.0; QTest::newRow("C 1,") << QString("C") << QString("1,") << false << 0.0;
QTest::newRow("C 1,2") << QString("C") << QString("1,2") << false << 0.0; QTest::newRow("C 1,2") << QString("C") << QString("1,2") << false << 0.0;
QTest::newRow("C 1,23") << QString("C") << QString("1,23") << false << 0.0; QTest::newRow("C 1,23") << QString("C") << QString("1,23") << false << 0.0;
QTest::newRow("C 1,234") << QString("C") << QString("1,234") << true << 1234.0; QTest::newRow("C 1,234") << QString("C") << QString("1,234") << true << 1234.0;
QTest::newRow("C 1,234,") << QString("C") << QString("1,234,") << false << 0.0; QTest::newRow("C 1,234,") << QString("C") << QString("1,234,") << false << 0.0;
QTest::newRow("C 1,234,5") << QString("C") << QString("1,234,5") << false << 0.0; QTest::newRow("C 1,234,5") << QString("C") << QString("1,234,5") << false << 0.0;
QTest::newRow("C 1,234,56") << QString("C") << QString("1,234,56") << false << 0.0; QTest::newRow("C 1,234,56") << QString("C") << QString("1,234,56") << false << 0.0;
QTest::newRow("C 1,234,567") << QString("C") << QString("1,234,567") << true << 1234567.0; QTest::newRow("C 1,234,567") << QString("C") << QString("1,234,567") << true << 1234567.0;
QTest::newRow("C 1,234,567.") << QString("C") << QString("1,234,567.") << true << 1234567.0; QTest::newRow("C 1,234,567.") << QString("C") << QString("1,234,567.") << true << 1234567.0;
QTest::newRow("C 1,234,567.8") << QString("C") << QString("1,234,567.8")<< true << 1234567.8; QTest::newRow("C 1,234,567.8") << QString("C") << QString("1,234,567.8") << true << 1234567.8;
QTest::newRow("C 1,234567.8") << QString("C") << QString("1,234567.8") << false << 0.0; QTest::newRow("C 1,234567.8") << QString("C") << QString("1,234567.8") << false << 0.0;
QTest::newRow("C 12,34567.8") << QString("C") << QString("12,34567.8") << false << 0.0; QTest::newRow("C 12,34567.8") << QString("C") << QString("12,34567.8") << false << 0.0;
QTest::newRow("C 1234,567.8") << QString("C") << QString("1234,567.8") << false << 0.0; QTest::newRow("C 1234,567.8") << QString("C") << QString("1234,567.8") << false << 0.0;
QTest::newRow("C 1234567.8") << QString("C") << QString("1234567.8") << true << 1234567.8; QTest::newRow("C 1234567.8") << QString("C") << QString("1234567.8") << true << 1234567.8;
QTest::newRow("C ,") << QString("C") << QString(",") << false << 0.0; QTest::newRow("C ,") << QString("C") << QString(",") << false << 0.0;
QTest::newRow("C ,123") << QString("C") << QString(",123") << false << 0.0; QTest::newRow("C ,123") << QString("C") << QString(",123") << false << 0.0;
QTest::newRow("C ,3") << QString("C") << QString(",3") << false << 0.0; QTest::newRow("C ,3") << QString("C") << QString(",3") << false << 0.0;
QTest::newRow("C , 3") << QString("C") << QString(", 3") << false << 0.0; QTest::newRow("C , 3") << QString("C") << QString(", 3") << false << 0.0;
QTest::newRow("C , 3") << QString("C") << QString(", 3") << false << 0.0; QTest::newRow("C , 3") << QString("C") << QString(", 3") << false << 0.0;
QTest::newRow("C , 3.2") << QString("C") << QString(", 3.2") << false << 0.0; QTest::newRow("C , 3.2") << QString("C") << QString(", 3.2") << false << 0.0;
QTest::newRow("C , 3.2e2") << QString("C") << QString(", 3.2e2") << false << 0.0; QTest::newRow("C , 3.2e2") << QString("C") << QString(", 3.2e2") << false << 0.0;
QTest::newRow("C , e2") << QString("C") << QString(", e2") << false << 0.0; QTest::newRow("C , e2") << QString("C") << QString(", e2") << false << 0.0;
QTest::newRow("C 1,,234") << QString("C") << QString("1,,234") << false << 0.0; QTest::newRow("C 1,,234") << QString("C") << QString("1,,234") << false << 0.0;
QTest::newRow("C empty") << QString("C") << QString("") << false << 0.0; QTest::newRow("C empty") << QString("C") << QString("") << false << 0.0;
QTest::newRow("C null") << QString("C") << QString() << false << 0.0; QTest::newRow("C null") << QString("C") << QString() << false << 0.0;
QTest::newRow("C .") << QString("C") << QString(".") << false << 0.0; QTest::newRow("C .") << QString("C") << QString(".") << false << 0.0;
QTest::newRow("C 1e") << QString("C") << QString("1e") << false << 0.0; QTest::newRow("C 1e") << QString("C") << QString("1e") << false << 0.0;
QTest::newRow("C 1,0") << QString("C") << QString("1,0") << false << 0.0; QTest::newRow("C 1,0") << QString("C") << QString("1,0") << false << 0.0;
QTest::newRow("C 1,000") << QString("C") << QString("1,000") << true << 1000.0; QTest::newRow("C 1,000") << QString("C") << QString("1,000") << true << 1000.0;
QTest::newRow("C 1,000e-6") << QString("C") << QString("1,000e-6") << true << 1000.0e-6; QTest::newRow("C 1,000e-6") << QString("C") << QString("1,000e-6") << true << 1000.0e-6;
QTest::newRow("C 1e1.0") << QString("C") << QString("1e1.0") << false << 0.0; QTest::newRow("C 1e1.0") << QString("C") << QString("1e1.0") << false << 0.0;
QTest::newRow("C 1e+") << QString("C") << QString("1e+") << false << 0.0; QTest::newRow("C 1e+") << QString("C") << QString("1e+") << false << 0.0;
QTest::newRow("C 1e-") << QString("C") << QString("1e-") << false << 0.0; QTest::newRow("C 1e-") << QString("C") << QString("1e-") << false << 0.0;
QTest::newRow("C .1") << QString("C") << QString(".1") << true << 0.1; QTest::newRow("C .1") << QString("C") << QString(".1") << true << 0.1;
QTest::newRow("C -.1") << QString("C") << QString("-.1") << true << -0.1; QTest::newRow("C -.1") << QString("C") << QString("-.1") << true << -0.1;
QTest::newRow("C 1.") << QString("C") << QString("1.") << true << 1.0; QTest::newRow("C 1.") << QString("C") << QString("1.") << true << 1.0;
QTest::newRow("C 1.E10") << QString("C") << QString("1.E10") << true << 1.0e10; QTest::newRow("C 1.E10") << QString("C") << QString("1.E10") << true << 1.0e10;
QTest::newRow("C 1e+10") << QString("C") << QString("1e+10") << true << 1.0e+10; QTest::newRow("C 1e+10") << QString("C") << QString("1e+10") << true << 1.0e+10;
QTest::newRow("de_DE 1.") << QString("de_DE") << QString("1.") << false << 0.0; QTest::newRow("de_DE 1.") << QString("de_DE") << QString("1.") << false << 0.0;
QTest::newRow("de_DE 1.2") << QString("de_DE") << QString("1.2") << false << 0.0; QTest::newRow("de_DE 1.2") << QString("de_DE") << QString("1.2") << false << 0.0;
QTest::newRow("de_DE 1.23") << QString("de_DE") << QString("1.23") << false << 0.0; QTest::newRow("de_DE 1.23") << QString("de_DE") << QString("1.23") << false << 0.0;
QTest::newRow("de_DE 1.234") << QString("de_DE") << QString("1.234") << true << 1234.0; QTest::newRow("de_DE 1.234") << QString("de_DE") << QString("1.234") << true << 1234.0;
QTest::newRow("de_DE 1.234,") << QString("de_DE") << QString("1.234.") << false << 0.0; QTest::newRow("de_DE 1.234,") << QString("de_DE") << QString("1.234.") << false << 0.0;
QTest::newRow("de_DE 1.234.5") << QString("de_DE") << QString("1.234.5") << false << 0.0; QTest::newRow("de_DE 1.234.5") << QString("de_DE") << QString("1.234.5") << false << 0.0;
QTest::newRow("de_DE 1.234.56") << QString("de_DE") << QString("1.234.56") << false << 0.0; QTest::newRow("de_DE 1.234.56") << QString("de_DE") << QString("1.234.56") << false << 0.0;
QTest::newRow("de_DE 1.234.567") << QString("de_DE") << QString("1.234.567") << true << 1234567.0; QTest::newRow("de_DE 1.234.567") << QString("de_DE") << QString("1.234.567") << true << 1234567.0;
QTest::newRow("de_DE 1.234.567,") << QString("de_DE") << QString("1.234.567,") << true << 1234567.0; QTest::newRow("de_DE 1.234.567,") << QString("de_DE") << QString("1.234.567,") << true << 1234567.0;
QTest::newRow("de_DE 1.234.567,8") << QString("de_DE") << QString("1.234.567,8")<< true << 1234567.8; QTest::newRow("de_DE 1.234.567,8") << QString("de_DE") << QString("1.234.567,8") << true << 1234567.8;
QTest::newRow("de_DE 1.234567,8") << QString("de_DE") << QString("1.234567,8") << false << 0.0; QTest::newRow("de_DE 1.234567,8") << QString("de_DE") << QString("1.234567,8") << false << 0.0;
QTest::newRow("de_DE 12.34567,8") << QString("de_DE") << QString("12.34567,8") << false << 0.0; QTest::newRow("de_DE 12.34567,8") << QString("de_DE") << QString("12.34567,8") << false << 0.0;
QTest::newRow("de_DE 1234.567,8") << QString("de_DE") << QString("1234.567,8") << false << 0.0; QTest::newRow("de_DE 1234.567,8") << QString("de_DE") << QString("1234.567,8") << false << 0.0;
QTest::newRow("de_DE 1234567,8") << QString("de_DE") << QString("1234567,8") << true << 1234567.8; QTest::newRow("de_DE 1234567,8") << QString("de_DE") << QString("1234567,8") << true << 1234567.8;
QTest::newRow("de_DE .123") << QString("de_DE") << QString(".123") << false << 0.0; QTest::newRow("de_DE .123") << QString("de_DE") << QString(".123") << false << 0.0;
QTest::newRow("de_DE .3") << QString("de_DE") << QString(".3") << false << 0.0; QTest::newRow("de_DE .3") << QString("de_DE") << QString(".3") << false << 0.0;
QTest::newRow("de_DE . 3") << QString("de_DE") << QString(". 3") << false << 0.0; QTest::newRow("de_DE . 3") << QString("de_DE") << QString(". 3") << false << 0.0;
QTest::newRow("de_DE . 3") << QString("de_DE") << QString(". 3") << false << 0.0; QTest::newRow("de_DE . 3") << QString("de_DE") << QString(". 3") << false << 0.0;
QTest::newRow("de_DE . 3,2") << QString("de_DE") << QString(". 3,2") << false << 0.0; QTest::newRow("de_DE . 3,2") << QString("de_DE") << QString(". 3,2") << false << 0.0;
QTest::newRow("de_DE . 3,2e2") << QString("de_DE") << QString(". 3,2e2") << false << 0.0; QTest::newRow("de_DE . 3,2e2") << QString("de_DE") << QString(". 3,2e2") << false << 0.0;
QTest::newRow("de_DE . e2") << QString("de_DE") << QString(". e2") << false << 0.0; QTest::newRow("de_DE . e2") << QString("de_DE") << QString(". e2") << false << 0.0;
QTest::newRow("de_DE 1..234") << QString("de_DE") << QString("1..234") << false << 0.0; QTest::newRow("de_DE 1..234") << QString("de_DE") << QString("1..234") << false << 0.0;
QTest::newRow("de_DE 1") << QString("de_DE") << QString("1") << true << 1.0; QTest::newRow("de_DE 1") << QString("de_DE") << QString("1") << true << 1.0;
QTest::newRow("de_DE 1.0") << QString("de_DE") << QString("1.0") << false << 0.0; QTest::newRow("de_DE 1.0") << QString("de_DE") << QString("1.0") << false << 0.0;
QTest::newRow("de_DE 1.234e-10") << QString("de_DE") << QString("1.234e-10") << true << 1234.0e-10; QTest::newRow("de_DE 1.234e-10") << QString("de_DE") << QString("1.234e-10") << true << 1234.0e-10;
QTest::newRow("de_DE 1.234E10") << QString("de_DE") << QString("1.234E10") << true << 1234.0e10; QTest::newRow("de_DE 1.234E10") << QString("de_DE") << QString("1.234E10") << true << 1234.0e10;
QTest::newRow("de_DE 1e10") << QString("de_DE") << QString("1e10") << true << 1.0e10; QTest::newRow("de_DE 1e10") << QString("de_DE") << QString("1e10") << true << 1.0e10;
QTest::newRow("de_DE .1") << QString("de_DE") << QString(".1") << false << 0.0; QTest::newRow("de_DE .1") << QString("de_DE") << QString(".1") << false << 0.0;
QTest::newRow("de_DE -.1") << QString("de_DE") << QString("-.1") << false << 0.0; QTest::newRow("de_DE -.1") << QString("de_DE") << QString("-.1") << false << 0.0;
QTest::newRow("de_DE 1.E10") << QString("de_DE") << QString("1.E10") << false << 0.0; QTest::newRow("de_DE 1.E10") << QString("de_DE") << QString("1.E10") << false << 0.0;
QTest::newRow("de_DE 1e+10") << QString("de_DE") << QString("1e+10") << true << 1.0e+10; QTest::newRow("de_DE 1e+10") << QString("de_DE") << QString("1e+10") << true << 1.0e+10;
QTest::newRow("de_DE 1,0") << QString("de_DE") << QString("1,0") << true << 1.0; QTest::newRow("de_DE 1,0") << QString("de_DE") << QString("1,0") << true << 1.0;
QTest::newRow("de_DE 1,234") << QString("de_DE") << QString("1,234") << true << 1.234; QTest::newRow("de_DE 1,234") << QString("de_DE") << QString("1,234") << true << 1.234;
QTest::newRow("de_DE 1,234e-10") << QString("de_DE") << QString("1,234e-10") << true << 1.234e-10; QTest::newRow("de_DE 1,234e-10") << QString("de_DE") << QString("1,234e-10") << true << 1.234e-10;
QTest::newRow("de_DE 1,234E10") << QString("de_DE") << QString("1,234E10") << true << 1.234e10; QTest::newRow("de_DE 1,234E10") << QString("de_DE") << QString("1,234E10") << true << 1.234e10;
QTest::newRow("de_DE ,1") << QString("de_DE") << QString(",1") << true << 0.1; QTest::newRow("de_DE ,1") << QString("de_DE") << QString(",1") << true << 0.1;
QTest::newRow("de_DE -,1") << QString("de_DE") << QString("-,1") << true << -0.1; QTest::newRow("de_DE -,1") << QString("de_DE") << QString("-,1") << true << -0.1;
QTest::newRow("de_DE 1,") << QString("de_DE") << QString("1,") << true << 1.0; QTest::newRow("de_DE 1,") << QString("de_DE") << QString("1,") << true << 1.0;
QTest::newRow("de_DE 1,E10") << QString("de_DE") << QString("1,E10") << true << 1.0e10; QTest::newRow("de_DE 1,E10") << QString("de_DE") << QString("1,E10") << true << 1.0e10;
QTest::newRow("de_DE empty") << QString("de_DE") << QString("") << false << 0.0; QTest::newRow("de_DE empty") << QString("de_DE") << QString("") << false << 0.0;
QTest::newRow("de_DE null") << QString("de_DE") << QString() << false << 0.0; QTest::newRow("de_DE null") << QString("de_DE") << QString() << false << 0.0;
QTest::newRow("de_DE .") << QString("de_DE") << QString(".") << false << 0.0; QTest::newRow("de_DE .") << QString("de_DE") << QString(".") << false << 0.0;
QTest::newRow("de_DE 1e") << QString("de_DE") << QString("1e") << false << 0.0; QTest::newRow("de_DE 1e") << QString("de_DE") << QString("1e") << false << 0.0;
QTest::newRow("de_DE 1e1.0") << QString("de_DE") << QString("1e1.0") << false << 0.0; QTest::newRow("de_DE 1e1.0") << QString("de_DE") << QString("1e1.0") << false << 0.0;
QTest::newRow("de_DE 1e+") << QString("de_DE") << QString("1e+") << false << 0.0; QTest::newRow("de_DE 1e+") << QString("de_DE") << QString("1e+") << false << 0.0;
QTest::newRow("de_DE 1e-") << QString("de_DE") << QString("1e-") << false << 0.0; QTest::newRow("de_DE 1e-") << QString("de_DE") << QString("1e-") << false << 0.0;
QTest::newRow("C 9,876543") << QString("C") << QString("9,876543") << false << 0.0; QTest::newRow("C 9,876543") << QString("C") << QString("9,876543") << false << 0.0;
QTest::newRow("C 9,876543.2") << QString("C") << QString("9,876543.2") << false << 0.0; QTest::newRow("C 9,876543.2") << QString("C") << QString("9,876543.2") << false << 0.0;
QTest::newRow("C 9,876543e-2") << QString("C") << QString("9,876543e-2") << false << 0.0; QTest::newRow("C 9,876543e-2") << QString("C") << QString("9,876543e-2") << false << 0.0;
QTest::newRow("C 9,876543.0e-2") << QString("C") << QString("9,876543.0e-2") << false << 0.0; QTest::newRow("C 9,876543.0e-2") << QString("C") << QString("9,876543.0e-2") << false << 0.0;
QTest::newRow("de_DE 9.876543") << QString("de_DE") << QString("9876.543") << false << 0.0; QTest::newRow("de_DE 9.876543") << QString("de_DE") << QString("9876.543") << false << 0.0;
QTest::newRow("de_DE 9.876543,2") << QString("de_DE") << QString("9.876543,2") << false << 0.0; QTest::newRow("de_DE 9.876543,2") << QString("de_DE") << QString("9.876543,2") << false << 0.0;
@ -595,10 +594,10 @@ void tst_QLocale::double_conversion()
QCOMPARE(ok, good); QCOMPARE(ok, good);
if (ok) { if (ok) {
double diff = d - num; double diff = d - num;
if (diff < 0) if (diff < 0)
diff = -diff; diff = -diff;
QVERIFY(diff <= MY_DOUBLE_EPSILON); QVERIFY(diff <= MY_DOUBLE_EPSILON);
} }
} }
@ -609,50 +608,50 @@ void tst_QLocale::long_long_conversion_data()
QTest::addColumn<bool>("good"); QTest::addColumn<bool>("good");
QTest::addColumn<qlonglong>("num"); QTest::addColumn<qlonglong>("num");
QTest::newRow("C null") << QString("C") << QString() << false << (qlonglong) 0; QTest::newRow("C null") << QString("C") << QString() << false << (qlonglong) 0;
QTest::newRow("C empty") << QString("C") << QString("") << false << (qlonglong) 0; QTest::newRow("C empty") << QString("C") << QString("") << false << (qlonglong) 0;
QTest::newRow("C 1") << QString("C") << "1" << true << (qlonglong) 1; QTest::newRow("C 1") << QString("C") << "1" << true << (qlonglong) 1;
QTest::newRow("C 1,") << QString("C") << "1," << false << (qlonglong) 0; QTest::newRow("C 1,") << QString("C") << "1," << false << (qlonglong) 0;
QTest::newRow("C 1,2") << QString("C") << "1,2" << false << (qlonglong) 0; QTest::newRow("C 1,2") << QString("C") << "1,2" << false << (qlonglong) 0;
QTest::newRow("C 1,23") << QString("C") << "1,23" << false << (qlonglong) 0; QTest::newRow("C 1,23") << QString("C") << "1,23" << false << (qlonglong) 0;
QTest::newRow("C 1,234") << QString("C") << "1,234" << true << (qlonglong) 1234; QTest::newRow("C 1,234") << QString("C") << "1,234" << true << (qlonglong) 1234;
QTest::newRow("C 1234567") << QString("C") << "1234567"<< true << (qlonglong) 1234567; QTest::newRow("C 1234567") << QString("C") << "1234567" << true << (qlonglong) 1234567;
QTest::newRow("C 1,234567") << QString("C") << "1,234567"<< false << (qlonglong) 0; QTest::newRow("C 1,234567") << QString("C") << "1,234567" << false << (qlonglong) 0;
QTest::newRow("C 12,34567") << QString("C") << "12,34567"<< false << (qlonglong) 0; QTest::newRow("C 12,34567") << QString("C") << "12,34567" << false << (qlonglong) 0;
QTest::newRow("C 123,4567") << QString("C") << "123,4567"<< false << (qlonglong) 0; QTest::newRow("C 123,4567") << QString("C") << "123,4567" << false << (qlonglong) 0;
QTest::newRow("C 1234,567") << QString("C") << "1234,567"<< false << (qlonglong) 0; QTest::newRow("C 1234,567") << QString("C") << "1234,567" << false << (qlonglong) 0;
QTest::newRow("C 12345,67") << QString("C") << "12345,67"<< false << (qlonglong) 0; QTest::newRow("C 12345,67") << QString("C") << "12345,67" << false << (qlonglong) 0;
QTest::newRow("C 123456,7") << QString("C") << "123456,7"<< false << (qlonglong) 0; QTest::newRow("C 123456,7") << QString("C") << "123456,7" << false << (qlonglong) 0;
QTest::newRow("C 1,234,567") << QString("C")<< "1,234,567"<< true << (qlonglong) 1234567; QTest::newRow("C 1,234,567") << QString("C") << "1,234,567" << true << (qlonglong) 1234567;
QTest::newRow("de_DE 1") << QString("de_DE") << "1" << true << (qlonglong) 1; QTest::newRow("de_DE 1") << QString("de_DE") << "1" << true << (qlonglong) 1;
QTest::newRow("de_DE 1.") << QString("de_DE") << "1." << false << (qlonglong) 0; QTest::newRow("de_DE 1.") << QString("de_DE") << "1." << false << (qlonglong) 0;
QTest::newRow("de_DE 1.2") << QString("de_DE") << "1.2" << false << (qlonglong) 0; QTest::newRow("de_DE 1.2") << QString("de_DE") << "1.2" << false << (qlonglong) 0;
QTest::newRow("de_DE 1.23") << QString("de_DE") << "1.23" << false << (qlonglong) 0; QTest::newRow("de_DE 1.23") << QString("de_DE") << "1.23" << false << (qlonglong) 0;
QTest::newRow("de_DE 1.234") << QString("de_DE") << "1.234" << true << (qlonglong) 1234; QTest::newRow("de_DE 1.234") << QString("de_DE") << "1.234" << true << (qlonglong) 1234;
QTest::newRow("de_DE 1234567") << QString("de_DE") << "1234567"<< true << (qlonglong) 1234567; QTest::newRow("de_DE 1234567") << QString("de_DE") << "1234567" << true << (qlonglong) 1234567;
QTest::newRow("de_DE 1.234567") << QString("de_DE") << "1.234567"<< false << (qlonglong) 0; QTest::newRow("de_DE 1.234567") << QString("de_DE") << "1.234567" << false << (qlonglong) 0;
QTest::newRow("de_DE 12.34567") << QString("de_DE") << "12.34567"<< false << (qlonglong) 0; QTest::newRow("de_DE 12.34567") << QString("de_DE") << "12.34567" << false << (qlonglong) 0;
QTest::newRow("de_DE 123.4567") << QString("de_DE") << "123.4567"<< false << (qlonglong) 0; QTest::newRow("de_DE 123.4567") << QString("de_DE") << "123.4567" << false << (qlonglong) 0;
QTest::newRow("de_DE 1234.567") << QString("de_DE") << "1234.567"<< false << (qlonglong) 0; QTest::newRow("de_DE 1234.567") << QString("de_DE") << "1234.567" << false << (qlonglong) 0;
QTest::newRow("de_DE 12345.67") << QString("de_DE") << "12345.67"<< false << (qlonglong) 0; QTest::newRow("de_DE 12345.67") << QString("de_DE") << "12345.67" << false << (qlonglong) 0;
QTest::newRow("de_DE 123456.7") << QString("de_DE") << "123456.7"<< false << (qlonglong) 0; QTest::newRow("de_DE 123456.7") << QString("de_DE") << "123456.7" << false << (qlonglong) 0;
QTest::newRow("de_DE 1.234.567") << QString("de_DE")<< "1.234.567"<< true << (qlonglong) 1234567; QTest::newRow("de_DE 1.234.567") << QString("de_DE") << "1.234.567" << true << (qlonglong) 1234567;
QTest::newRow("de_DE 1.234.567 ldspcs") << QString("de_DE")<< " 1.234.567" << true << (qlonglong) 1234567; QTest::newRow("de_DE 1.234.567 ldspcs") << QString("de_DE") << " 1.234.567" << true << (qlonglong) 1234567;
QTest::newRow("de_DE 1.234.567 trspcs") << QString("de_DE")<< "1.234.567 "<< true << (qlonglong) 1234567; QTest::newRow("de_DE 1.234.567 trspcs") << QString("de_DE") << "1.234.567 " << true << (qlonglong) 1234567;
QTest::newRow("de_DE 1.234.567 ldtrspcs") << QString("de_DE")<< " 1.234.567 "<< true << (qlonglong) 1234567; QTest::newRow("de_DE 1.234.567 ldtrspcs") << QString("de_DE") << " 1.234.567 " << true << (qlonglong) 1234567;
// test that space is also accepted whenever QLocale::groupSeparator() == 0xa0 (which looks like space). // test that space is also accepted whenever QLocale::groupSeparator() == 0xa0 (which looks like space).
QTest::newRow("nb_NO 123 groupsep") << QString("nb_NO")<< QString("1")+QChar(0xa0)+QString("234") << true << (qlonglong) 1234; QTest::newRow("nb_NO 123 groupsep") << QString("nb_NO") << QString("1")+QChar(0xa0)+QString("234") << true << (qlonglong) 1234;
QTest::newRow("nb_NO 123 groupsep_space") << QString("nb_NO")<< QString("1")+QChar(0x20)+QString("234") << true << (qlonglong) 1234; QTest::newRow("nb_NO 123 groupsep_space") << QString("nb_NO") << QString("1")+QChar(0x20)+QString("234") << true << (qlonglong) 1234;
QTest::newRow("nb_NO 123 ldspcs") << QString("nb_NO")<< " 123" << true << (qlonglong) 123; QTest::newRow("nb_NO 123 ldspcs") << QString("nb_NO") << " 123" << true << (qlonglong) 123;
QTest::newRow("nb_NO 123 trspcs") << QString("nb_NO")<< "123 "<< true << (qlonglong) 123; QTest::newRow("nb_NO 123 trspcs") << QString("nb_NO") << "123 " << true << (qlonglong) 123;
QTest::newRow("nb_NO 123 ldtrspcs") << QString("nb_NO")<< " 123 "<< true << (qlonglong) 123; QTest::newRow("nb_NO 123 ldtrspcs") << QString("nb_NO") << " 123 " << true << (qlonglong) 123;
QTest::newRow("C 1234") << QString("C") << " 1234" << true << (qlonglong) 1234; QTest::newRow("C 1234") << QString("C") << " 1234" << true << (qlonglong) 1234;
QTest::newRow("C 1234 ") << QString("C") << "1234 " << true << (qlonglong) 1234; QTest::newRow("C 1234 ") << QString("C") << "1234 " << true << (qlonglong) 1234;
QTest::newRow("C 1234 ") << QString("C") << " 1234 " << true << (qlonglong) 1234; QTest::newRow("C 1234 ") << QString("C") << " 1234 " << true << (qlonglong) 1234;
} }
void tst_QLocale::long_long_conversion() void tst_QLocale::long_long_conversion()
@ -670,7 +669,7 @@ void tst_QLocale::long_long_conversion()
QCOMPARE(ok, good); QCOMPARE(ok, good);
if (ok) { if (ok) {
QCOMPARE(l, num); QCOMPARE(l, num);
} }
} }
@ -1105,13 +1104,13 @@ void tst_QLocale::macDefaultLocale()
int diff = currentTime.hour() - utcTime.hour(); int diff = currentTime.hour() - utcTime.hour();
// Check if local time and utc time are on opposite sides of the 24-hour wrap-around. // Check if local time and utc time are on opposite sides of the 24-hour wrap-around.
if (diff < -12) if (diff < -12)
diff += 24; diff += 24;
if (diff > 12) if (diff > 12)
diff -= 24; diff -= 24;
const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat); const QString timeString = locale.toString(QTime(1,2,3), QLocale::LongFormat);
QVERIFY(timeString.contains(QString("1:02:03"))); QVERIFY(timeString.contains(QString("1:02:03")));
QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00")); QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00"));

View File

@ -85,24 +85,24 @@ class MyClass
{ {
public: public:
MyClass() { MyClass() {
++count; ++count;
// qDebug("creating MyClass count=%d", count); // qDebug("creating MyClass count=%d", count);
} }
MyClass( const QString& c) { MyClass( const QString& c) {
count++; str = c; count++; str = c;
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count); // qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
} }
~MyClass() { ~MyClass() {
count--; count--;
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count); // qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
} }
MyClass( const MyClass& c ) { MyClass( const MyClass& c ) {
count++; str = c.str; count++; str = c.str;
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count); // qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
} }
MyClass &operator =(const MyClass &o) { MyClass &operator =(const MyClass &o) {
// qDebug("copying MyClass '%s'", o.str.latin1()); // qDebug("copying MyClass '%s'", o.str.latin1());
str = o.str; return *this; str = o.str; return *this;
} }
QString str; QString str;
@ -121,145 +121,145 @@ void tst_QMap::init()
void tst_QMap::count() void tst_QMap::count()
{ {
{ {
MyMap map; MyMap map;
MyMap map2( map ); MyMap map2( map );
QCOMPARE( map.count(), 0 ); QCOMPARE( map.count(), 0 );
QCOMPARE( map2.count(), 0 ); QCOMPARE( map2.count(), 0 );
QCOMPARE( MyClass::count, int(0) ); QCOMPARE( MyClass::count, int(0) );
// detach // detach
map2["Hallo"] = MyClass( "Fritz" ); map2["Hallo"] = MyClass( "Fritz" );
QCOMPARE( map.count(), 0 ); QCOMPARE( map.count(), 0 );
QCOMPARE( map2.count(), 1 ); QCOMPARE( map2.count(), 1 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 1 ); QCOMPARE( MyClass::count, 1 );
#endif #endif
} }
QCOMPARE( MyClass::count, int(0) ); QCOMPARE( MyClass::count, int(0) );
{ {
typedef QMap<QString, MyClass> Map; typedef QMap<QString, MyClass> Map;
Map map; Map map;
QCOMPARE( map.count(), 0); QCOMPARE( map.count(), 0);
map.insert( "Torben", MyClass("Weis") ); map.insert( "Torben", MyClass("Weis") );
QCOMPARE( map.count(), 1 ); QCOMPARE( map.count(), 1 );
map.insert( "Claudia", MyClass("Sorg") ); map.insert( "Claudia", MyClass("Sorg") );
QCOMPARE( map.count(), 2 ); QCOMPARE( map.count(), 2 );
map.insert( "Lars", MyClass("Linzbach") ); map.insert( "Lars", MyClass("Linzbach") );
map.insert( "Matthias", MyClass("Ettrich") ); map.insert( "Matthias", MyClass("Ettrich") );
map.insert( "Sue", MyClass("Paludo") ); map.insert( "Sue", MyClass("Paludo") );
map.insert( "Eirik", MyClass("Eng") ); map.insert( "Eirik", MyClass("Eng") );
map.insert( "Haavard", MyClass("Nord") ); map.insert( "Haavard", MyClass("Nord") );
map.insert( "Arnt", MyClass("Gulbrandsen") ); map.insert( "Arnt", MyClass("Gulbrandsen") );
map.insert( "Paul", MyClass("Tvete") ); map.insert( "Paul", MyClass("Tvete") );
QCOMPARE( map.count(), 9 ); QCOMPARE( map.count(), 9 );
map.insert( "Paul", MyClass("Tvete 1") ); map.insert( "Paul", MyClass("Tvete 1") );
map.insert( "Paul", MyClass("Tvete 2") ); map.insert( "Paul", MyClass("Tvete 2") );
map.insert( "Paul", MyClass("Tvete 3") ); map.insert( "Paul", MyClass("Tvete 3") );
map.insert( "Paul", MyClass("Tvete 4") ); map.insert( "Paul", MyClass("Tvete 4") );
map.insert( "Paul", MyClass("Tvete 5") ); map.insert( "Paul", MyClass("Tvete 5") );
map.insert( "Paul", MyClass("Tvete 6") ); map.insert( "Paul", MyClass("Tvete 6") );
QCOMPARE( map.count(), 9 ); QCOMPARE( map.count(), 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
Map map2( map ); Map map2( map );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.insert( "Kay", MyClass("Roemer") ); map2.insert( "Kay", MyClass("Roemer") );
QVERIFY( map2.count() == 10 ); QVERIFY( map2.count() == 10 );
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 ); QCOMPARE( MyClass::count, 19 );
#endif #endif
map2 = map; map2 = map;
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.insert( "Kay", MyClass("Roemer") ); map2.insert( "Kay", MyClass("Roemer") );
QVERIFY( map2.count() == 10 ); QVERIFY( map2.count() == 10 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 19 ); QCOMPARE( MyClass::count, 19 );
#endif #endif
map2.clear(); map2.clear();
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2 = map; map2 = map;
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 9 ); QVERIFY( map2.count() == 9 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map2.clear(); map2.clear();
QVERIFY( map.count() == 9 ); QVERIFY( map.count() == 9 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 9 ); QCOMPARE( MyClass::count, 9 );
#endif #endif
map.remove( "Lars" ); map.remove( "Lars" );
QVERIFY( map.count() == 8 ); QVERIFY( map.count() == 8 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 ); QCOMPARE( MyClass::count, 8 );
#endif #endif
map.remove( "Mist" ); map.remove( "Mist" );
QVERIFY( map.count() == 8 ); QVERIFY( map.count() == 8 );
QVERIFY( map2.count() == 0 ); QVERIFY( map2.count() == 0 );
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QCOMPARE( MyClass::count, 8 ); QCOMPARE( MyClass::count, 8 );
#endif #endif
} }
QVERIFY( MyClass::count == 0 ); QVERIFY( MyClass::count == 0 );
{ {
typedef QMap<QString,MyClass> Map; typedef QMap<QString,MyClass> Map;
Map map; Map map;
map["Torben"] = MyClass("Weis"); map["Torben"] = MyClass("Weis");
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 1 ); QVERIFY( MyClass::count == 1 );
#endif #endif
QVERIFY( map.count() == 1 ); QVERIFY( map.count() == 1 );
(void)map["Torben"].str; (void)map["Torben"].str;
(void)map["Lars"].str; (void)map["Lars"].str;
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 ); QVERIFY( MyClass::count == 2 );
#endif #endif
QVERIFY( map.count() == 2 ); QVERIFY( map.count() == 2 );
const Map& cmap = map; const Map& cmap = map;
(void)cmap["Depp"].str; (void)cmap["Depp"].str;
#ifndef Q_CC_SUN #ifndef Q_CC_SUN
QVERIFY( MyClass::count == 2 ); QVERIFY( MyClass::count == 2 );
#endif #endif
QVERIFY( map.count() == 2 ); QVERIFY( map.count() == 2 );
QVERIFY( cmap.count() == 2 ); QVERIFY( cmap.count() == 2 );
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
{ {
for ( int i = 0; i < 100; ++i ) for ( int i = 0; i < 100; ++i )
{ {
QMap<int, MyClass> map; QMap<int, MyClass> map;
for (int j = 0; j < i; ++j) for (int j = 0; j < i; ++j)
map.insert(j, MyClass(QString::number(j))); map.insert(j, MyClass(QString::number(j)));
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
} }
QCOMPARE( MyClass::count, 0 ); QCOMPARE( MyClass::count, 0 );
} }
@ -267,17 +267,17 @@ void tst_QMap::count()
void tst_QMap::clear() void tst_QMap::clear()
{ {
{ {
MyMap map; MyMap map;
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
map.insert( "key", MyClass( "value" ) ); map.insert( "key", MyClass( "value" ) );
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
map.insert( "key0", MyClass( "value0" ) ); map.insert( "key0", MyClass( "value0" ) );
map.insert( "key0", MyClass( "value1" ) ); map.insert( "key0", MyClass( "value1" ) );
map.insert( "key1", MyClass( "value2" ) ); map.insert( "key1", MyClass( "value2" ) );
map.clear(); map.clear();
QVERIFY( map.isEmpty() ); QVERIFY( map.isEmpty() );
} }
QCOMPARE( MyClass::count, int(0) ); QCOMPARE( MyClass::count, int(0) );
} }
@ -302,8 +302,8 @@ void tst_QMap::beginEnd()
// test iteration // test iteration
QString result; QString result;
for ( StringMap::ConstIterator it = map.constBegin(); for ( StringMap::ConstIterator it = map.constBegin();
it != map.constEnd(); ++it ) it != map.constEnd(); ++it )
result += *it; result += *it;
QCOMPARE( result, QString( "ab" ) ); QCOMPARE( result, QString( "ab" ) );
// maps should still be identical // maps should still be identical

File diff suppressed because it is too large Load Diff

View File

@ -137,79 +137,79 @@ void tst_QRegExp::indexIn_data()
QTest::newRow( stri + "anc00" ) << QString("a(?=)z") << QString("az") << 0 << 2 << QStringList(); QTest::newRow( stri + "anc00" ) << QString("a(?=)z") << QString("az") << 0 << 2 << QStringList();
QTest::newRow( stri + "anc01" ) << QString("a(?!)z") << QString("az") << -1 << -1 << QStringList(); QTest::newRow( stri + "anc01" ) << QString("a(?!)z") << QString("az") << -1 << -1 << QStringList();
QTest::newRow( stri + "anc02" ) << QString("a(?:(?=)|(?=))z") << QString("az") << 0 << 2 QTest::newRow( stri + "anc02" ) << QString("a(?:(?=)|(?=))z") << QString("az") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc03" ) << QString("a(?:(?=)|(?!))z") << QString("az") << 0 << 2 QTest::newRow( stri + "anc03" ) << QString("a(?:(?=)|(?!))z") << QString("az") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc04" ) << QString("a(?:(?!)|(?=))z") << QString("az") << 0 << 2 QTest::newRow( stri + "anc04" ) << QString("a(?:(?!)|(?=))z") << QString("az") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc05" ) << QString("a(?:(?!)|(?!))z") << QString("az") << -1 << -1 QTest::newRow( stri + "anc05" ) << QString("a(?:(?!)|(?!))z") << QString("az") << -1 << -1
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc06" ) << QString("a(?:(?=)|b)z") << QString("az") << 0 << 2 QTest::newRow( stri + "anc06" ) << QString("a(?:(?=)|b)z") << QString("az") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc07" ) << QString("a(?:(?=)|b)z") << QString("abz") << 0 << 3 QTest::newRow( stri + "anc07" ) << QString("a(?:(?=)|b)z") << QString("abz") << 0 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc08" ) << QString("a(?:(?!)|b)z") << QString("az") << -1 << -1 QTest::newRow( stri + "anc08" ) << QString("a(?:(?!)|b)z") << QString("az") << -1 << -1
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc09" ) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3 QTest::newRow( stri + "anc09" ) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3
<< QStringList(); << QStringList();
#if 0 #if 0
QTest::newRow( stri + "anc10" ) << QString("a?(?=^b$)") << QString("ab") << 0 << 1 QTest::newRow( stri + "anc10" ) << QString("a?(?=^b$)") << QString("ab") << 0 << 1
<< QStringList(); << QStringList();
QTest::newRow( stri + "anc11" ) << QString("a?(?=^b$)") << QString("b") << 0 << 0 QTest::newRow( stri + "anc11" ) << QString("a?(?=^b$)") << QString("b") << 0 << 0
<< QStringList(); << QStringList();
#endif #endif
// back-references // back-references
QTest::newRow( stri + "bref00" ) << QString("(a*)(\\1)") << QString("aaaaa") << 0 << 4 QTest::newRow( stri + "bref00" ) << QString("(a*)(\\1)") << QString("aaaaa") << 0 << 4
<< QStringList( QStringList() << "aa" << "aa" ); << QStringList( QStringList() << "aa" << "aa" );
QTest::newRow( stri + "bref01" ) << QString("<(\\w*)>.+</\\1>") << QString("<b>blabla</b>bla</>") QTest::newRow( stri + "bref01" ) << QString("<(\\w*)>.+</\\1>") << QString("<b>blabla</b>bla</>")
<< 0 << 13 << QStringList( QStringList() << "b" ); << 0 << 13 << QStringList( QStringList() << "b" );
QTest::newRow( stri + "bref02" ) << QString("<(\\w*)>.+</\\1>") << QString("<>blabla</b>bla</>") QTest::newRow( stri + "bref02" ) << QString("<(\\w*)>.+</\\1>") << QString("<>blabla</b>bla</>")
<< 0 << 18 << QStringList( QStringList() << "" ); << 0 << 18 << QStringList( QStringList() << "" );
QTest::newRow( stri + "bref03" ) << QString("((a*\\2)\\2)") << QString("aaaa") << 0 << 4 QTest::newRow( stri + "bref03" ) << QString("((a*\\2)\\2)") << QString("aaaa") << 0 << 4
<< QStringList( QStringList() << QString("aaaa") << "aa" ); << QStringList( QStringList() << QString("aaaa") << "aa" );
QTest::newRow( stri + "bref04" ) << QString("^(aa+)\\1+$") << QString("aaaaaa") << 0 << 6 QTest::newRow( stri + "bref04" ) << QString("^(aa+)\\1+$") << QString("aaaaaa") << 0 << 6
<< QStringList( QStringList() << QString("aa") ); << QStringList( QStringList() << QString("aa") );
QTest::newRow( stri + "bref05" ) << QString("^(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)" QTest::newRow( stri + "bref05" ) << QString("^(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)(12)(13)(14)"
"\\14\\13\\12\\11\\10\\9\\8\\7\\6\\5\\4\\3\\2\\1") "\\14\\13\\12\\11\\10\\9\\8\\7\\6\\5\\4\\3\\2\\1")
<< QString("12345678910111213141413121110987654321") << 0 << 38 << QString("12345678910111213141413121110987654321") << 0 << 38
<< QStringList( QStringList() << "1" << "2" << "3" << "4" << "5" << "6" << QStringList( QStringList() << "1" << "2" << "3" << "4" << "5" << "6"
<< "7" << "8" << "9" << "10" << "11" << "7" << "8" << "9" << "10" << "11"
<< "12" << "13" << "14"); << "12" << "13" << "14");
// captures // captures
QTest::newRow( stri + "cap00" ) << QString("(a*)") << QString("") << 0 << 0 QTest::newRow( stri + "cap00" ) << QString("(a*)") << QString("") << 0 << 0
<< QStringList( QStringList() << QString("") ); << QStringList( QStringList() << QString("") );
QTest::newRow( stri + "cap01" ) << QString("(a*)") << QString("aaa") << 0 << 3 QTest::newRow( stri + "cap01" ) << QString("(a*)") << QString("aaa") << 0 << 3
<< QStringList( QStringList() << "aaa" ); << QStringList( QStringList() << "aaa" );
QTest::newRow( stri + "cap02" ) << QString("(a*)") << QString("baaa") << 0 << 0 QTest::newRow( stri + "cap02" ) << QString("(a*)") << QString("baaa") << 0 << 0
<< QStringList( QStringList() << QString("") ); << QStringList( QStringList() << QString("") );
QTest::newRow( stri + "cap03" ) << QString("(a*)(a*)") << QString("aaa") << 0 << 3 QTest::newRow( stri + "cap03" ) << QString("(a*)(a*)") << QString("aaa") << 0 << 3
<< QStringList( QStringList() << QString("aaa") << QString("") ); << QStringList( QStringList() << QString("aaa") << QString("") );
QTest::newRow( stri + "cap04" ) << QString("(a*)(b*)") << QString("aaabbb") << 0 << 6 QTest::newRow( stri + "cap04" ) << QString("(a*)(b*)") << QString("aaabbb") << 0 << 6
<< QStringList( QStringList() << QString("aaa") << QString("bbb") ); << QStringList( QStringList() << QString("aaa") << QString("bbb") );
QTest::newRow( stri + "cap06" ) << QString("(a*)a*") << QString("aaa") << 0 << 3 QTest::newRow( stri + "cap06" ) << QString("(a*)a*") << QString("aaa") << 0 << 3
<< QStringList( QStringList() << QString("aaa") ); << QStringList( QStringList() << QString("aaa") );
QTest::newRow( stri + "cap07" ) << QString("((a*a*)*)") << QString("aaa") << 0 << 3 QTest::newRow( stri + "cap07" ) << QString("((a*a*)*)") << QString("aaa") << 0 << 3
<< QStringList( QStringList() << "aaa" << QString("aaa") ); << QStringList( QStringList() << "aaa" << QString("aaa") );
QTest::newRow( stri + "cap08" ) << QString("(((a)*(b)*)*)") << QString("ababa") << 0 << 5 QTest::newRow( stri + "cap08" ) << QString("(((a)*(b)*)*)") << QString("ababa") << 0 << 5
<< QStringList( QStringList() << QString("ababa") << QString("a") << QString("a") << QStringList( QStringList() << QString("ababa") << QString("a") << QString("a")
<< "" ); << "" );
QTest::newRow( stri + "cap09" ) << QString("(((a)*(b)*)c)*") << QString("") << 0 << 0 QTest::newRow( stri + "cap09" ) << QString("(((a)*(b)*)c)*") << QString("") << 0 << 0
<< QStringList( QStringList() << QString("") << QString("") << QString("") << QString("") ); << QStringList( QStringList() << QString("") << QString("") << QString("") << QString("") );
QTest::newRow( stri + "cap10" ) << QString("(((a)*(b)*)c)*") << QString("abc") << 0 << 3 QTest::newRow( stri + "cap10" ) << QString("(((a)*(b)*)c)*") << QString("abc") << 0 << 3
<< QStringList( QStringList() << "abc" << "ab" << "a" << QStringList( QStringList() << "abc" << "ab" << "a"
<< "b" ); << "b" );
QTest::newRow( stri + "cap11" ) << QString("(((a)*(b)*)c)*") << QString("abcc") << 0 << 4 QTest::newRow( stri + "cap11" ) << QString("(((a)*(b)*)c)*") << QString("abcc") << 0 << 4
<< QStringList( QStringList() << "c" << "" << "" << "" ); << QStringList( QStringList() << "c" << "" << "" << "" );
QTest::newRow( stri + "cap12" ) << QString("(((a)*(b)*)c)*") << QString("abcac") << 0 << 5 QTest::newRow( stri + "cap12" ) << QString("(((a)*(b)*)c)*") << QString("abcac") << 0 << 5
<< QStringList( QStringList() << "ac" << "a" << "a" << "" ); << QStringList( QStringList() << "ac" << "a" << "a" << "" );
QTest::newRow( stri + "cap13" ) << QString("(to|top)?(o|polo)?(gical|o?logical)") QTest::newRow( stri + "cap13" ) << QString("(to|top)?(o|polo)?(gical|o?logical)")
<< QString("topological") << 0 << 11 << QString("topological") << 0 << 11
<< QStringList( QStringList() << "top" << "o" << QStringList( QStringList() << "top" << "o"
<< "logical" ); << "logical" );
QTest::newRow( stri + "cap14" ) << QString("(a)+") << QString("aaaa") << 0 << 4 QTest::newRow( stri + "cap14" ) << QString("(a)+") << QString("aaaa") << 0 << 4
<< QStringList( QStringList() << "a" ); << QStringList( QStringList() << "a" );
// concatenation // concatenation
QTest::newRow( stri + "cat00" ) << QString("") << QString("") << 0 << 0 << QStringList(); QTest::newRow( stri + "cat00" ) << QString("") << QString("") << 0 << 0 << QStringList();
@ -220,165 +220,156 @@ void tst_QRegExp::indexIn_data()
QTest::newRow( stri + "cat05" ) << QString("b") << QString("a") << -1 << -1 << QStringList(); QTest::newRow( stri + "cat05" ) << QString("b") << QString("a") << -1 << -1 << QStringList();
QTest::newRow( stri + "cat06" ) << QString("ab") << QString("ab") << 0 << 2 << QStringList(); QTest::newRow( stri + "cat06" ) << QString("ab") << QString("ab") << 0 << 2 << QStringList();
QTest::newRow( stri + "cat07" ) << QString("ab") << QString("ba") << -1 << -1 << QStringList(); QTest::newRow( stri + "cat07" ) << QString("ab") << QString("ba") << -1 << -1 << QStringList();
QTest::newRow( stri + "cat08" ) << QString("abab") << QString("abbaababab") << 4 << 4 QTest::newRow( stri + "cat08" ) << QString("abab") << QString("abbaababab") << 4 << 4 << QStringList();
<< QStringList();
indexIn_addMoreRows(stri); indexIn_addMoreRows(stri);
} }
} }
void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri) void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri)
{ {
// from Perl Cookbook // from Perl Cookbook
QTest::newRow( stri + "cook00" ) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0" QTest::newRow( stri + "cook00" ) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0,3}|i[vx])$")
",3}|i[vx])$") << QString("mmxl") << 0 << 4
<< QString("mmxl") << 0 << 4 << QStringList( QStringList() << "mm" << "" << "xl"
<< QStringList( QStringList() << "mm" << "" << "xl" << "" );
<< "" );
QTest::newRow( stri + "cook01" ) << QString("(\\S+)(\\s+)(\\S+)") << QString(" a b") << 1 << 5 QTest::newRow( stri + "cook01" ) << QString("(\\S+)(\\s+)(\\S+)") << QString(" a b") << 1 << 5
<< QStringList( QStringList() << "a" << " " << "b" ); << QStringList( QStringList() << "a" << " " << "b" );
QTest::newRow( stri + "cook02" ) << QString("(\\w+)\\s*=\\s*(.*)\\s*$") << QString(" PATH=. ") << 1 QTest::newRow( stri + "cook02" ) << QString("(\\w+)\\s*=\\s*(.*)\\s*$") << QString(" PATH=. ") << 1
<< 7 << QStringList( QStringList() << "PATH" << ". " ); << 7 << QStringList( QStringList() << "PATH" << ". " );
QTest::newRow( stri + "cook03" ) << QString(".{80,}") QTest::newRow( stri + "cook03" ) << QString(".{80,}")
<< QString("0000000011111111222222223333333344444444555" << QString("0000000011111111222222223333333344444444555"
"5555566666666777777778888888899999999000000" "5555566666666777777778888888899999999000000"
"00aaaaaaaa") "00aaaaaaaa")
<< 0 << 96 << QStringList(); << 0 << 96 << QStringList();
QTest::newRow( stri + "cook04" ) << QString("(\\d+)/(\\d+)/(\\d+) (\\d+):(\\d+):(\\d+)") QTest::newRow( stri + "cook04" ) << QString("(\\d+)/(\\d+)/(\\d+) (\\d+):(\\d+):(\\d+)")
<< QString("1978/05/24 07:30:00") << 0 << 19 << QString("1978/05/24 07:30:00") << 0 << 19
<< QStringList( QStringList() << "1978" << "05" << "24" << QStringList( QStringList() << "1978" << "05" << "24"
<< "07" << "30" << "00" ); << "07" << "30" << "00" );
QTest::newRow( stri + "cook05" ) << QString("/usr/bin") << QString("/usr/local/bin:/usr/bin") QTest::newRow( stri + "cook05" ) << QString("/usr/bin") << QString("/usr/local/bin:/usr/bin")
<< 15 << 8 << QStringList(); << 15 << 8 << QStringList();
QTest::newRow( stri + "cook06" ) << QString("%([0-9A-Fa-f]{2})") << QString("http://%7f") << 7 << 3 QTest::newRow( stri + "cook06" ) << QString("%([0-9A-Fa-f]{2})") << QString("http://%7f") << 7 << 3
<< QStringList( QStringList() << "7f" ); << QStringList( QStringList() << "7f" );
QTest::newRow( stri + "cook07" ) << QString("/\\*.*\\*/") << QString("i++; /* increment i */") << 5 QTest::newRow( stri + "cook07" ) << QString("/\\*.*\\*/") << QString("i++; /* increment i */") << 5
<< 17 << QStringList(); << 17 << QStringList();
QTest::newRow( stri + "cook08" ) << QString("^\\s+") << QString(" aaa ") << 0 << 3 QTest::newRow( stri + "cook08" ) << QString("^\\s+") << QString(" aaa ") << 0 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "cook09" ) << QString("\\s+$") << QString(" aaa ") << 6 << 3 QTest::newRow( stri + "cook09" ) << QString("\\s+$") << QString(" aaa ") << 6 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "cook10" ) << QString("^.*::") << QString("Box::cat") << 0 << 5 QTest::newRow( stri + "cook10" ) << QString("^.*::") << QString("Box::cat") << 0 << 5
<< QStringList(); << QStringList();
QTest::newRow( stri + "cook11" ) << QString("^([01]?\\d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\" QTest::newRow( stri + "cook11" ) << QString("^([01]?\\d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\"
"d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-" "d\\d|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-"
"4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-4]\\d|25[" "4]\\d|25[0-5])\\.([01]?\\d\\d|2[0-4]\\d|25["
"0-5])$") "0-5])$")
<< QString("255.00.40.30") << 0 << 12 << QString("255.00.40.30") << 0 << 12
<< QStringList( QStringList() << "255" << "00" << "40" << QStringList( QStringList() << "255" << "00" << "40"
<< "30" ); << "30" );
QTest::newRow( stri + "cook12" ) << QString("^.*/") << QString(" /usr/local/bin/moc") << 0 << 16 QTest::newRow( stri + "cook12" ) << QString("^.*/") << QString(" /usr/local/bin/moc") << 0 << 16
<< QStringList(); << QStringList();
QTest::newRow( stri + "cook13" ) << QString(":co#(\\d+):") << QString("bla:co#55:") << 3 << 7 QTest::newRow( stri + "cook13" ) << QString(":co#(\\d+):") << QString("bla:co#55:") << 3 << 7
<< QStringList( QStringList() << "55" ); << QStringList( QStringList() << "55" );
QTest::newRow( stri + "cook14" ) << QString("linux") << QString("alphalinuxinunix") << 5 << 5 QTest::newRow( stri + "cook14" ) << QString("linux") << QString("alphalinuxinunix") << 5 << 5
<< QStringList(); << QStringList();
QTest::newRow( stri + "cook15" ) << QString("(\\d+\\.?\\d*|\\.\\d+)") << QString("0.0.5") << 0 << 3 QTest::newRow( stri + "cook15" ) << QString("(\\d+\\.?\\d*|\\.\\d+)") << QString("0.0.5") << 0 << 3
<< QStringList( QStringList() << "0.0" ); << QStringList( QStringList() << "0.0" );
// mathematical trivia // mathematical trivia
QTest::newRow( stri + "math00" ) << QString("^(a\\1*)$") << QString("a") << 0 << 1 QTest::newRow( stri + "math00" ) << QString("^(a\\1*)$") << QString("a") << 0 << 1
<< QStringList( QStringList() << "a" ); << QStringList( QStringList() << "a" );
QTest::newRow( stri + "math01" ) << QString("^(a\\1*)$") << QString("aa") << 0 << 2 QTest::newRow( stri + "math01" ) << QString("^(a\\1*)$") << QString("aa") << 0 << 2
<< QStringList( QStringList() << "aa" ); << QStringList( QStringList() << "aa" );
QTest::newRow( stri + "math02" ) << QString("^(a\\1*)$") << QString("aaa") << -1 << -1 QTest::newRow( stri + "math02" ) << QString("^(a\\1*)$") << QString("aaa") << -1 << -1
<< QStringList( QStringList() << QString() ); << QStringList( QStringList() << QString() );
QTest::newRow( stri + "math03" ) << QString("^(a\\1*)$") << QString("aaaa") << 0 << 4 QTest::newRow( stri + "math03" ) << QString("^(a\\1*)$") << QString("aaaa") << 0 << 4
<< QStringList( QStringList() << "aaaa" ); << QStringList( QStringList() << "aaaa" );
QTest::newRow( stri + "math04" ) << QString("^(a\\1*)$") << QString("aaaaa") << -1 << -1 QTest::newRow( stri + "math04" ) << QString("^(a\\1*)$") << QString("aaaaa") << -1 << -1
<< QStringList( QStringList() << QString() ); << QStringList( QStringList() << QString() );
QTest::newRow( stri + "math05" ) << QString("^(a\\1*)$") << QString("aaaaaa") << -1 << -1 QTest::newRow( stri + "math05" ) << QString("^(a\\1*)$") << QString("aaaaaa") << -1 << -1
<< QStringList( QStringList() << QString() ); << QStringList( QStringList() << QString() );
QTest::newRow( stri + "math06" ) << QString("^(a\\1*)$") << QString("aaaaaaa") << -1 << -1 QTest::newRow( stri + "math06" ) << QString("^(a\\1*)$") << QString("aaaaaaa") << -1 << -1
<< QStringList( QStringList() << QString() ); << QStringList( QStringList() << QString() );
QTest::newRow( stri + "math07" ) << QString("^(a\\1*)$") << QString("aaaaaaaa") << 0 << 8 QTest::newRow( stri + "math07" ) << QString("^(a\\1*)$") << QString("aaaaaaaa") << 0 << 8
<< QStringList( QStringList() << "aaaaaaaa" ); << QStringList( QStringList() << "aaaaaaaa" );
QTest::newRow( stri + "math08" ) << QString("^(a\\1*)$") << QString("aaaaaaaaa") << -1 << -1 QTest::newRow( stri + "math08" ) << QString("^(a\\1*)$") << QString("aaaaaaaaa") << -1 << -1
<< QStringList( QStringList() << QString() ); << QStringList( QStringList() << QString() );
QTest::newRow( stri + "math09" ) << QString("^a(?:a(\\1a))*$") << QString("a") << 0 << 1 QTest::newRow( stri + "math09" ) << QString("^a(?:a(\\1a))*$") << QString("a") << 0 << 1
<< QStringList( QStringList() << "" ); << QStringList( QStringList() << "" );
QTest::newRow( stri + "math10" ) << QString("^a(?:a(\\1a))*$") << QString("aaa") << 0 << 3 QTest::newRow( stri + "math10" ) << QString("^a(?:a(\\1a))*$") << QString("aaa") << 0 << 3
<< QStringList( QStringList() << "a" ); << QStringList( QStringList() << "a" );
QTest::newRow( stri + "math13" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" QTest::newRow( stri + "math13" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|("
"?=a$)))*a$") "?=a$)))*a$")
<< QString("aaa") << 0 << 3 << QString("aaa") << 0 << 3
<< QStringList( QStringList() << "a" << "a" << "" ); << QStringList( QStringList() << "a" << "a" << "" );
QTest::newRow( stri + "math14" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|(" QTest::newRow( stri + "math14" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|("
"?=a$)))*a$") "?=a$)))*a$")
<< QString("aaaaa") << 0 << 5 << QString("aaaaa") << 0 << 5
<< QStringList( QStringList() << "a" << "a" << "aa" ); << QStringList( QStringList() << "a" << "a" << "aa" );
QTest::newRow( stri + "math17" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" QTest::newRow( stri + "math17" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
<< QString("aaa") << 0 << 3 << QString("aaa") << 0 << 3
<< QStringList( QStringList() << "" << "" << "" << "aaa" << QStringList( QStringList() << "" << "" << "" << "aaa" << "a" << "aa" );
<< "a" << "aa" );
QTest::newRow( stri + "math18" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" QTest::newRow( stri + "math18" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
<< QString("aaaaa") << 0 << 5 << QString("aaaaa") << 0 << 5
<< QStringList( QStringList() << "aaaaa" << "a" << "aaa" << QStringList( QStringList() << "aaaaa" << "a" << "aaa" << "" << "" << "" );
<< "" << "" << "" );
QTest::newRow( stri + "math19" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" QTest::newRow( stri + "math19" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
<< QString("aaaaaaaa") << 0 << 8 << QString("aaaaaaaa") << 0 << 8
<< QStringList( QStringList() << "" << "" << "" << QStringList( QStringList() << "" << "" << "" << "aaaaaaaa" << "a" << "aa" );
<< "aaaaaaaa" << "a"
<< "aa" );
QTest::newRow( stri + "math20" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?" QTest::newRow( stri + "math20" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$") ":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
<< QString("aaaaaaaaa") << -1 << -1 << QString("aaaaaaaaa") << -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() << QString()
<< QString() << QString()
<< QString() << QString()
<< QString() ); << QString() );
QTest::newRow( stri + "math21" ) << QString("^(aa+)\\1+$") << QString("aaaaaaaaaaaa") << 0 << 12 QTest::newRow( stri + "math21" ) << QString("^(aa+)\\1+$") << QString("aaaaaaaaaaaa") << 0 << 12
<< QStringList( QStringList() << "aa" ); << QStringList( QStringList() << "aa" );
static const char * const squareRegExp[] = { static const char * const squareRegExp[] = {
"^a(?:(\\1aa)a)*$", "^a(?:(\\1aa)a)*$",
"^(\\2(\\1a))+$", "^(\\2(\\1a))+$",
"^((\\2a)*)\\1\\2a$", "^((\\2a)*)\\1\\2a$",
0 0
}; };
int ii = 0; int ii = 0;
while ( squareRegExp[ii] != 0 ) { while ( squareRegExp[ii] != 0 ) {
for ( int j = 0; j < 100; j++ ) { for ( int j = 0; j < 100; j++ ) {
QString name; QString name;
name.sprintf( "square%.1d%.2d", ii, j ); name.sprintf( "square%.1d%.2d", ii, j );
QString target = ""; QString target = "";
target.fill( 'a', j ); target.fill( 'a', j );
int pos = -1; int pos = -1;
int len = -1; int len = -1;
for ( int k = 1; k * k <= j; k++ ) { for ( int k = 1; k * k <= j; k++ ) {
if ( k * k == j ) { if ( k * k == j ) {
pos = 0; pos = 0;
len = j; len = j;
break; break;
} }
} }
QTest::newRow( name.toLatin1() ) << QString( squareRegExp[ii] ) << target QTest::newRow( name.toLatin1() ) << QString( squareRegExp[ii] ) << target
<< pos << len << QStringList( "IGNORE ME" ); << pos << len << QStringList( "IGNORE ME" );
} }
ii++; ii++;
} }
// miscellaneous // miscellaneous
QTest::newRow( stri + "misc00" ) << QString(email) QTest::newRow( stri + "misc00" ) << QString(email)
<< QString("troll1@trolltech.com") << 0 << 20 << QString("troll1@trolltech.com") << 0 << 20
<< QStringList(); << QStringList();
QTest::newRow( stri + "misc01" ) << QString("[0-9]*\\.[0-9]+") << QString("pi = 3.14") << 5 << 4 QTest::newRow( stri + "misc01" ) << QString("[0-9]*\\.[0-9]+") << QString("pi = 3.14") << 5 << 4
<< QStringList(); << QStringList();
// or operator // or operator
QTest::newRow( stri + "or00" ) << QString("(?:|b)") << QString("xxx") << 0 << 0 << QStringList(); QTest::newRow( stri + "or00" ) << QString("(?:|b)") << QString("xxx") << 0 << 0 << QStringList();
@ -392,82 +383,82 @@ void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri)
QTest::newRow( stri + "or08" ) << QString("(?:a|b)") << QString("abc") << 0 << 1 << QStringList(); QTest::newRow( stri + "or08" ) << QString("(?:a|b)") << QString("abc") << 0 << 1 << QStringList();
QTest::newRow( stri + "or09" ) << QString("(?:a|b)") << QString("cba") << 1 << 1 << QStringList(); QTest::newRow( stri + "or09" ) << QString("(?:a|b)") << QString("cba") << 1 << 1 << QStringList();
QTest::newRow( stri + "or10" ) << QString("(?:ab|ba)") << QString("aba") << 0 << 2 QTest::newRow( stri + "or10" ) << QString("(?:ab|ba)") << QString("aba") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "or11" ) << QString("(?:ab|ba)") << QString("bab") << 0 << 2 QTest::newRow( stri + "or11" ) << QString("(?:ab|ba)") << QString("bab") << 0 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "or12" ) << QString("(?:ab|ba)") << QString("caba") << 1 << 2 QTest::newRow( stri + "or12" ) << QString("(?:ab|ba)") << QString("caba") << 1 << 2
<< QStringList(); << QStringList();
QTest::newRow( stri + "or13" ) << QString("(?:ab|ba)") << QString("cbab") << 1 << 2 QTest::newRow( stri + "or13" ) << QString("(?:ab|ba)") << QString("cbab") << 1 << 2
<< QStringList(); << QStringList();
// quantifiers // quantifiers
QTest::newRow( stri + "qua00" ) << QString("((([a-j])){0,0})") << QString("") << 0 << 0 QTest::newRow( stri + "qua00" ) << QString("((([a-j])){0,0})") << QString("") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua01" ) << QString("((([a-j])){0,0})") << QString("a") << 0 << 0 QTest::newRow( stri + "qua01" ) << QString("((([a-j])){0,0})") << QString("a") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua02" ) << QString("((([a-j])){0,0})") << QString("xyz") << 0 << 0 QTest::newRow( stri + "qua02" ) << QString("((([a-j])){0,0})") << QString("xyz") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua03" ) << QString("((([a-j]))?)") << QString("") << 0 << 0 QTest::newRow( stri + "qua03" ) << QString("((([a-j]))?)") << QString("") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua04" ) << QString("((([a-j]))?)") << QString("a") << 0 << 1 QTest::newRow( stri + "qua04" ) << QString("((([a-j]))?)") << QString("a") << 0 << 1
<< QStringList( QStringList() << "a" << "a" << "a" ); << QStringList( QStringList() << "a" << "a" << "a" );
QTest::newRow( stri + "qua05" ) << QString("((([a-j]))?)") << QString("x") << 0 << 0 QTest::newRow( stri + "qua05" ) << QString("((([a-j]))?)") << QString("x") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua06" ) << QString("((([a-j]))?)") << QString("ab") << 0 << 1 QTest::newRow( stri + "qua06" ) << QString("((([a-j]))?)") << QString("ab") << 0 << 1
<< QStringList( QStringList() << "a" << "a" << "a" ); << QStringList( QStringList() << "a" << "a" << "a" );
QTest::newRow( stri + "qua07" ) << QString("((([a-j]))?)") << QString("xa") << 0 << 0 QTest::newRow( stri + "qua07" ) << QString("((([a-j]))?)") << QString("xa") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua08" ) << QString("((([a-j])){0,3})") << QString("") << 0 << 0 QTest::newRow( stri + "qua08" ) << QString("((([a-j])){0,3})") << QString("") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua09" ) << QString("((([a-j])){0,3})") << QString("a") << 0 << 1 QTest::newRow( stri + "qua09" ) << QString("((([a-j])){0,3})") << QString("a") << 0 << 1
<< QStringList( QStringList() << "a" << "a" << "a" ); << QStringList( QStringList() << "a" << "a" << "a" );
QTest::newRow( stri + "qua10" ) << QString("((([a-j])){0,3})") << QString("abcd") << 0 << 3 QTest::newRow( stri + "qua10" ) << QString("((([a-j])){0,3})") << QString("abcd") << 0 << 3
<< QStringList( QStringList() << "abc" << "c" << "c" ); << QStringList( QStringList() << "abc" << "c" << "c" );
QTest::newRow( stri + "qua11" ) << QString("((([a-j])){0,3})") << QString("abcde") << 0 << 3 QTest::newRow( stri + "qua11" ) << QString("((([a-j])){0,3})") << QString("abcde") << 0 << 3
<< QStringList( QStringList() << "abc" << "c" << "c" ); << QStringList( QStringList() << "abc" << "c" << "c" );
QTest::newRow( stri + "qua12" ) << QString("((([a-j])){2,4})") << QString("a") << -1 << -1 QTest::newRow( stri + "qua12" ) << QString("((([a-j])){2,4})") << QString("a") << -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() ); << QString() );
QTest::newRow( stri + "qua13" ) << QString("((([a-j])){2,4})") << QString("ab") << 0 << 2 QTest::newRow( stri + "qua13" ) << QString("((([a-j])){2,4})") << QString("ab") << 0 << 2
<< QStringList( QStringList() << "ab" << "b" << "b" ); << QStringList( QStringList() << "ab" << "b" << "b" );
QTest::newRow( stri + "qua14" ) << QString("((([a-j])){2,4})") << QString("abcd") << 0 << 4 QTest::newRow( stri + "qua14" ) << QString("((([a-j])){2,4})") << QString("abcd") << 0 << 4
<< QStringList( QStringList() << "abcd" << "d" << "d" ); << QStringList( QStringList() << "abcd" << "d" << "d" );
QTest::newRow( stri + "qua15" ) << QString("((([a-j])){2,4})") << QString("abcdef") << 0 << 4 QTest::newRow( stri + "qua15" ) << QString("((([a-j])){2,4})") << QString("abcdef") << 0 << 4
<< QStringList( QStringList() << "abcd" << "d" << "d" ); << QStringList( QStringList() << "abcd" << "d" << "d" );
QTest::newRow( stri + "qua16" ) << QString("((([a-j])){2,4})") << QString("xaybcd") << 3 << 3 QTest::newRow( stri + "qua16" ) << QString("((([a-j])){2,4})") << QString("xaybcd") << 3 << 3
<< QStringList( QStringList() << "bcd" << "d" << "d" ); << QStringList( QStringList() << "bcd" << "d" << "d" );
QTest::newRow( stri + "qua17" ) << QString("((([a-j])){0,})") << QString("abcdefgh") << 0 << 8 QTest::newRow( stri + "qua17" ) << QString("((([a-j])){0,})") << QString("abcdefgh") << 0 << 8
<< QStringList( QStringList() << "abcdefgh" << "h" << "h" ); << QStringList( QStringList() << "abcdefgh" << "h" << "h" );
QTest::newRow( stri + "qua18" ) << QString("((([a-j])){,0})") << QString("abcdefgh") << 0 << 0 QTest::newRow( stri + "qua18" ) << QString("((([a-j])){,0})") << QString("abcdefgh") << 0 << 0
<< QStringList( QStringList() << "" << "" << "" ); << QStringList( QStringList() << "" << "" << "" );
QTest::newRow( stri + "qua19" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("123332333") << 0 QTest::newRow( stri + "qua19" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("123332333") << 0
<< 9 << 9
<< QStringList( QStringList() << "123332333" << "2333" << QStringList( QStringList() << "123332333" << "2333"
<< "3" ); << "3" );
QTest::newRow( stri + "qua20" ) << QString("(1(2(3){3,4}){2,3}){1,2}") QTest::newRow( stri + "qua20" ) << QString("(1(2(3){3,4}){2,3}){1,2}")
<< QString("12333323333233331233332333323333") << 0 << 32 << QString("12333323333233331233332333323333") << 0 << 32
<< QStringList( QStringList() << "1233332333323333" << QStringList( QStringList() << "1233332333323333"
<< "23333" << "3" ); << "23333" << "3" );
QTest::newRow( stri + "qua21" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("") << -1 << -1 QTest::newRow( stri + "qua21" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("") << -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() ); << QString() );
QTest::newRow( stri + "qua22" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333") << -1 QTest::newRow( stri + "qua22" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333") << -1
<< -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() ); << QString() );
QTest::newRow( stri + "qua23" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333233") << -1 QTest::newRow( stri + "qua23" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333233") << -1
<< -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() ); << QString() );
QTest::newRow( stri + "qua24" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("122333") << -1 QTest::newRow( stri + "qua24" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("122333") << -1
<< -1 << -1
<< QStringList( QStringList() << QString() << QStringList( QStringList() << QString()
<< QString() << QString()
<< QString() ); << QString() );
// star operator // star operator
QTest::newRow( stri + "star00" ) << QString("(?:)*") << QString("") << 0 << 0 << QStringList(); QTest::newRow( stri + "star00" ) << QString("(?:)*") << QString("") << 0 << 0 << QStringList();
@ -476,28 +467,28 @@ void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri)
QTest::newRow( stri + "star03" ) << QString("(?:a)*") << QString("a") << 0 << 1 << QStringList(); QTest::newRow( stri + "star03" ) << QString("(?:a)*") << QString("a") << 0 << 1 << QStringList();
QTest::newRow( stri + "star04" ) << QString("(?:a)*") << QString("aaa") << 0 << 3 << QStringList(); QTest::newRow( stri + "star04" ) << QString("(?:a)*") << QString("aaa") << 0 << 3 << QStringList();
QTest::newRow( stri + "star05" ) << QString("(?:a)*") << QString("bbbbaaa") << 0 << 0 QTest::newRow( stri + "star05" ) << QString("(?:a)*") << QString("bbbbaaa") << 0 << 0
<< QStringList(); << QStringList();
QTest::newRow( stri + "star06" ) << QString("(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 0 QTest::newRow( stri + "star06" ) << QString("(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 0
<< QStringList(); << QStringList();
QTest::newRow( stri + "star07" ) << QString("(?:b)*(?:a)*") << QString("") << 0 << 0 QTest::newRow( stri + "star07" ) << QString("(?:b)*(?:a)*") << QString("") << 0 << 0
<< QStringList(); << QStringList();
QTest::newRow( stri + "star08" ) << QString("(?:b)*(?:a)*") << QString("a") << 0 << 1 QTest::newRow( stri + "star08" ) << QString("(?:b)*(?:a)*") << QString("a") << 0 << 1
<< QStringList(); << QStringList();
QTest::newRow( stri + "star09" ) << QString("(?:b)*(?:a)*") << QString("aaa") << 0 << 3 QTest::newRow( stri + "star09" ) << QString("(?:b)*(?:a)*") << QString("aaa") << 0 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "star10" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaa") << 0 << 7 QTest::newRow( stri + "star10" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaa") << 0 << 7
<< QStringList(); << QStringList();
QTest::newRow( stri + "star11" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 7 QTest::newRow( stri + "star11" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 7
<< QStringList(); << QStringList();
QTest::newRow( stri + "star12" ) << QString("(?:a|b)*") << QString("c") << 0 << 0 << QStringList(); QTest::newRow( stri + "star12" ) << QString("(?:a|b)*") << QString("c") << 0 << 0 << QStringList();
QTest::newRow( stri + "star13" ) << QString("(?:a|b)*") << QString("abac") << 0 << 3 QTest::newRow( stri + "star13" ) << QString("(?:a|b)*") << QString("abac") << 0 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "star14" ) << QString("(?:a|b|)*") << QString("c") << 0 << 0 QTest::newRow( stri + "star14" ) << QString("(?:a|b|)*") << QString("c") << 0 << 0
<< QStringList(); << QStringList();
QTest::newRow( stri + "star15" ) << QString("(?:a|b|)*") << QString("abac") << 0 << 3 QTest::newRow( stri + "star15" ) << QString("(?:a|b|)*") << QString("abac") << 0 << 3
<< QStringList(); << QStringList();
QTest::newRow( stri + "star16" ) << QString("(?:ab|ba|b)*") << QString("abbbababbbaaab") << 0 << 11 QTest::newRow( stri + "star16" ) << QString("(?:ab|ba|b)*") << QString("abbbababbbaaab") << 0 << 11
<< QStringList(); << QStringList();
} }
/* /*
@ -544,19 +535,19 @@ void tst_QRegExp::exactMatch()
QRegExp rx_W( "\\W" ); QRegExp rx_W( "\\W" );
for ( int i = 0; i < 65536; i++ ) { for ( int i = 0; i < 65536; i++ ) {
QChar ch( i ); QChar ch( i );
bool is_d = ( ch.category() == QChar::Number_DecimalDigit ); bool is_d = ( ch.category() == QChar::Number_DecimalDigit );
bool is_s = ch.isSpace(); bool is_s = ch.isSpace();
bool is_w = ( ch.isLetterOrNumber() bool is_w = ( ch.isLetterOrNumber()
|| ch.isMark() || ch.isMark()
|| ch == '_' ); || ch == '_' );
QVERIFY( rx_d.exactMatch(QString(ch)) == is_d ); QVERIFY( rx_d.exactMatch(QString(ch)) == is_d );
QVERIFY( rx_s.exactMatch(QString(ch)) == is_s ); QVERIFY( rx_s.exactMatch(QString(ch)) == is_s );
QVERIFY( rx_w.exactMatch(QString(ch)) == is_w ); QVERIFY( rx_w.exactMatch(QString(ch)) == is_w );
QVERIFY( rx_D.exactMatch(QString(ch)) != is_d ); QVERIFY( rx_D.exactMatch(QString(ch)) != is_d );
QVERIFY( rx_S.exactMatch(QString(ch)) != is_s ); QVERIFY( rx_S.exactMatch(QString(ch)) != is_s );
QVERIFY( rx_W.exactMatch(QString(ch)) != is_w ); QVERIFY( rx_W.exactMatch(QString(ch)) != is_w );
} }
} }
@ -652,9 +643,9 @@ void tst_QRegExp::indexIn()
QCOMPARE( mypos, pos ); QCOMPARE( mypos, pos );
QCOMPARE( mylen, len ); QCOMPARE( mylen, len );
if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) { if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) {
QCOMPARE( mycaps.count(), caps.count() ); QCOMPARE( mycaps.count(), caps.count() );
for ( int i = 1; i < (int) mycaps.count(); i++ ) for ( int i = 1; i < (int) mycaps.count(); i++ )
QCOMPARE( mycaps[i], caps[i] ); QCOMPARE( mycaps[i], caps[i] );
} }
} }
@ -670,9 +661,9 @@ void tst_QRegExp::indexIn()
QCOMPARE( mypos, pos ); QCOMPARE( mypos, pos );
QCOMPARE( mylen, len ); QCOMPARE( mylen, len );
if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) { if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) {
QCOMPARE( mycaps.count(), caps.count() ); QCOMPARE( mycaps.count(), caps.count() );
for ( int i = 1; i < (int) mycaps.count(); i++ ) for ( int i = 1; i < (int) mycaps.count(); i++ )
QCOMPARE( mycaps[i], caps[i] ); QCOMPARE( mycaps[i], caps[i] );
} }
} }
} }
@ -702,14 +693,14 @@ void tst_QRegExp::lastIndexIn()
QStringList mycaps = rx.capturedTexts(); QStringList mycaps = rx.capturedTexts();
if ( mypos <= pos || pos == -1 ) { if ( mypos <= pos || pos == -1 ) {
QCOMPARE( mypos, pos ); QCOMPARE( mypos, pos );
QCOMPARE( mylen, len ); QCOMPARE( mylen, len );
if (caps.size() > 1 && caps[1] != "IGNORE ME") { if (caps.size() > 1 && caps[1] != "IGNORE ME") {
QCOMPARE( mycaps.count(), caps.count() ); QCOMPARE( mycaps.count(), caps.count() );
for ( int i = 1; i < (int) mycaps.count(); i++ ) for ( int i = 1; i < (int) mycaps.count(); i++ )
QCOMPARE( mycaps[i], caps[i] ); QCOMPARE( mycaps[i], caps[i] );
} }
} }
} }
@ -722,14 +713,14 @@ void tst_QRegExp::lastIndexIn()
QStringList mycaps = rx.capturedTexts(); QStringList mycaps = rx.capturedTexts();
if ( mypos <= pos || pos == -1 ) { if ( mypos <= pos || pos == -1 ) {
QCOMPARE( mypos, pos ); QCOMPARE( mypos, pos );
QCOMPARE( mylen, len ); QCOMPARE( mylen, len );
if (caps.size() > 1 && caps[1] != "IGNORE ME") { if (caps.size() > 1 && caps[1] != "IGNORE ME") {
QCOMPARE( mycaps.count(), caps.count() ); QCOMPARE( mycaps.count(), caps.count() );
for ( int i = 1; i < (int) mycaps.count(); i++ ) for ( int i = 1; i < (int) mycaps.count(); i++ )
QCOMPARE( mycaps[i], caps[i] ); QCOMPARE( mycaps[i], caps[i] );
} }
} }
} }
} }
@ -924,8 +915,8 @@ void tst_QRegExp::testEscapingWildcard_data(){
QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true; QTest::newRow("a true '\\' in input") << "\\Qt;" << "\\Qt;" << true;
QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true; QTest::newRow("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true;
QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true; QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true;
} }
void tst_QRegExp::testEscapingWildcard(){ void tst_QRegExp::testEscapingWildcard(){
QFETCH(QString, pattern); QFETCH(QString, pattern);
@ -949,8 +940,8 @@ void tst_QRegExp::testInvalidWildcard_data(){
QTest::newRow("ending [\\") << "abc[\\" << false; QTest::newRow("ending [\\") << "abc[\\" << false;
QTest::newRow("ending []") << "abc[]" << false; QTest::newRow("ending []") << "abc[]" << false;
QTest::newRow("ending [[") << "abc[[" << false; QTest::newRow("ending [[") << "abc[[" << false;
} }
void tst_QRegExp::testInvalidWildcard(){ void tst_QRegExp::testInvalidWildcard(){
QFETCH(QString, pattern); QFETCH(QString, pattern);
@ -1018,7 +1009,7 @@ void tst_QRegExp::rainersSlowRegExpCopyBug()
// this test should take an extreme amount of time if QRegExp is broken // this test should take an extreme amount of time if QRegExp is broken
QRegExp original(email); QRegExp original(email);
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) {
#else #else
for (int i = 0; i < 100000; ++i) { for (int i = 0; i < 100000; ++i) {
#endif #endif
@ -1071,7 +1062,7 @@ void Thread::run()
int x; int x;
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
for (int j = 0; j < 100; ++j) { for (int j = 0; j < 100; ++j) {
#else #else
for (int j = 0; j < 10000; ++j) { for (int j = 0; j < 10000; ++j) {
#endif #endif
@ -1113,7 +1104,7 @@ void Thread2::run()
int x; int x;
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
for (int j = 0; j < 100; ++j) { for (int j = 0; j < 100; ++j) {
#else #else
for (int j = 0; j < 10000; ++j) { for (int j = 0; j < 10000; ++j) {
#endif #endif

View File

@ -165,11 +165,11 @@ void tst_QSize::expandedTo_data()
QTest::addColumn<QSize>("input2"); QTest::addColumn<QSize>("input2");
QTest::addColumn<QSize>("expected"); QTest::addColumn<QSize>("expected");
QTest::newRow("data0") << QSize(10,12) << QSize(6,4) << QSize(10,12); QTest::newRow("data0") << QSize(10,12) << QSize(6,4) << QSize(10,12);
QTest::newRow("data1") << QSize(0,0) << QSize(6,4) << QSize(6,4); QTest::newRow("data1") << QSize(0,0) << QSize(6,4) << QSize(6,4);
// This should pick the highest of w,h components independently of each other, // This should pick the highest of w,h components independently of each other,
// thus the results don't have to be equal to neither input1 nor input2. // thus the results don't have to be equal to neither input1 nor input2.
QTest::newRow("data3") << QSize(6,4) << QSize(4,6) << QSize(6,6); QTest::newRow("data3") << QSize(6,4) << QSize(4,6) << QSize(6,6);
} }
void tst_QSize::expandedTo() void tst_QSize::expandedTo()
@ -187,11 +187,11 @@ void tst_QSize::boundedTo_data()
QTest::addColumn<QSize>("input2"); QTest::addColumn<QSize>("input2");
QTest::addColumn<QSize>("expected"); QTest::addColumn<QSize>("expected");
QTest::newRow("data0") << QSize(10,12) << QSize(6,4) << QSize(6,4); QTest::newRow("data0") << QSize(10,12) << QSize(6,4) << QSize(6,4);
QTest::newRow("data1") << QSize(0,0) << QSize(6,4) << QSize(0,0); QTest::newRow("data1") << QSize(0,0) << QSize(6,4) << QSize(0,0);
// This should pick the lowest of w,h components independently of each other, // This should pick the lowest of w,h components independently of each other,
// thus the results don't have to be equal to neither input1 nor input2. // thus the results don't have to be equal to neither input1 nor input2.
QTest::newRow("data3") << QSize(6,4) << QSize(4,6) << QSize(4,4); QTest::newRow("data3") << QSize(6,4) << QSize(4,6) << QSize(4,4);
} }
void tst_QSize::boundedTo() void tst_QSize::boundedTo()
@ -209,8 +209,8 @@ void tst_QSize::transpose_data()
QTest::addColumn<QSize>("expected"); QTest::addColumn<QSize>("expected");
QTest::newRow("data0") << QSize(10,12) << QSize(12,10); QTest::newRow("data0") << QSize(10,12) << QSize(12,10);
QTest::newRow("data1") << QSize(0,0) << QSize(0,0); QTest::newRow("data1") << QSize(0,0) << QSize(0,0);
QTest::newRow("data3") << QSize(6,4) << QSize(4,6); QTest::newRow("data3") << QSize(6,4) << QSize(4,6);
} }
void tst_QSize::transpose() void tst_QSize::transpose()

View File

@ -562,19 +562,19 @@ void tst_QString::utf8_data()
QTest::addColumn<QString>("res" ); QTest::addColumn<QString>("res" );
QTest::newRow( "str0" ) << QByteArray("abcdefgh") QTest::newRow( "str0" ) << QByteArray("abcdefgh")
<< QString("abcdefgh"); << QString("abcdefgh");
QTest::newRow( "str1" ) << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") QTest::newRow( "str1" ) << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205")
<< QString("\366\344\374\326\304\334\370\346\345\330\306\305") ; << QString("\366\344\374\326\304\334\370\346\345\330\306\305") ;
str += QChar( 0x05e9 ); str += QChar( 0x05e9 );
str += QChar( 0x05d3 ); str += QChar( 0x05d3 );
str += QChar( 0x05d2 ); str += QChar( 0x05d2 );
QTest::newRow( "str2" ) << QByteArray("\327\251\327\223\327\222") QTest::newRow( "str2" ) << QByteArray("\327\251\327\223\327\222")
<< str; << str;
str = QChar( 0x20ac ); str = QChar( 0x20ac );
str += " some text"; str += " some text";
QTest::newRow( "str3" ) << QByteArray("\342\202\254 some text") QTest::newRow( "str3" ) << QByteArray("\342\202\254 some text")
<< str; << str;
str = "Old Italic: "; str = "Old Italic: ";
str += QChar(0xd800); str += QChar(0xd800);
@ -710,14 +710,14 @@ void tst_QString::acc_01()
QVERIFY(*a.toLatin1().constData() == '\0'); QVERIFY(*a.toLatin1().constData() == '\0');
{ {
#if defined(Q_OS_WINCE) #if defined(Q_OS_WINCE)
int argc = 0; int argc = 0;
QCoreApplication app(argc, 0); QCoreApplication app(argc, 0);
#endif #endif
QFile f("COMPARE.txt"); QFile f("COMPARE.txt");
f.open(QIODevice::ReadOnly); f.open(QIODevice::ReadOnly);
QTextStream ts( &f ); QTextStream ts( &f );
ts.setCodec(QTextCodec::codecForName("UTF-16")); ts.setCodec(QTextCodec::codecForName("UTF-16"));
ts << "Abc"; ts << "Abc";
} }
} }
@ -775,8 +775,6 @@ void tst_QString::constructor()
QVERIFY( empty.isEmpty() ); QVERIFY( empty.isEmpty() );
} }
void tst_QString::constructorQByteArray_data() void tst_QString::constructorQByteArray_data()
{ {
QTest::addColumn<QByteArray>("src" ); QTest::addColumn<QByteArray>("src" );
@ -1187,17 +1185,17 @@ void tst_QString::indexOf2()
QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseInsensitive), resultpos ); QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseInsensitive), resultpos );
QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos ); QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos );
if ( needle.length() > 0 ) { if ( needle.length() > 0 ) {
got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive ); got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive );
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) ); QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
got = haystack.lastIndexOf( needle, -1, Qt::CaseInsensitive ); got = haystack.lastIndexOf( needle, -1, Qt::CaseInsensitive );
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) ); QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
} }
QCOMPARE( chaystack.indexOf(cneedle, 0), resultpos ); QCOMPARE( chaystack.indexOf(cneedle, 0), resultpos );
QCOMPARE( QByteArrayMatcher(cneedle).indexIn(chaystack, 0), resultpos ); QCOMPARE( QByteArrayMatcher(cneedle).indexIn(chaystack, 0), resultpos );
if ( cneedle.length() > 0 ) { if ( cneedle.length() > 0 ) {
got = chaystack.lastIndexOf(cneedle, -1); got = chaystack.lastIndexOf(cneedle, -1);
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) ); QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
} }
} }
@ -1778,22 +1776,22 @@ void tst_QString::append_bytearray_data()
void tst_QString::append_bytearray() void tst_QString::append_bytearray()
{ {
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
str.append( ba ); str.append( ba );
QTEST( str, "res" ); QTEST( str, "res" );
} }
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str.append( ba ); str.append( ba );
QTextCodec::setCodecForCStrings( 0 ); QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" ); QTEST( str, "res" );
} }
} }
@ -1805,22 +1803,22 @@ void tst_QString::operator_pluseq_bytearray_data()
void tst_QString::operator_pluseq_bytearray() void tst_QString::operator_pluseq_bytearray()
{ {
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
str += ba; str += ba;
QTEST( str, "res" ); QTEST( str, "res" );
} }
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str += ba; str += ba;
QTextCodec::setCodecForCStrings( 0 ); QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" ); QTEST( str, "res" );
} }
} }
@ -1866,23 +1864,23 @@ void tst_QString::prepend_bytearray_data()
void tst_QString::prepend_bytearray() void tst_QString::prepend_bytearray()
{ {
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
str.prepend( ba ); str.prepend( ba );
QFETCH( QString, res ); QFETCH( QString, res );
QCOMPARE( str, res ); QCOMPARE( str, res );
} }
{ {
QFETCH( QString, str ); QFETCH( QString, str );
QFETCH( QByteArray, ba ); QFETCH( QByteArray, ba );
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1 QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
str.prepend( ba ); str.prepend( ba );
QTextCodec::setCodecForCStrings( 0 ); QTextCodec::setCodecForCStrings( 0 );
QTEST( str, "res" ); QTEST( str, "res" );
} }
} }
@ -1902,13 +1900,13 @@ void tst_QString::replace_uint_uint()
QTEST( s2, "result" ); QTEST( s2, "result" );
if ( after.length() == 1 ) { if ( after.length() == 1 ) {
QString s3 = string; QString s3 = string;
s3.replace( (uint) index, (uint) len, QChar(after[0]) ); s3.replace( (uint) index, (uint) len, QChar(after[0]) );
QTEST( s3, "result" ); QTEST( s3, "result" );
QString s4 = string; QString s4 = string;
s4.replace( (uint) index, (uint) len, QChar(after[0]).toLatin1() ); s4.replace( (uint) index, (uint) len, QChar(after[0]).toLatin1() );
QTEST( s4, "result" ); QTEST( s4, "result" );
} }
} }
@ -1961,17 +1959,17 @@ void tst_QString::replace_string()
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive; Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
if ( before.length() == 1 ) { if ( before.length() == 1 ) {
QChar ch = before.at( 0 ); QChar ch = before.at( 0 );
QString s1 = string; QString s1 = string;
s1.replace( ch, after, cs ); s1.replace( ch, after, cs );
QTEST( s1, "result" ); QTEST( s1, "result" );
if ( QChar(ch.toLatin1()) == ch ) { if ( QChar(ch.toLatin1()) == ch ) {
QString s2 = string; QString s2 = string;
s2.replace( ch.toLatin1(), after, cs ); s2.replace( ch.toLatin1(), after, cs );
QTEST( s2, "result" ); QTEST( s2, "result" );
} }
} }
QString s3 = string; QString s3 = string;
@ -2006,11 +2004,11 @@ void tst_QString::remove_uint_uint()
QFETCH( QString, after ); QFETCH( QString, after );
if ( after.length() == 0 ) { if ( after.length() == 0 ) {
QString s1 = string; QString s1 = string;
s1.remove( (uint) index, (uint) len ); s1.remove( (uint) index, (uint) len );
QTEST( s1, "result" ); QTEST( s1, "result" );
} else } else
QCOMPARE( 0, 0 ); // shut QtTest QCOMPARE( 0, 0 ); // shut QtTest
} }
void tst_QString::remove_string() void tst_QString::remove_string()
@ -2023,33 +2021,33 @@ void tst_QString::remove_string()
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive; Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
if ( after.length() == 0 ) { if ( after.length() == 0 ) {
if ( before.length() == 1 && cs ) { if ( before.length() == 1 && cs ) {
QChar ch = before.at( 0 ); QChar ch = before.at( 0 );
QString s1 = string; QString s1 = string;
s1.remove( ch ); s1.remove( ch );
QTEST( s1, "result" ); QTEST( s1, "result" );
if ( QChar(ch.toLatin1()) == ch ) { if ( QChar(ch.toLatin1()) == ch ) {
QString s2 = string; QString s2 = string;
s2.remove( ch ); s2.remove( ch );
QTEST( s2, "result" ); QTEST( s2, "result" );
} }
} }
QString s3 = string; QString s3 = string;
s3.remove( before, cs ); s3.remove( before, cs );
QTEST( s3, "result" ); QTEST( s3, "result" );
QString s4 = string; QString s4 = string;
s4.replace( QRegExp(QRegExp::escape(before), cs), after ); s4.replace( QRegExp(QRegExp::escape(before), cs), after );
QTEST( s4, "result" ); QTEST( s4, "result" );
QString s5 = string; QString s5 = string;
s5.replace( QRegExp(before, cs, QRegExp::FixedString), after ); s5.replace( QRegExp(before, cs, QRegExp::FixedString), after );
QTEST( s5, "result" ); QTEST( s5, "result" );
} else { } else {
QCOMPARE( 0, 0 ); // shut QtTest QCOMPARE( 0, 0 ); // shut QtTest
} }
} }
@ -2060,10 +2058,10 @@ void tst_QString::remove_regexp()
QFETCH( QString, after ); QFETCH( QString, after );
if ( after.length() == 0 ) { if ( after.length() == 0 ) {
string.remove( QRegExp(regexp) ); string.remove( QRegExp(regexp) );
QTEST( string, "result" ); QTEST( string, "result" );
} else { } else {
QCOMPARE( 0, 0 ); // shut QtTest QCOMPARE( 0, 0 ); // shut QtTest
} }
} }
@ -2354,15 +2352,15 @@ void tst_QString::toUShort()
QVERIFY(ok); QVERIFY(ok);
if (sizeof(short) == 2) { if (sizeof(short) == 2) {
a = "65536"; a = "65536";
QCOMPARE(a.toUShort(),(ushort)0); QCOMPARE(a.toUShort(),(ushort)0);
QCOMPARE(a.toUShort(&ok),(ushort)0); QCOMPARE(a.toUShort(&ok),(ushort)0);
QVERIFY(!ok); QVERIFY(!ok);
a = "123456"; a = "123456";
QCOMPARE(a.toUShort(),(ushort)0); QCOMPARE(a.toUShort(),(ushort)0);
QCOMPARE(a.toUShort(&ok),(ushort)0); QCOMPARE(a.toUShort(&ok),(ushort)0);
QVERIFY(!ok); QVERIFY(!ok);
} }
} }
@ -2430,15 +2428,15 @@ void tst_QString::toShort()
QVERIFY(ok); QVERIFY(ok);
if (sizeof(short) == 2) { if (sizeof(short) == 2) {
a = "32768"; a = "32768";
QCOMPARE(a.toShort(),(short)0); QCOMPARE(a.toShort(),(short)0);
QCOMPARE(a.toShort(&ok),(short)0); QCOMPARE(a.toShort(&ok),(short)0);
QVERIFY(!ok); QVERIFY(!ok);
a = "-32769"; a = "-32769";
QCOMPARE(a.toShort(),(short)0); QCOMPARE(a.toShort(),(short)0);
QCOMPARE(a.toShort(&ok),(short)0); QCOMPARE(a.toShort(&ok),(short)0);
QVERIFY(!ok); QVERIFY(!ok);
} }
} }
@ -2506,25 +2504,25 @@ void tst_QString::toInt()
QVERIFY(ok); QVERIFY(ok);
if (sizeof(int) == 4) { if (sizeof(int) == 4) {
a = "-2147483647"; // -(2**31 - 1) a = "-2147483647"; // -(2**31 - 1)
QCOMPARE(a.toInt(),-2147483647); QCOMPARE(a.toInt(),-2147483647);
QCOMPARE(a.toInt(&ok),-2147483647); QCOMPARE(a.toInt(&ok),-2147483647);
QVERIFY(ok); QVERIFY(ok);
a = "2147483648"; // 2**31 a = "2147483648"; // 2**31
QCOMPARE(a.toInt(),0); QCOMPARE(a.toInt(),0);
QCOMPARE(a.toInt(&ok),0); QCOMPARE(a.toInt(&ok),0);
QVERIFY(!ok); QVERIFY(!ok);
a = "-2147483648"; // -2**31 a = "-2147483648"; // -2**31
QCOMPARE(a.toInt(),-2147483647 - 1); QCOMPARE(a.toInt(),-2147483647 - 1);
QCOMPARE(a.toInt(&ok),-2147483647 - 1); QCOMPARE(a.toInt(&ok),-2147483647 - 1);
QVERIFY(ok); QVERIFY(ok);
a = "2147483649"; // 2**31 + 1 a = "2147483649"; // 2**31 + 1
QCOMPARE(a.toInt(),0); QCOMPARE(a.toInt(),0);
QCOMPARE(a.toInt(&ok),0); QCOMPARE(a.toInt(&ok),0);
QVERIFY(!ok); QVERIFY(!ok);
} }
} }
@ -2547,10 +2545,10 @@ void tst_QString::toUInt()
QVERIFY(ok); QVERIFY(ok);
if (sizeof(int) == 4) { if (sizeof(int) == 4) {
a = "4294967296"; // 2**32 a = "4294967296"; // 2**32
QCOMPARE(a.toUInt(),0u); QCOMPARE(a.toUInt(),0u);
QCOMPARE(a.toUInt(&ok),0u); QCOMPARE(a.toUInt(&ok),0u);
QVERIFY(!ok); QVERIFY(!ok);
} }
} }
@ -2649,9 +2647,9 @@ void tst_QString::toLongLong()
str = "-9223372036854775808"; // LLONG_MIN str = "-9223372036854775808"; // LLONG_MIN
QCOMPARE( str.toLongLong( 0 ), QCOMPARE( str.toLongLong( 0 ),
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) ); -Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
QCOMPARE( str.toLongLong( &ok ), QCOMPARE( str.toLongLong( &ok ),
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) ); -Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
QVERIFY( ok ); QVERIFY( ok );
str = "aaaa9223372036854775807aaaa"; str = "aaaa9223372036854775807aaaa";
@ -2738,10 +2736,10 @@ void tst_QString::toDouble()
bool ok; bool ok;
double d = str.toDouble( &ok ); double d = str.toDouble( &ok );
if ( result_ok ) { if ( result_ok ) {
QTEST( d, "result" ); QTEST( d, "result" );
QVERIFY( ok ); QVERIFY( ok );
} else { } else {
QVERIFY( !ok ); QVERIFY( !ok );
} }
} }
@ -2770,11 +2768,11 @@ void tst_QString::setNum()
QCOMPARE(a.setNum(Q_INT64_C(-1099511627776)), QString("-1099511627776")); QCOMPARE(a.setNum(Q_INT64_C(-1099511627776)), QString("-1099511627776"));
QCOMPARE(a.setNum(Q_UINT64_C(1099511627776)), QString("1099511627776")); QCOMPARE(a.setNum(Q_UINT64_C(1099511627776)), QString("1099511627776"));
QCOMPARE(a.setNum(Q_INT64_C(9223372036854775807)), // LLONG_MAX QCOMPARE(a.setNum(Q_INT64_C(9223372036854775807)), // LLONG_MAX
QString("9223372036854775807")); QString("9223372036854775807"));
QCOMPARE(a.setNum(-Q_INT64_C(9223372036854775807) - Q_INT64_C(1)), QCOMPARE(a.setNum(-Q_INT64_C(9223372036854775807) - Q_INT64_C(1)),
QString("-9223372036854775808")); QString("-9223372036854775808"));
QCOMPARE(a.setNum(Q_UINT64_C(18446744073709551615)), // ULLONG_MAX QCOMPARE(a.setNum(Q_UINT64_C(18446744073709551615)), // ULLONG_MAX
QString("18446744073709551615")); QString("18446744073709551615"));
QCOMPARE(a.setNum(0.000000000931322574615478515625),QString("9.31323e-10")); QCOMPARE(a.setNum(0.000000000931322574615478515625),QString("9.31323e-10"));
// QCOMPARE(a.setNum(0.000000000931322574615478515625,'g',30),(QString)"9.31322574615478515625e-010"); // QCOMPARE(a.setNum(0.000000000931322574615478515625,'g',30),(QString)"9.31322574615478515625e-010");
@ -2989,8 +2987,8 @@ void tst_QString::check_QDataStream()
QString a; QString a;
QByteArray ar; QByteArray ar;
{ {
QDataStream out(&ar,QIODevice::WriteOnly); QDataStream out(&ar,QIODevice::WriteOnly);
out << QString("COMPARE Text"); out << QString("COMPARE Text");
} }
{ {
QDataStream in(&ar,QIODevice::ReadOnly); QDataStream in(&ar,QIODevice::ReadOnly);
@ -3004,13 +3002,13 @@ void tst_QString::check_QTextStream()
QString a; QString a;
QByteArray ar; QByteArray ar;
{ {
QTextStream out(&ar,QIODevice::WriteOnly); QTextStream out(&ar,QIODevice::WriteOnly);
out << QString("This is COMPARE Text"); out << QString("This is COMPARE Text");
} }
{ {
QTextStream in(&ar,QIODevice::ReadOnly); QTextStream in(&ar,QIODevice::ReadOnly);
in >> a; in >> a;
QCOMPARE(a,(QString)"This"); QCOMPARE(a,(QString)"This");
} }
} }
@ -3018,17 +3016,17 @@ void tst_QString::check_QTextIOStream()
{ {
QString a; QString a;
{ {
a=""; a="";
QTextStream ts(&a); QTextStream ts(&a);
ts << "pi \261= " << 3.125; ts << "pi \261= " << 3.125;
QCOMPARE(a,(QString)"pi \261= 3.125"); QCOMPARE(a,(QString)"pi \261= 3.125");
} }
{ {
a="123 456"; a="123 456";
int x,y; int x,y;
QTextStream(&a) >> x >> y; QTextStream(&a) >> x >> y;
QCOMPARE(x,123); QCOMPARE(x,123);
QCOMPARE(y,456); QCOMPARE(y,456);
} }
} }
@ -3256,8 +3254,8 @@ void tst_QString::fromLocal8Bit_data()
QString longQString; QString longQString;
for (int l=0;l<111;l++) { for (int l=0;l<111;l++) {
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
} }
//QTest::newRow("longString") << longQByteArray << -1 << longQString; //QTest::newRow("longString") << longQByteArray << -1 << longQString;
@ -3303,8 +3301,8 @@ void tst_QString::local8Bit_data()
QString longQString; QString longQString;
for (int l=0;l<111;l++) { for (int l=0;l<111;l++) {
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
} }
QTest::newRow("longString") << longQString << longQByteArray; QTest::newRow("longString") << longQString << longQByteArray;
@ -3569,7 +3567,7 @@ void tst_QString::arg()
QString firstName( "James" ); QString firstName( "James" );
QString lastName( "Bond" ); QString lastName( "Bond" );
QString fullName = QString( "My name is %2, %1 %2" ) QString fullName = QString( "My name is %2, %1 %2" )
.arg( firstName ).arg( lastName ); .arg( firstName ).arg( lastName );
QCOMPARE( fullName, QString("My name is Bond, James Bond") ); QCOMPARE( fullName, QString("My name is Bond, James Bond") );
// number overloads // number overloads
@ -3577,7 +3575,7 @@ void tst_QString::arg()
QCOMPARE( s4.arg(-1), QString("[-1]") ); QCOMPARE( s4.arg(-1), QString("[-1]") );
QCOMPARE( s4.arg(4294967295UL), QString("[4294967295]") ); // ULONG_MAX 32 QCOMPARE( s4.arg(4294967295UL), QString("[4294967295]") ); // ULONG_MAX 32
QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX
QString("[9223372036854775807]") ); QString("[9223372036854775807]") );
QCOMPARE( QString().arg(0), QString() ); QCOMPARE( QString().arg(0), QString() );
QCOMPARE( QString("").arg(0), QString("") ); QCOMPARE( QString("").arg(0), QString("") );
@ -4009,7 +4007,7 @@ void tst_QString::integer_conversion()
QCOMPARE(ok, good); QCOMPARE(ok, good);
if (ok) { if (ok) {
QCOMPARE(d, num); QCOMPARE(d, num);
} }
QLocale::setDefault(QLocale::C); QLocale::setDefault(QLocale::C);
@ -4088,8 +4086,8 @@ void tst_QString::double_conversion_data()
*/ */
// Let's try some Arabic // Let's try some Arabic
const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662, const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662,
0x0663, 0x0664, 0x0065, 0x0662, 0x0663, 0x0664, 0x0065, 0x0662,
0x0000 }; // "0.1234e2" 0x0000 }; // "0.1234e2"
QTest::newRow("ar_SA") << QString("ar_SA") << QString::fromUtf16(arabic_str) << true << 0.1234e2; QTest::newRow("ar_SA") << QString("ar_SA") << QString::fromUtf16(arabic_str) << true << 0.1234e2;
} }
@ -4110,10 +4108,10 @@ void tst_QString::double_conversion()
QCOMPARE(ok, good); QCOMPARE(ok, good);
if (ok) { if (ok) {
double diff = d - num; double diff = d - num;
if (diff < 0) if (diff < 0)
diff = -diff; diff = -diff;
QVERIFY(diff <= MY_DOUBLE_EPSILON); QVERIFY(diff <= MY_DOUBLE_EPSILON);
} }
QLocale::setDefault(QLocale::C); QLocale::setDefault(QLocale::C);
@ -4130,11 +4128,11 @@ void tst_QString::tortureSprintfDouble()
QString s; QString s;
for (; data->fmt != 0; ++data) { for (; data->fmt != 0; ++data) {
double d; double d;
char *buff = (char *)&d; char *buff = (char *)&d;
# ifndef Q_BYTE_ORDER # ifndef Q_BYTE_ORDER
# error "Q_BYTE_ORDER not defined" # error "Q_BYTE_ORDER not defined"
# endif # endif
# ifdef QT_ARMFPA # ifdef QT_ARMFPA
buff[0] = data->bytes[4]; buff[0] = data->bytes[4];
@ -4145,20 +4143,20 @@ void tst_QString::tortureSprintfDouble()
buff[5] = data->bytes[1]; buff[5] = data->bytes[1];
buff[6] = data->bytes[2]; buff[6] = data->bytes[2];
buff[7] = data->bytes[3]; buff[7] = data->bytes[3];
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN # elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
for (uint i = 0; i < 8; ++i) for (uint i = 0; i < 8; ++i)
buff[i] = data->bytes[i]; buff[i] = data->bytes[i];
# else # else
for (uint i = 0; i < 8; ++i) for (uint i = 0; i < 8; ++i)
buff[7 - i] = data->bytes[i]; buff[7 - i] = data->bytes[i];
# endif # endif
s.sprintf(data->fmt, d); s.sprintf(data->fmt, d);
#ifdef QT_NO_FPU // reduced precision when running with hardfloats in qemu #ifdef QT_NO_FPU // reduced precision when running with hardfloats in qemu
if (d - 0.1 < 1e12) if (d - 0.1 < 1e12)
QSKIP("clib sprintf doesn't fill with 0's on this platform"); QSKIP("clib sprintf doesn't fill with 0's on this platform");
QCOMPARE(s.left(16), QString(data->expected).left(16)); QCOMPARE(s.left(16), QString(data->expected).left(16));
#else #else
QCOMPARE(s, QString(data->expected)); QCOMPARE(s, QString(data->expected));
#endif #endif
} }
} }
@ -4361,7 +4359,7 @@ void tst_QString::localeAwareCompare()
#else #else
if (!locale.isEmpty()) if (!locale.isEmpty())
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
#endif #endif
} }
#endif #endif
@ -4374,7 +4372,7 @@ void tst_QString::split_data()
QTest::newRow("1") << "a,b,c" << "," << (QStringList() << "a" << "b" << "c"); QTest::newRow("1") << "a,b,c" << "," << (QStringList() << "a" << "b" << "c");
QTest::newRow("2") << QString("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile") QTest::newRow("2") << QString("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile")
<< " " << " "
<< (QStringList() << "-rw-r--r--" << "" << "1" << "0" << "" << "0" << "" << (QStringList() << "-rw-r--r--" << "" << "1" << "0" << "" << "0" << ""
<< "519240" << "Jul" << "" << "9" << "" << "2002" << "bigfile"); << "519240" << "Jul" << "" << "9" << "" << "2002" << "bigfile");
QTest::newRow("one-empty") << "" << " " << (QStringList() << ""); QTest::newRow("one-empty") << "" << " " << (QStringList() << "");
@ -4580,14 +4578,14 @@ void tst_QString::arg_fillChar_data()
replaceValues << QVariant((int)5.5) << QVariant(QString("foo")) << QVariant((qulonglong)INT_MAX); replaceValues << QVariant((int)5.5) << QVariant(QString("foo")) << QVariant((qulonglong)INT_MAX);
widths << 10 << 2 << 5; widths << 10 << 2 << 5;
QTest::newRow("str1") << QString("%3.%1.%3.%2") << replaceValues << widths << QString("0 c") QTest::newRow("str1") << QString("%3.%1.%3.%2") << replaceValues << widths << QString("0 c")
<< QString("2147483647.0000000005.2147483647.foo"); << QString("2147483647.0000000005.2147483647.foo");
replaceValues.clear(); replaceValues.clear();
widths.clear(); widths.clear();
replaceValues << QVariant(QString("fisk")); replaceValues << QVariant(QString("fisk"));
widths << 100; widths << 100;
QTest::newRow("str2") << QString("%9 og poteter") << replaceValues << widths << QString("f") QTest::newRow("str2") << QString("%9 og poteter") << replaceValues << widths << QString("f")
<< QString("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffisk og poteter"); << QString("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffisk og poteter");
} }
void tst_QString::arg_fillChar() void tst_QString::arg_fillChar()
@ -4606,9 +4604,9 @@ void tst_QString::arg_fillChar()
QString actual = pattern; QString actual = pattern;
for (int i=0; i<replaceValues.count(); ++i) { for (int i=0; i<replaceValues.count(); ++i) {
const QVariant &var = replaceValues.at(i); const QVariant &var = replaceValues.at(i);
const int width = widths.at(i); const int width = widths.at(i);
const QChar &fillChar = fillChars.at(i); const QChar &fillChar = fillChars.at(i);
switch (var.type()) { switch (var.type()) {
case QVariant::String: actual = actual.arg(var.toString(), width, fillChar); break; case QVariant::String: actual = actual.arg(var.toString(), width, fillChar); break;
case QVariant::Int: actual = actual.arg(var.toInt(), width, base, fillChar); break; case QVariant::Int: actual = actual.arg(var.toInt(), width, base, fillChar); break;

View File

@ -410,20 +410,20 @@ void tst_QStringRef::indexOf2()
QCOMPARE(haystackRef.indexOf(needle, 0, Qt::CaseInsensitive), resultpos); QCOMPARE(haystackRef.indexOf(needle, 0, Qt::CaseInsensitive), resultpos);
QCOMPARE(haystackRef.indexOf(needleRef, 0, Qt::CaseInsensitive), resultpos); QCOMPARE(haystackRef.indexOf(needleRef, 0, Qt::CaseInsensitive), resultpos);
if (needle.length() > 0) { if (needle.length() > 0) {
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseSensitive); got = haystackRef.lastIndexOf(needle, -1, Qt::CaseSensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseInsensitive); got = haystackRef.lastIndexOf(needle, -1, Qt::CaseInsensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseSensitive); got = haystack.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseInsensitive); got = haystack.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseSensitive); got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseInsensitive); got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
} }
} }

View File

@ -108,9 +108,9 @@ void tst_QTimeLine::range()
QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
timeLine.start(); timeLine.start();
#ifdef Q_OS_WINCE #ifdef Q_OS_WINCE
QTest::qWait(1000); QTest::qWait(1000);
#else #else
QTest::qWait(100); QTest::qWait(100);
#endif #endif
QCOMPARE(timeLine.state(), QTimeLine::Running); QCOMPARE(timeLine.state(), QTimeLine::Running);
int oldValue = timeLine.currentFrame(); int oldValue = timeLine.currentFrame();
@ -301,7 +301,7 @@ void tst_QTimeLine::loopCount()
timeLine.stop(); timeLine.stop();
timeLine.setDuration(2500); // ### some platforms have a very low resolution timer timeLine.setDuration(2500); // ### some platforms have a very low resolution timer
timeLine.setFrameRange(0, 2); timeLine.setFrameRange(0, 2);
timeLine.setLoopCount(4); timeLine.setLoopCount(4);
QSignalSpy finishedSpy(&timeLine, SIGNAL(finished())); QSignalSpy finishedSpy(&timeLine, SIGNAL(finished()));
@ -333,9 +333,9 @@ void tst_QTimeLine::loopCount()
QCOMPARE(finishedSpy.count(), 2); QCOMPARE(finishedSpy.count(), 2);
QCOMPARE(frameChangedSpy.count(), 22); QCOMPARE(frameChangedSpy.count(), 22);
for (int i = 11; i < 22; ++i) { for (int i = 11; i < 22; ++i) {
QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i+2) % 3); QCOMPARE(frameChangedSpy.at(i).at(0).toInt(), 2 - (i+2) % 3);
} }
} }
void tst_QTimeLine::interpolation() void tst_QTimeLine::interpolation()

View File

@ -118,39 +118,39 @@ void tst_QVarLengthArray::removeLast()
void tst_QVarLengthArray::oldTests() void tst_QVarLengthArray::oldTests()
{ {
{ {
QVarLengthArray<int, 256> sa(128); QVarLengthArray<int, 256> sa(128);
QVERIFY(sa.data() == &sa[0]); QVERIFY(sa.data() == &sa[0]);
sa[0] = 0xfee; sa[0] = 0xfee;
sa[10] = 0xff; sa[10] = 0xff;
QVERIFY(sa[0] == 0xfee); QVERIFY(sa[0] == 0xfee);
QVERIFY(sa[10] == 0xff); QVERIFY(sa[10] == 0xff);
sa.resize(512); sa.resize(512);
QVERIFY(sa.data() == &sa[0]); QVERIFY(sa.data() == &sa[0]);
QVERIFY(sa[0] == 0xfee); QVERIFY(sa[0] == 0xfee);
QVERIFY(sa[10] == 0xff); QVERIFY(sa[10] == 0xff);
QVERIFY(sa.at(0) == 0xfee); QVERIFY(sa.at(0) == 0xfee);
QVERIFY(sa.at(10) == 0xff); QVERIFY(sa.at(10) == 0xff);
QVERIFY(sa.value(0) == 0xfee); QVERIFY(sa.value(0) == 0xfee);
QVERIFY(sa.value(10) == 0xff); QVERIFY(sa.value(10) == 0xff);
QVERIFY(sa.value(1000) == 0); QVERIFY(sa.value(1000) == 0);
QVERIFY(sa.value(1000, 12) == 12); QVERIFY(sa.value(1000, 12) == 12);
QVERIFY(sa.size() == 512); QVERIFY(sa.size() == 512);
sa.reserve(1024); sa.reserve(1024);
QVERIFY(sa.capacity() == 1024); QVERIFY(sa.capacity() == 1024);
QVERIFY(sa.size() == 512); QVERIFY(sa.size() == 512);
} }
{ {
QVarLengthArray<QString> sa(10); QVarLengthArray<QString> sa(10);
sa[0] = "Hello"; sa[0] = "Hello";
sa[9] = "World"; sa[9] = "World";
QVERIFY(*sa.data() == "Hello"); QVERIFY(*sa.data() == "Hello");
QVERIFY(sa[9] == "World"); QVERIFY(sa[9] == "World");
sa.reserve(512); sa.reserve(512);
QVERIFY(*sa.data() == "Hello"); QVERIFY(*sa.data() == "Hello");
QVERIFY(sa[9] == "World"); QVERIFY(sa[9] == "World");
sa.resize(512); sa.resize(512);
QVERIFY(*sa.data() == "Hello"); QVERIFY(*sa.data() == "Hello");
QVERIFY(sa[9] == "World"); QVERIFY(sa[9] == "World");
} }
{ {
int arr[2] = {1, 2}; int arr[2] = {1, 2};