Cleanup corelib autotests
Remove literal tabs. Change-Id: I210a0259773cceb20d35ebc80b889e3ebb88b540 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
2cd4710715
commit
8e11f7c93a
@ -351,7 +351,7 @@ void tst_QParallelAnimationGroup::stateChanged()
|
||||
void tst_QParallelAnimationGroup::clearGroup()
|
||||
{
|
||||
QParallelAnimationGroup group;
|
||||
static const int animationCount = 10;
|
||||
static const int animationCount = 10;
|
||||
|
||||
for (int i = 0; i < animationCount; ++i) {
|
||||
new QParallelAnimationGroup(&group);
|
||||
|
@ -923,7 +923,7 @@ void tst_QSequentialAnimationGroup::clearGroup()
|
||||
{
|
||||
QSequentialAnimationGroup group;
|
||||
|
||||
static const int animationCount = 20;
|
||||
static const int animationCount = 20;
|
||||
|
||||
for (int i = 0; i < animationCount/2; ++i) {
|
||||
QSequentialAnimationGroup *subGroup = new QSequentialAnimationGroup(&group);
|
||||
|
@ -513,8 +513,8 @@ void tst_QTextCodec::aliasForUTF16() const
|
||||
|
||||
void tst_QTextCodec::mibForTSCII() const
|
||||
{
|
||||
QTextCodec *codec = QTextCodec::codecForName("TSCII");
|
||||
QVERIFY(codec);
|
||||
QTextCodec *codec = QTextCodec::codecForName("TSCII");
|
||||
QVERIFY(codec);
|
||||
QCOMPARE(codec->mibEnum(), 2107);
|
||||
}
|
||||
|
||||
|
@ -203,72 +203,73 @@ void tst_QBuffer::writeBlock_data()
|
||||
QTest::addColumn<QString>("str");
|
||||
|
||||
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"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.\n\n"
|
||||
"The QBuffer class is an I/O device that operates on a QByteArray.\n"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.\n\n"
|
||||
"The QBuffer class is an I/O device that operates on a QByteArray.\n"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.");
|
||||
QTest::newRow( "large_bytearray" ) << QString(
|
||||
"The QBuffer class is an I/O device that operates on a QByteArray.\n"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.\n\n"
|
||||
"The QBuffer class is an I/O device that operates on a QByteArray.\n"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.\n\n"
|
||||
"The QBuffer class is an I/O device that operates on a QByteArray.\n"
|
||||
"QBuffer is used to read and write to a memory buffer. It is normally "
|
||||
"used with a QTextStream or a QDataStream. QBuffer has an associated "
|
||||
"QByteArray which holds the buffer data. The size() of the buffer is "
|
||||
"automatically adjusted as data is written.\n"
|
||||
"The constructor QBuffer(QByteArray) creates a QBuffer using an existing "
|
||||
"byte array. The byte array can also be set with setBuffer(). Writing to "
|
||||
"the QBuffer will modify the original byte array because QByteArray is "
|
||||
"explicitly shared.\n"
|
||||
"Use open() to open the buffer before use and to set the mode (read-only, "
|
||||
"write-only, etc.). close() closes the buffer. The buffer must be closed "
|
||||
"before reopening or calling setBuffer().\n"
|
||||
"A common way to use QBuffer is through QDataStream or QTextStream, which "
|
||||
"have constructors that take a QBuffer parameter. For convenience, there "
|
||||
"are also QDataStream and QTextStream constructors that take a QByteArray "
|
||||
"parameter. These constructors create and open an internal QBuffer.\n"
|
||||
"Note that QTextStream can also operate on a QString (a Unicode string); a "
|
||||
"QBuffer cannot.\n"
|
||||
"You can also use QBuffer directly through the standard QIODevice functions "
|
||||
"readBlock(), writeBlock() readLine(), at(), getch(), putch() and ungetch().\n"
|
||||
"See also QFile, QDataStream, QTextStream, QByteArray, Shared Classes, Collection "
|
||||
"Classes and Input/Output and Networking.");
|
||||
}
|
||||
|
||||
void tst_QBuffer::writeBlock()
|
||||
|
@ -644,7 +644,7 @@ void tst_QFile::setSize()
|
||||
QCOMPARE(c, 'a');
|
||||
|
||||
QCOMPARE(f.size(), (qlonglong)1);
|
||||
bool ok = f.resize(99);
|
||||
bool ok = f.resize(99);
|
||||
QVERIFY(ok);
|
||||
QCOMPARE(f.size(), (qlonglong)99);
|
||||
|
||||
@ -1492,19 +1492,19 @@ void tst_QFile::tailFile()
|
||||
|
||||
void tst_QFile::flush()
|
||||
{
|
||||
QString fileName("stdfile.txt");
|
||||
QString fileName("stdfile.txt");
|
||||
|
||||
QFile::remove(fileName);
|
||||
QFile::remove(fileName);
|
||||
|
||||
{
|
||||
QFile file(fileName);
|
||||
QVERIFY(file.open(QFile::WriteOnly));
|
||||
QCOMPARE(file.write("abc", 3),qint64(3));
|
||||
}
|
||||
{
|
||||
QFile file(fileName);
|
||||
QVERIFY(file.open(QFile::WriteOnly));
|
||||
QCOMPARE(file.write("abc", 3),qint64(3));
|
||||
}
|
||||
|
||||
{
|
||||
QFile file(fileName);
|
||||
QVERIFY(file.open(QFile::WriteOnly | QFile::Append));
|
||||
{
|
||||
QFile file(fileName);
|
||||
QVERIFY(file.open(QFile::WriteOnly | QFile::Append));
|
||||
QCOMPARE(file.pos(), qlonglong(3));
|
||||
QCOMPARE(file.write("def", 3), qlonglong(3));
|
||||
QCOMPARE(file.pos(), qlonglong(6));
|
||||
@ -1516,7 +1516,7 @@ void tst_QFile::flush()
|
||||
QCOMPARE(file.readAll(), QByteArray("abcdef"));
|
||||
}
|
||||
|
||||
QFile::remove(fileName);
|
||||
QFile::remove(fileName);
|
||||
}
|
||||
|
||||
void tst_QFile::bufferedRead()
|
||||
@ -1529,7 +1529,7 @@ void tst_QFile::bufferedRead()
|
||||
file.close();
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r");
|
||||
FILE *stdFile = fopen((QCoreApplication::applicationDirPath() + "/stdfile.txt").toAscii() , "r");
|
||||
#else
|
||||
FILE *stdFile = fopen("stdfile.txt", "r");
|
||||
#endif
|
||||
@ -2281,7 +2281,7 @@ void tst_QFile::virtualFile()
|
||||
void tst_QFile::textFile()
|
||||
{
|
||||
#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)
|
||||
FILE *fs = ::fopen("writeabletextfile", "wt");
|
||||
#else
|
||||
@ -2787,8 +2787,7 @@ void tst_QFile::map()
|
||||
QVERIFY(file.open(QFile::ReadWrite));
|
||||
memory = file.map(offset, size);
|
||||
if (error != QFile::NoError) {
|
||||
|
||||
QVERIFY(file.error() != QFile::NoError);
|
||||
QVERIFY(file.error() != QFile::NoError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2909,7 +2908,7 @@ void tst_QFile::mapOpenMode()
|
||||
if (QFile::exists(fileName)) {
|
||||
QVERIFY(QFile::setPermissions(fileName,
|
||||
QFile::WriteOwner | QFile::ReadOwner | QFile::WriteUser | QFile::ReadUser));
|
||||
QFile::remove(fileName);
|
||||
QFile::remove(fileName);
|
||||
}
|
||||
QFile file(fileName);
|
||||
|
||||
|
@ -250,10 +250,10 @@ void tst_QIODevice::unget()
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
QTcpSocket socket;
|
||||
QIODevice *dev;
|
||||
QByteArray result;
|
||||
const char *lineResult;
|
||||
if (i == 0) {
|
||||
QIODevice *dev;
|
||||
QByteArray result;
|
||||
const char *lineResult;
|
||||
if (i == 0) {
|
||||
dev = &buffer;
|
||||
result = QByteArray("ZXCV");
|
||||
lineResult = "ZXCV";
|
||||
@ -264,21 +264,21 @@ void tst_QIODevice::unget()
|
||||
dev = &socket;
|
||||
result = QByteArray("HTTP");
|
||||
lineResult = "Date";
|
||||
}
|
||||
char ch, ch2;
|
||||
dev->seek(0);
|
||||
dev->getChar(&ch);
|
||||
dev->ungetChar(ch);
|
||||
QCOMPARE(dev->peek(4), result);
|
||||
dev->getChar(&ch);
|
||||
dev->getChar(&ch2);
|
||||
dev->ungetChar(ch2);
|
||||
dev->ungetChar(ch);
|
||||
QCOMPARE(dev->read(1), result.left(1));
|
||||
QCOMPARE(dev->read(3), result.right(3));
|
||||
}
|
||||
char ch, ch2;
|
||||
dev->seek(0);
|
||||
dev->getChar(&ch);
|
||||
dev->ungetChar(ch);
|
||||
QCOMPARE(dev->peek(4), result);
|
||||
dev->getChar(&ch);
|
||||
dev->getChar(&ch2);
|
||||
dev->ungetChar(ch2);
|
||||
dev->ungetChar(ch);
|
||||
QCOMPARE(dev->read(1), result.left(1));
|
||||
QCOMPARE(dev->read(3), result.right(3));
|
||||
|
||||
if (i == 0)
|
||||
dev->seek(0);
|
||||
dev->seek(0);
|
||||
else
|
||||
dev->readLine();
|
||||
dev->getChar(&ch);
|
||||
@ -300,33 +300,33 @@ void tst_QIODevice::peek()
|
||||
QFile file("peektestfile");
|
||||
|
||||
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->write("ZXCV");
|
||||
device->open(QBuffer::ReadWrite);
|
||||
device->write("ZXCV");
|
||||
|
||||
device->seek(0);
|
||||
QCOMPARE(device->peek(4), QByteArray("ZXCV"));
|
||||
QCOMPARE(device->pos(), qint64(0));
|
||||
device->write("ABCDE");
|
||||
device->seek(3);
|
||||
QCOMPARE(device->peek(1), QByteArray("D"));
|
||||
QCOMPARE(device->peek(5), QByteArray("DE"));
|
||||
device->seek(0);
|
||||
QCOMPARE(device->read(4), QByteArray("ABCD"));
|
||||
QCOMPARE(device->pos(), qint64(4));
|
||||
device->seek(0);
|
||||
QCOMPARE(device->peek(4), QByteArray("ZXCV"));
|
||||
QCOMPARE(device->pos(), qint64(0));
|
||||
device->write("ABCDE");
|
||||
device->seek(3);
|
||||
QCOMPARE(device->peek(1), QByteArray("D"));
|
||||
QCOMPARE(device->peek(5), QByteArray("DE"));
|
||||
device->seek(0);
|
||||
QCOMPARE(device->read(4), QByteArray("ABCD"));
|
||||
QCOMPARE(device->pos(), qint64(4));
|
||||
|
||||
device->seek(0);
|
||||
device->write("ZXCV");
|
||||
device->seek(0);
|
||||
char buf[5];
|
||||
buf[4] = 0;
|
||||
device->peek(buf, 4);
|
||||
QCOMPARE(static_cast<const char *>(buf), "ZXCV");
|
||||
QCOMPARE(device->pos(), qint64(0));
|
||||
device->read(buf, 4);
|
||||
QCOMPARE(static_cast<const char *>(buf), "ZXCV");
|
||||
QCOMPARE(device->pos(), qint64(4));
|
||||
device->seek(0);
|
||||
device->write("ZXCV");
|
||||
device->seek(0);
|
||||
char buf[5];
|
||||
buf[4] = 0;
|
||||
device->peek(buf, 4);
|
||||
QCOMPARE(static_cast<const char *>(buf), "ZXCV");
|
||||
QCOMPARE(device->pos(), qint64(0));
|
||||
device->read(buf, 4);
|
||||
QCOMPARE(static_cast<const char *>(buf), "ZXCV");
|
||||
QCOMPARE(device->pos(), qint64(4));
|
||||
}
|
||||
QFile::remove("peektestfile");
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ static QString settingsPath(const char *path = "")
|
||||
// Temporary path for files that are specified explictly in the constructor.
|
||||
QString tempPath = QDir::tempPath();
|
||||
if (tempPath.endsWith("/"))
|
||||
tempPath.truncate(tempPath.size() - 1);
|
||||
tempPath.truncate(tempPath.size() - 1);
|
||||
return QDir::toNativeSeparators(tempPath + "/tst_QSettings/" + QLatin1String(path));
|
||||
}
|
||||
|
||||
@ -309,9 +309,9 @@ void tst_QSettings::init()
|
||||
removePath(settingsPath());
|
||||
#else
|
||||
if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based)
|
||||
system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1());
|
||||
else
|
||||
system(QString("deltree /Y %1").arg(settingsPath()).toLatin1());
|
||||
system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1());
|
||||
else
|
||||
system(QString("deltree /Y %1").arg(settingsPath()).toLatin1());
|
||||
#endif
|
||||
}
|
||||
#elif defined(Q_OS_DARWIN)
|
||||
@ -812,16 +812,16 @@ void tst_QSettings::testIniParsing()
|
||||
QSettings settings(settingsPath("someDir/someSettings.ini"), QSettings::IniFormat);
|
||||
|
||||
if ( settings.status() == QSettings::NoError ) { // else no point proceeding
|
||||
QVariant v = settings.value(key);
|
||||
QVERIFY(v.canConvert(expect.type()));
|
||||
// check some types so as to give prettier error messages
|
||||
if ( v.type() == QVariant::String ) {
|
||||
QCOMPARE(v.toString(), expect.toString());
|
||||
} else if ( v.type() == QVariant::Int ) {
|
||||
QCOMPARE(v.toInt(), expect.toInt());
|
||||
} else {
|
||||
QCOMPARE(v, expect);
|
||||
}
|
||||
QVariant v = settings.value(key);
|
||||
QVERIFY(v.canConvert(expect.type()));
|
||||
// check some types so as to give prettier error messages
|
||||
if ( v.type() == QVariant::String ) {
|
||||
QCOMPARE(v.toString(), expect.toString());
|
||||
} else if ( v.type() == QVariant::Int ) {
|
||||
QCOMPARE(v.toInt(), expect.toInt());
|
||||
} else {
|
||||
QCOMPARE(v, expect);
|
||||
}
|
||||
}
|
||||
|
||||
QCOMPARE(settings.status(), status);
|
||||
|
@ -224,38 +224,36 @@ void tst_QTemporaryFile::fileNameIsEmpty()
|
||||
|
||||
void tst_QTemporaryFile::autoRemove()
|
||||
{
|
||||
// Test auto remove
|
||||
QString fileName;
|
||||
{
|
||||
QTemporaryFile file("tempXXXXXX");
|
||||
file.setAutoRemove(true);
|
||||
QVERIFY(file.open());
|
||||
fileName = file.fileName();
|
||||
file.close();
|
||||
}
|
||||
QVERIFY(!QFile::exists(fileName));
|
||||
// Test auto remove
|
||||
QString fileName;
|
||||
{
|
||||
QTemporaryFile file("tempXXXXXX");
|
||||
file.setAutoRemove(true);
|
||||
QVERIFY(file.open());
|
||||
fileName = file.fileName();
|
||||
file.close();
|
||||
}
|
||||
QVERIFY(!QFile::exists(fileName));
|
||||
|
||||
// Test if disabling auto remove works.
|
||||
{
|
||||
QTemporaryFile file("tempXXXXXX");
|
||||
file.setAutoRemove(false);
|
||||
QVERIFY(file.open());
|
||||
fileName = file.fileName();
|
||||
file.close();
|
||||
}
|
||||
QVERIFY(QFile::exists(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));
|
||||
// Test if disabling auto remove works.
|
||||
{
|
||||
QTemporaryFile file("tempXXXXXX");
|
||||
file.setAutoRemove(false);
|
||||
QVERIFY(file.open());
|
||||
fileName = file.fileName();
|
||||
file.close();
|
||||
}
|
||||
QVERIFY(QFile::exists(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));
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::nonWritableCurrentDir()
|
||||
|
@ -796,84 +796,83 @@ void tst_QUrl::resolving()
|
||||
QCOMPARE(url.resolved(relativeUrl).toString(), relsolvedUrl);
|
||||
}
|
||||
|
||||
|
||||
void tst_QUrl::toString_data()
|
||||
{
|
||||
QTest::addColumn<QString>("urlString");
|
||||
QTest::addColumn<uint>("options");
|
||||
QTest::addColumn<QString>("string");
|
||||
|
||||
QTest::newRow("data0") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
|
||||
<< uint(QUrl::RemoveScheme)
|
||||
<< QString::fromLatin1("//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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemovePassword)
|
||||
<< QString::fromLatin1("http://ole@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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveUserInfo)
|
||||
<< QString::fromLatin1("http://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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemovePort)
|
||||
<< QString::fromLatin1("http://ole:password@www.troll.no/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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveAuthority)
|
||||
<< QString::fromLatin1("http:/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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemovePath)
|
||||
<< QString::fromLatin1("http://ole:password@www.troll.no:9090?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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveQuery)
|
||||
<< QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html#top");
|
||||
QTest::newRow("data7") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
|
||||
<< uint(QUrl::RemoveQuery)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveFragment)
|
||||
<< QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei");
|
||||
QTest::newRow("data8") << QString::fromLatin1("http://ole:password@www.troll.no:9090/index.html?ole=semann&gud=hei#top")
|
||||
<< uint(QUrl::RemoveFragment)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePassword)
|
||||
<< QString::fromLatin1("//ole@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)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo)
|
||||
<< QString::fromLatin1("//www.troll.no:9090/index.html?ole=semann&gud=hei#top");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveUserInfo)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePort)
|
||||
<< QString::fromLatin1("//ole:password@www.troll.no/index.html?ole=semann&gud=hei#top");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePort)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority)
|
||||
<< QString::fromLatin1("/index.html?ole=semann&gud=hei#top");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePath)
|
||||
<< QString::fromLatin1("//ole:password@www.troll.no:9090?ole=semann&gud=hei#top");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePath)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment)
|
||||
<< QString::fromLatin1("/index.html?ole=semann&gud=hei");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemoveFragment)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveAuthority | QUrl::RemoveQuery)
|
||||
<< QString::fromLatin1("http:/index.html#top");
|
||||
<< uint(QUrl::RemoveAuthority | QUrl::RemoveQuery)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemovePassword | QUrl::RemovePort
|
||||
| QUrl::RemovePath | QUrl::RemoveQuery
|
||||
| QUrl::RemoveFragment)
|
||||
<< QString::fromLatin1("http://ole@www.troll.no");
|
||||
<< uint(QUrl::RemovePassword | QUrl::RemovePort
|
||||
| QUrl::RemovePath | QUrl::RemoveQuery
|
||||
| QUrl::RemoveFragment)
|
||||
<< 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")
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePassword
|
||||
| QUrl::RemovePort | QUrl::RemovePath
|
||||
| QUrl::RemoveQuery | QUrl::RemoveFragment)
|
||||
<< QString::fromLatin1("//ole@www.troll.no");
|
||||
<< uint(QUrl::RemoveScheme | QUrl::RemovePassword
|
||||
| QUrl::RemovePort | QUrl::RemovePath
|
||||
| QUrl::RemoveQuery | QUrl::RemoveFragment)
|
||||
<< QString::fromLatin1("//ole@www.troll.no");
|
||||
|
||||
QTest::newRow("data18") << QString::fromLatin1("http://andreas:hemmelig@www.vg.no/?my=query&your=query#yougotfragged")
|
||||
<< uint(QUrl::None)
|
||||
@ -911,18 +910,16 @@ void tst_QUrl::isParentOf_data()
|
||||
QTest::addColumn<QString>("child");
|
||||
QTest::addColumn<bool>("trueFalse");
|
||||
|
||||
QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/d/e?f") << true;
|
||||
QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/d") << false;
|
||||
QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/de") << false;
|
||||
QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/")
|
||||
<< QString::fromLatin1("http://a.b.c/de") << false;
|
||||
QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/")
|
||||
<< QString::fromLatin1("http://a.b.c/d/e") << true;
|
||||
|
||||
|
||||
QTest::newRow("data0") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/d/e?f") << true;
|
||||
QTest::newRow("data1") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/d") << false;
|
||||
QTest::newRow("data2") << QString::fromLatin1("http://a.b.c/d")
|
||||
<< QString::fromLatin1("http://a.b.c/de") << false;
|
||||
QTest::newRow("data3") << QString::fromLatin1("http://a.b.c/d/")
|
||||
<< QString::fromLatin1("http://a.b.c/de") << false;
|
||||
QTest::newRow("data4") << QString::fromLatin1("http://a.b.c/d/")
|
||||
<< QString::fromLatin1("http://a.b.c/d/e") << true;
|
||||
}
|
||||
|
||||
void tst_QUrl::toString_constructed_data()
|
||||
@ -941,16 +938,16 @@ void tst_QUrl::toString_constructed_data()
|
||||
QString n("");
|
||||
|
||||
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("//qt.nokia.com/index.html");
|
||||
<< QByteArray() << n << QString::fromLatin1("//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()
|
||||
<< n << QString::fromLatin1("file:///root") << QByteArray("file:///root");
|
||||
QTest::newRow("userAndPass") << QString::fromLatin1("http") << QString::fromLatin1("dfaure") << QString::fromLatin1("kde")
|
||||
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
|
||||
<< QString::fromLatin1("http://dfaure:kde@kde.org:443/") << QByteArray("http://dfaure:kde@kde.org:443/");
|
||||
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
|
||||
<< 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")
|
||||
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
|
||||
<< QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
|
||||
<< "kde.org" << 443 << QString::fromLatin1("/") << QByteArray() << n
|
||||
<< QString::fromLatin1("http://:kde@kde.org:443/") << QByteArray("http://:kde@kde.org:443/");
|
||||
}
|
||||
|
||||
void tst_QUrl::toString_constructed()
|
||||
@ -968,21 +965,21 @@ void tst_QUrl::toString_constructed()
|
||||
|
||||
QUrl url;
|
||||
if (!scheme.isEmpty())
|
||||
url.setScheme(scheme);
|
||||
url.setScheme(scheme);
|
||||
if (!userName.isEmpty())
|
||||
url.setUserName(userName);
|
||||
url.setUserName(userName);
|
||||
if (!password.isEmpty())
|
||||
url.setPassword(password);
|
||||
url.setPassword(password);
|
||||
if (!host.isEmpty())
|
||||
url.setHost(host);
|
||||
url.setHost(host);
|
||||
if (port != -1)
|
||||
url.setPort(port);
|
||||
url.setPort(port);
|
||||
if (!path.isEmpty())
|
||||
url.setPath(path);
|
||||
url.setPath(path);
|
||||
if (!query.isEmpty())
|
||||
url.setEncodedQuery(query);
|
||||
url.setEncodedQuery(query);
|
||||
if (!fragment.isEmpty())
|
||||
url.setFragment(fragment);
|
||||
url.setFragment(fragment);
|
||||
|
||||
QVERIFY(url.isValid());
|
||||
QCOMPARE(url.toString(), asString);
|
||||
@ -1006,14 +1003,14 @@ void tst_QUrl::toLocalFile_data()
|
||||
QTest::addColumn<QString>("theUrl");
|
||||
QTest::addColumn<QString>("theFile");
|
||||
|
||||
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("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("data7") << 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("data10") << 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("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("data7") << 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("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt");
|
||||
|
||||
// and some that result in empty (i.e., not local)
|
||||
QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString();
|
||||
@ -1039,16 +1036,16 @@ void tst_QUrl::fromLocalFile_data()
|
||||
QTest::addColumn<QString>("theUrl");
|
||||
QTest::addColumn<QString>("thePath");
|
||||
|
||||
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("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("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile")
|
||||
<< QString::fromLatin1("/somedir/somefile");
|
||||
QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost")
|
||||
<< QString::fromLatin1("");
|
||||
QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/")
|
||||
<< QString::fromLatin1("/");
|
||||
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("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("data4") << QString::fromLatin1("//somehost/somedir/somefile") << QString::fromLatin1("file://somehost/somedir/somefile")
|
||||
<< QString::fromLatin1("/somedir/somefile");
|
||||
QTest::newRow("data5") << QString::fromLatin1("//somehost") << QString::fromLatin1("file://somehost")
|
||||
<< QString::fromLatin1("");
|
||||
QTest::newRow("data6") << QString::fromLatin1("//somehost/") << QString::fromLatin1("file://somehost/")
|
||||
<< QString::fromLatin1("/");
|
||||
}
|
||||
|
||||
void tst_QUrl::fromLocalFile()
|
||||
@ -1066,32 +1063,32 @@ void tst_QUrl::fromLocalFile()
|
||||
void tst_QUrl::compat_legacy()
|
||||
{
|
||||
{
|
||||
QUrl u( "file:bar" );
|
||||
QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") );
|
||||
QUrl u( "file:bar" );
|
||||
QCOMPARE( u.toString(QUrl::RemoveScheme), QString("bar") );
|
||||
}
|
||||
|
||||
/* others
|
||||
*/
|
||||
{
|
||||
QUrl u( "http://qt.nokia.com/images/ban/pgs_front.jpg" );
|
||||
QCOMPARE( u.path(), QString("/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") );
|
||||
}
|
||||
{
|
||||
QUrl tmp( "http://qt.nokia.com/images/ban/" );
|
||||
QUrl u = tmp.resolved(QString("pgs_front.jpg"));
|
||||
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
|
||||
QUrl tmp( "http://qt.nokia.com/images/ban/" );
|
||||
QUrl u = tmp.resolved(QString("pgs_front.jpg"));
|
||||
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
|
||||
}
|
||||
{
|
||||
QUrl tmp;
|
||||
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
|
||||
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
|
||||
QUrl tmp;
|
||||
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
|
||||
QCOMPARE( u.path(), QString("/images/ban/pgs_front.jpg") );
|
||||
}
|
||||
{
|
||||
QUrl tmp;
|
||||
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
|
||||
QFileInfo fi(u.path());
|
||||
u.setPath(fi.path());
|
||||
QCOMPARE( u.path(), QString("/images/ban") );
|
||||
QUrl tmp;
|
||||
QUrl u = tmp.resolved(QString("http://qt.nokia.com/images/ban/pgs_front.jpg"));
|
||||
QFileInfo fi(u.path());
|
||||
u.setPath(fi.path());
|
||||
QCOMPARE( u.path(), QString("/images/ban") );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1124,16 +1121,16 @@ void tst_QUrl::compat_constructor_01()
|
||||
QFETCH( QString, urlStr );
|
||||
|
||||
{
|
||||
QUrl empty;
|
||||
QUrl u = empty.resolved(urlStr);
|
||||
QUrl empty;
|
||||
QUrl u = empty.resolved(urlStr);
|
||||
|
||||
QTEST( u.toString(), "res" );
|
||||
QTEST( u.toString(), "res" );
|
||||
}
|
||||
{
|
||||
QUrl empty;
|
||||
QUrl u = empty.resolved(urlStr);
|
||||
QUrl empty;
|
||||
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;
|
||||
if ( !protocol.isEmpty() )
|
||||
url.setScheme( protocol );
|
||||
url.setScheme( protocol );
|
||||
if ( !user.isEmpty() )
|
||||
url.setUserName( user );
|
||||
url.setUserName( user );
|
||||
if ( !password.isEmpty() )
|
||||
url.setPassword( password );
|
||||
url.setPassword( password );
|
||||
if ( !host.isEmpty() )
|
||||
url.setHost( host );
|
||||
url.setHost( host );
|
||||
if ( port != -1 )
|
||||
url.setPort( port );
|
||||
url.setPort( port );
|
||||
if ( !path.isEmpty() )
|
||||
url.setPath( path );
|
||||
url.setPath( path );
|
||||
|
||||
QVERIFY( url.isValid() == res );
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ void tst_QMetaObject::invokeMetaMember()
|
||||
QCOMPARE(obj.slotResult, QString("testReference:whatever"));
|
||||
QCOMPARE(refStr, QString("gotcha"));
|
||||
|
||||
qint64 ll1 = -1;
|
||||
qint64 ll1 = -1;
|
||||
quint64 ll2 = 0;
|
||||
QVERIFY(QMetaObject::invokeMethod(&obj,
|
||||
"testLongLong",
|
||||
@ -559,7 +559,7 @@ void tst_QMetaObject::invokeQueuedMetaMember()
|
||||
QVERIFY(!QMetaObject::invokeMethod(&obj, "sig1", Qt::QueuedConnection, Q_RETURN_ARG(QString, exp),
|
||||
Q_ARG(QString, "nono")));
|
||||
|
||||
qint64 ll1 = -1;
|
||||
qint64 ll1 = -1;
|
||||
quint64 ll2 = 0;
|
||||
QVERIFY(QMetaObject::invokeMethod(&obj,
|
||||
"testLongLong",
|
||||
|
@ -49,106 +49,99 @@
|
||||
static int Step = 0;
|
||||
Sender RandomSender (0, 0);
|
||||
|
||||
|
||||
void TRACE (int step, const char *name)
|
||||
{
|
||||
for (int t = 0; t < step - 1; t++)
|
||||
fprintf (stderr, "\t");
|
||||
fprintf (stderr, "Step %d: %s\n", step, name);
|
||||
return;
|
||||
for (int t = 0; t < step - 1; t++)
|
||||
fprintf (stderr, "\t");
|
||||
fprintf (stderr, "Step %d: %s\n", step, name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Receiver::Receiver ()
|
||||
: QObject ()
|
||||
: QObject ()
|
||||
{
|
||||
}
|
||||
|
||||
void Receiver::received ()
|
||||
{
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Receiver::received()");
|
||||
if (::Step != 2 && ::Step != 4)
|
||||
qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step);
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Receiver::received()");
|
||||
if (::Step != 2 && ::Step != 4)
|
||||
qFatal("%s: Incorrect Step: %d (should be 2 or 4)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
if (::Step == 2)
|
||||
s->fire ();
|
||||
if (::Step == 2)
|
||||
s->fire ();
|
||||
|
||||
fprintf (stderr, "Receiver<%s>::received() sender=%s\n",
|
||||
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
|
||||
fprintf (stderr, "Receiver<%s>::received() sender=%s\n",
|
||||
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
|
||||
|
||||
TRACE (stepCopy, "ends Receiver::received()");
|
||||
TRACE (stepCopy, "ends Receiver::received()");
|
||||
}
|
||||
|
||||
|
||||
Disconnector::Disconnector ()
|
||||
: QObject ()
|
||||
: QObject ()
|
||||
{
|
||||
}
|
||||
|
||||
void Disconnector::received ()
|
||||
{
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Disconnector::received()");
|
||||
if (::Step != 5 && ::Step != 6)
|
||||
qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Disconnector::received()");
|
||||
if (::Step != 5 && ::Step != 6)
|
||||
qFatal("%s: Incorrect Step: %d (should be 5 or 6)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
|
||||
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
|
||||
if (sender () == 0)
|
||||
fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");
|
||||
fprintf (stderr, "Disconnector<%s>::received() sender=%s\n",
|
||||
(const char *) objectName ().toAscii (), sender ()->metaObject()->className());
|
||||
if (sender () == 0)
|
||||
fprintf (stderr, "WE SHOULD NOT BE RECEIVING THIS SIGNAL\n");
|
||||
|
||||
if (::Step == 5)
|
||||
{
|
||||
disconnect (s, SIGNAL (fired ()), s->d, SLOT (received ()));
|
||||
if (::Step == 5)
|
||||
{
|
||||
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)
|
||||
: QObject ()
|
||||
: QObject ()
|
||||
{
|
||||
this->r = r; this->d = d;
|
||||
if (r)
|
||||
connect (this, SIGNAL (fired ()), r, SLOT (received ()));
|
||||
if (d)
|
||||
connect (this, SIGNAL (fired ()), d, SLOT (received ()));
|
||||
this->r = r; this->d = d;
|
||||
if (r)
|
||||
connect (this, SIGNAL (fired ()), r, SLOT (received ()));
|
||||
if (d)
|
||||
connect (this, SIGNAL (fired ()), d, SLOT (received ()));
|
||||
};
|
||||
|
||||
void Sender::fire ()
|
||||
{
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Sender::fire()");
|
||||
if (::Step != 1 && ::Step != 3)
|
||||
qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);
|
||||
::Step++;
|
||||
const int stepCopy = ::Step;
|
||||
TRACE (stepCopy, "Sender::fire()");
|
||||
if (::Step != 1 && ::Step != 3)
|
||||
qFatal("%s: Incorrect Step: %d (should be 1 or 3)", Q_FUNC_INFO, ::Step);
|
||||
|
||||
emit fired ();
|
||||
TRACE (stepCopy, "ends Sender::fire()");
|
||||
emit fired ();
|
||||
TRACE (stepCopy, "ends Sender::fire()");
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
QCoreApplication app (argc, argv);
|
||||
QCoreApplication app (argc, argv);
|
||||
|
||||
Receiver r;
|
||||
Disconnector d;
|
||||
Sender s (&r, &d);
|
||||
Receiver r;
|
||||
Disconnector d;
|
||||
Sender s (&r, &d);
|
||||
|
||||
r.s = &s;
|
||||
d.s = &s;
|
||||
r.s = &s;
|
||||
d.s = &s;
|
||||
|
||||
|
||||
::Step = 0;
|
||||
s.fire ();
|
||||
return 0;
|
||||
::Step = 0;
|
||||
s.fire ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,50 +54,47 @@ class Receiver : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Receiver ();
|
||||
virtual ~Receiver () {}
|
||||
Receiver ();
|
||||
virtual ~Receiver () {}
|
||||
|
||||
protected slots:
|
||||
void received ();
|
||||
void received ();
|
||||
|
||||
public:
|
||||
Sender *s;
|
||||
Sender *s;
|
||||
};
|
||||
|
||||
|
||||
class Disconnector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Disconnector ();
|
||||
virtual ~Disconnector () {}
|
||||
Disconnector ();
|
||||
virtual ~Disconnector () {}
|
||||
|
||||
protected slots:
|
||||
void received ();
|
||||
void received ();
|
||||
|
||||
public:
|
||||
Sender *s;
|
||||
Sender *s;
|
||||
};
|
||||
|
||||
|
||||
class Sender : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Sender (Receiver *r, Disconnector *d);
|
||||
virtual ~Sender () {}
|
||||
Sender (Receiver *r, Disconnector *d);
|
||||
virtual ~Sender () {}
|
||||
|
||||
void fire ();
|
||||
void fire ();
|
||||
|
||||
signals:
|
||||
void fired ();
|
||||
void fired ();
|
||||
|
||||
public:
|
||||
Receiver *r;
|
||||
Disconnector *d;
|
||||
Receiver *r;
|
||||
Disconnector *d;
|
||||
};
|
||||
|
||||
|
||||
#endif // SIGNAL_BUG_H
|
||||
|
@ -173,16 +173,19 @@ class ReceiverObject : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ReceiverObject() : sequence_slot1( 0 ),
|
||||
sequence_slot2( 0 ),
|
||||
sequence_slot3( 0 ),
|
||||
sequence_slot4( 0 ) {}
|
||||
ReceiverObject()
|
||||
: sequence_slot1( 0 )
|
||||
, sequence_slot2( 0 )
|
||||
, sequence_slot3( 0 )
|
||||
, sequence_slot4( 0 )
|
||||
{}
|
||||
|
||||
void reset() {
|
||||
sequence_slot4 = 0;
|
||||
sequence_slot3 = 0;
|
||||
sequence_slot2 = 0;
|
||||
sequence_slot1 = 0;
|
||||
void reset()
|
||||
{
|
||||
sequence_slot4 = 0;
|
||||
sequence_slot3 = 0;
|
||||
sequence_slot2 = 0;
|
||||
sequence_slot1 = 0;
|
||||
count_slot1 = 0;
|
||||
count_slot2 = 0;
|
||||
count_slot3 = 0;
|
||||
@ -198,7 +201,8 @@ public:
|
||||
int count_slot3;
|
||||
int count_slot4;
|
||||
|
||||
bool called(int slot) {
|
||||
bool called(int slot)
|
||||
{
|
||||
switch (slot) {
|
||||
case 1: return sequence_slot1;
|
||||
case 2: return sequence_slot2;
|
||||
@ -759,13 +763,13 @@ public:
|
||||
protected:
|
||||
void connectNotify( const char *signal )
|
||||
{
|
||||
org_signal = signal;
|
||||
nw_signal = QMetaObject::normalizedSignature(signal);
|
||||
org_signal = signal;
|
||||
nw_signal = QMetaObject::normalizedSignature(signal);
|
||||
};
|
||||
void disconnectNotify( const char *signal )
|
||||
{
|
||||
org_signal = signal;
|
||||
nw_signal = QMetaObject::normalizedSignature(signal);
|
||||
org_signal = signal;
|
||||
nw_signal = QMetaObject::normalizedSignature(signal);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -189,7 +189,7 @@ public:
|
||||
if (++timeoutsForFirst == 1) {
|
||||
killTimer(extraTimerId);
|
||||
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);
|
||||
}
|
||||
} else if (te->timerId() == secondTimerId) {
|
||||
@ -229,10 +229,10 @@ void tst_QTimer::livelock()
|
||||
QCOMPARE(tester.timeoutsForExtra, 0);
|
||||
QTRY_COMPARE(tester.timeoutsForSecond, 1);
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
|
||||
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
|
||||
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
|
||||
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
|
||||
#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
|
||||
QVERIFY(tester.postEventAtRightTime);
|
||||
}
|
||||
|
@ -199,13 +199,12 @@ void tst_QLibrary::version()
|
||||
VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion");
|
||||
QVERIFY(fnVersion);
|
||||
QCOMPARE(fnVersion(), resultversion);
|
||||
QVERIFY(library.unload());
|
||||
QVERIFY(library.unload());
|
||||
#else
|
||||
Q_UNUSED(lib);
|
||||
Q_UNUSED(loadversion);
|
||||
Q_UNUSED(resultversion);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void tst_QLibrary::load_data()
|
||||
@ -242,10 +241,10 @@ void tst_QLibrary::load()
|
||||
QLibrary library( lib );
|
||||
bool ok = library.load();
|
||||
if ( result ) {
|
||||
QVERIFY( ok );
|
||||
QVERIFY(library.unload());
|
||||
QVERIFY( ok );
|
||||
QVERIFY(library.unload());
|
||||
} else {
|
||||
QVERIFY( !ok );
|
||||
QVERIFY( !ok );
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,9 +272,9 @@ void tst_QLibrary::unload()
|
||||
library.load();
|
||||
bool ok = library.unload();
|
||||
if ( result ) {
|
||||
QVERIFY( ok );
|
||||
QVERIFY( ok );
|
||||
} else {
|
||||
QVERIFY( !ok );
|
||||
QVERIFY( !ok );
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,11 +311,11 @@ void tst_QLibrary::resolve()
|
||||
QLibrary library( lib );
|
||||
testFunc func = (testFunc) library.resolve( symbol.toLatin1() );
|
||||
if ( goodPointer ) {
|
||||
QVERIFY( func != 0 );
|
||||
QVERIFY( func != 0 );
|
||||
} else {
|
||||
QVERIFY( func == 0 );
|
||||
QVERIFY( func == 0 );
|
||||
}
|
||||
library.unload();
|
||||
library.unload();
|
||||
}
|
||||
|
||||
void tst_QLibrary::library_data()
|
||||
@ -435,7 +434,7 @@ void tst_QLibrary::errorString()
|
||||
break;
|
||||
}
|
||||
QRegExp re(errorString);
|
||||
QString libErrorString = lib.errorString();
|
||||
QString libErrorString = lib.errorString();
|
||||
QVERIFY(!lib.isLoaded() || lib.unload());
|
||||
QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString));
|
||||
QCOMPARE(ok, success);
|
||||
@ -489,7 +488,7 @@ void tst_QLibrary::loadHints()
|
||||
bool ok = library.load();
|
||||
if ( result ) {
|
||||
QVERIFY( ok );
|
||||
QVERIFY(library.unload());
|
||||
QVERIFY(library.unload());
|
||||
} else {
|
||||
QVERIFY( !ok );
|
||||
}
|
||||
@ -539,29 +538,29 @@ void tst_QLibrary::multipleInstancesForOneLibrary()
|
||||
QString lib = QDir::currentPath() + "/mylib";
|
||||
|
||||
{
|
||||
QLibrary lib1(lib);
|
||||
QLibrary lib2(lib);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
lib1.load();
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib1.unload(), true);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
lib1.load();
|
||||
lib2.load();
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib1.unload(), false);
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib2.unload(), true);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
QLibrary lib1(lib);
|
||||
QLibrary lib2(lib);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
lib1.load();
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib1.unload(), true);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
lib1.load();
|
||||
lib2.load();
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib1.unload(), false);
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
QCOMPARE(lib2.unload(), true);
|
||||
QCOMPARE(lib1.isLoaded(), false);
|
||||
QCOMPARE(lib2.isLoaded(), false);
|
||||
|
||||
// Finally; unload on that is already unloaded
|
||||
QCOMPARE(lib1.unload(), false);
|
||||
// Finally; unload on that is already unloaded
|
||||
QCOMPARE(lib1.unload(), false);
|
||||
}
|
||||
|
||||
//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);
|
||||
lib1.load();
|
||||
QCOMPARE(lib1.isLoaded(), true);
|
||||
}
|
||||
QLibrary lib2(lib);
|
||||
//lib2 should be loaded because lib1 was loaded and never unloaded
|
||||
}
|
||||
QLibrary lib2(lib);
|
||||
//lib2 should be loaded because lib1 was loaded and never unloaded
|
||||
QCOMPARE(lib2.isLoaded(), true);
|
||||
|
||||
/*
|
||||
|
@ -314,16 +314,16 @@ public:
|
||||
|
||||
void run()
|
||||
{
|
||||
test_mutex.lock();
|
||||
test_mutex.lock();
|
||||
|
||||
mutex.lock();
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
cond.wakeOne();
|
||||
cond.wait(&mutex);
|
||||
}
|
||||
mutex.unlock();
|
||||
mutex.lock();
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
cond.wakeOne();
|
||||
cond.wait(&mutex);
|
||||
}
|
||||
mutex.unlock();
|
||||
|
||||
test_mutex.unlock();
|
||||
test_mutex.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
@ -339,22 +339,22 @@ public:
|
||||
|
||||
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();
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
cond.wakeOne();
|
||||
cond.wait(&mutex);
|
||||
}
|
||||
mutex.unlock();
|
||||
mutex.lock();
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
cond.wakeOne();
|
||||
cond.wait(&mutex);
|
||||
}
|
||||
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);
|
||||
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
// normal mutex
|
||||
QVERIFY(mutex.tryLock());
|
||||
mutex.unlock();
|
||||
// normal mutex
|
||||
QVERIFY(mutex.tryLock());
|
||||
mutex.unlock();
|
||||
|
||||
thread.mutex.lock();
|
||||
thread.start();
|
||||
thread.mutex.lock();
|
||||
thread.start();
|
||||
|
||||
for (int j = 0; j < iterations; ++j) {
|
||||
QVERIFY(thread.cond.wait(&thread.mutex, 10000));
|
||||
QVERIFY(!mutex.tryLock());
|
||||
for (int j = 0; j < iterations; ++j) {
|
||||
QVERIFY(thread.cond.wait(&thread.mutex, 10000));
|
||||
QVERIFY(!mutex.tryLock());
|
||||
|
||||
thread.cond.wakeOne();
|
||||
}
|
||||
thread.cond.wakeOne();
|
||||
}
|
||||
|
||||
thread.mutex.unlock();
|
||||
thread.mutex.unlock();
|
||||
|
||||
QVERIFY(thread.wait(10000));
|
||||
QVERIFY(mutex.tryLock());
|
||||
QVERIFY(thread.wait(10000));
|
||||
QVERIFY(mutex.tryLock());
|
||||
|
||||
mutex.unlock();
|
||||
mutex.unlock();
|
||||
|
||||
// recursive mutex
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
// recursive mutex
|
||||
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.start();
|
||||
rthread.mutex.lock();
|
||||
rthread.start();
|
||||
|
||||
for (int k = 0; k < iterations; ++k) {
|
||||
QVERIFY(rthread.cond.wait(&rthread.mutex, 10000));
|
||||
QVERIFY(!rmutex.tryLock());
|
||||
for (int k = 0; k < iterations; ++k) {
|
||||
QVERIFY(rthread.cond.wait(&rthread.mutex, 10000));
|
||||
QVERIFY(!rmutex.tryLock());
|
||||
|
||||
rthread.cond.wakeOne();
|
||||
}
|
||||
rthread.cond.wakeOne();
|
||||
}
|
||||
|
||||
rthread.mutex.unlock();
|
||||
rthread.mutex.unlock();
|
||||
|
||||
QVERIFY(rthread.wait(10000));
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rmutex.tryLock());
|
||||
QVERIFY(rthread.wait(10000));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,12 +70,12 @@ public:
|
||||
protected:
|
||||
void run()
|
||||
{
|
||||
int i = 0;
|
||||
while ( i < 100 ) {
|
||||
int i = 0;
|
||||
while ( i < 100 ) {
|
||||
semaphore->acquire();
|
||||
i++;
|
||||
i++;
|
||||
semaphore->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -89,12 +89,12 @@ public:
|
||||
protected:
|
||||
void run()
|
||||
{
|
||||
int i = 0;
|
||||
while ( i < 100 ) {
|
||||
int i = 0;
|
||||
while ( i < 100 ) {
|
||||
semaphore->acquire(N);
|
||||
i++;
|
||||
i++;
|
||||
semaphore->release(N);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -544,7 +544,7 @@ ostream &operator<<(ostream &out, const StableSortTest& obj) { out << obj.Major
|
||||
QVector<StableSortTest> createStableTestVector()
|
||||
{
|
||||
QVector<StableSortTest> stableTestVector;
|
||||
for (int i=500; i>=0; --i) {
|
||||
for (int i=500; i>=0; --i) {
|
||||
for (int j=0; j<10; ++j) {
|
||||
stableTestVector.append(StableSortTest(i, j));
|
||||
}
|
||||
|
@ -138,11 +138,11 @@ void tst_QBitArray::size()
|
||||
a.fill(1);
|
||||
int len = a.size();
|
||||
for (int j=0; j<len; j++) {
|
||||
bool b = a[j];
|
||||
if (b)
|
||||
S+= "1";
|
||||
else
|
||||
S+= "0";
|
||||
bool b = a[j];
|
||||
if (b)
|
||||
S+= "1";
|
||||
else
|
||||
S+= "0";
|
||||
}
|
||||
QTEST(S,"res");
|
||||
}
|
||||
|
@ -161,11 +161,11 @@ void tst_QByteArray::qCompress_data()
|
||||
|
||||
int i;
|
||||
for ( i=0; i<size1; i++ )
|
||||
ba1[i] = (char)( i / 1024 );
|
||||
ba1[i] = (char)( i / 1024 );
|
||||
QTest::newRow( "01" ) << ba1;
|
||||
|
||||
for ( i=0; i<size1; i++ )
|
||||
ba1[i] = (char)( i % 256 );
|
||||
ba1[i] = (char)( i % 256 );
|
||||
QTest::newRow( "02" ) << ba1;
|
||||
|
||||
ba1.fill( 'A' );
|
||||
@ -403,8 +403,7 @@ void tst_QByteArray::split_data()
|
||||
QTest::addColumn<QByteArray>("sample");
|
||||
QTest::addColumn<int>("size");
|
||||
|
||||
QTest::newRow("1") << QByteArray("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile")
|
||||
<< 14;
|
||||
QTest::newRow("1") << QByteArray("-rw-r--r-- 1 0 0 519240 Jul 9 2002 bigfile") << 14;
|
||||
QTest::newRow("2") << QByteArray("abcde") << 1;
|
||||
QTest::newRow("one empty") << QByteArray("") << 1;
|
||||
QTest::newRow("two empty") << QByteArray(" ") << 2;
|
||||
@ -956,31 +955,31 @@ void tst_QByteArray::lastIndexOf()
|
||||
if (!hasNull)
|
||||
QCOMPARE( haystack.lastIndexOf(needle.data(), startpos), expected );
|
||||
if (needle.size() == 1)
|
||||
QCOMPARE( haystack.lastIndexOf(needle.at(0), startpos), expected );
|
||||
QCOMPARE( haystack.lastIndexOf(needle.at(0), startpos), expected );
|
||||
|
||||
if (startpos == -1) {
|
||||
QCOMPARE( haystack.lastIndexOf(needle), expected );
|
||||
QCOMPARE( haystack.lastIndexOf(needle), expected );
|
||||
if (!hasNull)
|
||||
QCOMPARE( haystack.lastIndexOf(needle.data()), expected );
|
||||
if (needle.size() == 1)
|
||||
QCOMPARE( haystack.lastIndexOf(needle.at(0)), expected );
|
||||
if (needle.size() == 1)
|
||||
QCOMPARE( haystack.lastIndexOf(needle.at(0)), expected );
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QByteArray::number()
|
||||
{
|
||||
QCOMPARE(QString(QByteArray::number((quint64) 0)),
|
||||
QString(QByteArray("0")));
|
||||
QString(QByteArray("0")));
|
||||
QCOMPARE(QString(QByteArray::number(Q_UINT64_C(0xFFFFFFFFFFFFFFFF))),
|
||||
QString(QByteArray("18446744073709551615")));
|
||||
QString(QByteArray("18446744073709551615")));
|
||||
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0xFFFFFFFFFFFFFFFF))),
|
||||
QString(QByteArray("-1")));
|
||||
QString(QByteArray("-1")));
|
||||
QCOMPARE(QString(QByteArray::number(qint64(0))),
|
||||
QString(QByteArray("0")));
|
||||
QString(QByteArray("0")));
|
||||
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x7FFFFFFFFFFFFFFF))),
|
||||
QString(QByteArray("9223372036854775807")));
|
||||
QString(QByteArray("9223372036854775807")));
|
||||
QCOMPARE(QString(QByteArray::number(Q_INT64_C(0x8000000000000000))),
|
||||
QString(QByteArray("-9223372036854775808")));
|
||||
QString(QByteArray("-9223372036854775808")));
|
||||
}
|
||||
|
||||
// defined later
|
||||
|
@ -97,20 +97,20 @@ public:
|
||||
// qDebug("creating MyClass count=%d", count);
|
||||
}
|
||||
MyClass( const QString& c) {
|
||||
count++; str = c;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
count++; str = c;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
~MyClass() {
|
||||
count--;
|
||||
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
|
||||
count--;
|
||||
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
MyClass( const MyClass& c ) {
|
||||
count++; str = c.str;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
count++; str = c.str;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
MyClass &operator =(const MyClass &o) {
|
||||
// qDebug("copying MyClass '%s'", o.str.latin1());
|
||||
str = o.str; return *this;
|
||||
// qDebug("copying MyClass '%s'", o.str.latin1());
|
||||
str = o.str; return *this;
|
||||
}
|
||||
|
||||
QString str;
|
||||
@ -125,145 +125,145 @@ typedef QHash<QString, MyClass> MyMap;
|
||||
void tst_QHash::count()
|
||||
{
|
||||
{
|
||||
MyMap map;
|
||||
MyMap map2( map );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 0 );
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
// detach
|
||||
map2["Hallo"] = MyClass( "Fritz" );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
MyMap map;
|
||||
MyMap map2( map );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 0 );
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
// detach
|
||||
map2["Hallo"] = MyClass( "Fritz" );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 1 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 1 );
|
||||
QCOMPARE( MyClass::count, 1 );
|
||||
#endif
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
|
||||
{
|
||||
typedef QHash<QString, MyClass> Map;
|
||||
Map map;
|
||||
QCOMPARE( map.count(), 0);
|
||||
map.insert( "Torben", MyClass("Weis") );
|
||||
QCOMPARE( map.count(), 1 );
|
||||
map.insert( "Claudia", MyClass("Sorg") );
|
||||
QCOMPARE( map.count(), 2 );
|
||||
map.insert( "Lars", MyClass("Linzbach") );
|
||||
map.insert( "Matthias", MyClass("Ettrich") );
|
||||
map.insert( "Sue", MyClass("Paludo") );
|
||||
map.insert( "Eirik", MyClass("Eng") );
|
||||
map.insert( "Haavard", MyClass("Nord") );
|
||||
map.insert( "Arnt", MyClass("Gulbrandsen") );
|
||||
map.insert( "Paul", MyClass("Tvete") );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
map.insert( "Paul", MyClass("Tvete 1") );
|
||||
map.insert( "Paul", MyClass("Tvete 2") );
|
||||
map.insert( "Paul", MyClass("Tvete 3") );
|
||||
map.insert( "Paul", MyClass("Tvete 4") );
|
||||
map.insert( "Paul", MyClass("Tvete 5") );
|
||||
map.insert( "Paul", MyClass("Tvete 6") );
|
||||
typedef QHash<QString, MyClass> Map;
|
||||
Map map;
|
||||
QCOMPARE( map.count(), 0);
|
||||
map.insert( "Torben", MyClass("Weis") );
|
||||
QCOMPARE( map.count(), 1 );
|
||||
map.insert( "Claudia", MyClass("Sorg") );
|
||||
QCOMPARE( map.count(), 2 );
|
||||
map.insert( "Lars", MyClass("Linzbach") );
|
||||
map.insert( "Matthias", MyClass("Ettrich") );
|
||||
map.insert( "Sue", MyClass("Paludo") );
|
||||
map.insert( "Eirik", MyClass("Eng") );
|
||||
map.insert( "Haavard", MyClass("Nord") );
|
||||
map.insert( "Arnt", MyClass("Gulbrandsen") );
|
||||
map.insert( "Paul", MyClass("Tvete") );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
map.insert( "Paul", MyClass("Tvete 1") );
|
||||
map.insert( "Paul", MyClass("Tvete 2") );
|
||||
map.insert( "Paul", MyClass("Tvete 3") );
|
||||
map.insert( "Paul", MyClass("Tvete 4") );
|
||||
map.insert( "Paul", MyClass("Tvete 5") );
|
||||
map.insert( "Paul", MyClass("Tvete 6") );
|
||||
|
||||
QCOMPARE( map.count(), 9 );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
Map map2( map );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
Map map2( map );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
QVERIFY( map.count() == 9 );
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
QVERIFY( map.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
#endif
|
||||
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
#endif
|
||||
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map.remove( "Lars" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map.remove( "Lars" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
#endif
|
||||
|
||||
map.remove( "Mist" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map.remove( "Mist" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
#endif
|
||||
}
|
||||
QVERIFY( MyClass::count == 0 );
|
||||
|
||||
{
|
||||
typedef QHash<QString,MyClass> Map;
|
||||
Map map;
|
||||
map["Torben"] = MyClass("Weis");
|
||||
typedef QHash<QString,MyClass> Map;
|
||||
Map map;
|
||||
map["Torben"] = MyClass("Weis");
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 1 );
|
||||
QVERIFY( MyClass::count == 1 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 1 );
|
||||
QVERIFY( map.count() == 1 );
|
||||
|
||||
(void)map["Torben"].str;
|
||||
(void)map["Lars"].str;
|
||||
(void)map["Torben"].str;
|
||||
(void)map["Lars"].str;
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( map.count() == 2 );
|
||||
|
||||
const Map& cmap = map;
|
||||
(void)cmap["Depp"].str;
|
||||
const Map& cmap = map;
|
||||
(void)cmap["Depp"].str;
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( cmap.count() == 2 );
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( cmap.count() == 2 );
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
{
|
||||
for ( int i = 0; i < 100; ++i )
|
||||
{
|
||||
QHash<int, MyClass> map;
|
||||
for (int j = 0; j < i; ++j)
|
||||
map.insert(j, MyClass(QString::number(j)));
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
for ( int i = 0; i < 100; ++i )
|
||||
{
|
||||
QHash<int, MyClass> map;
|
||||
for (int j = 0; j < i; ++j)
|
||||
map.insert(j, MyClass(QString::number(j)));
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
}
|
||||
@ -334,9 +334,9 @@ void tst_QHash::insert1()
|
||||
QVERIFY(hash2[2] == world);
|
||||
|
||||
hash[1] = hash[1];
|
||||
QVERIFY(hash[1] == hello);
|
||||
}
|
||||
{
|
||||
QVERIFY(hash[1] == hello);
|
||||
}
|
||||
{
|
||||
Hash hash2 = hash;
|
||||
hash2.detach();
|
||||
hash2.remove(1);
|
||||
@ -464,8 +464,8 @@ void tst_QHash::erase()
|
||||
it1 = h1.begin();
|
||||
int n = 0;
|
||||
while (it1 != h1.end()) {
|
||||
it1 = h1.erase(it1);
|
||||
++n;
|
||||
it1 = h1.erase(it1);
|
||||
++n;
|
||||
}
|
||||
QVERIFY(n == 3);
|
||||
QHash<int, int> h2;
|
||||
@ -562,17 +562,17 @@ void tst_QHash::swap()
|
||||
void tst_QHash::clear()
|
||||
{
|
||||
{
|
||||
MyMap map;
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key", MyClass( "value" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key0", MyClass( "value0" ) );
|
||||
map.insert( "key0", MyClass( "value1" ) );
|
||||
map.insert( "key1", MyClass( "value2" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
MyMap map;
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key", MyClass( "value" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key0", MyClass( "value0" ) );
|
||||
map.insert( "key0", MyClass( "value1" ) );
|
||||
map.insert( "key1", MyClass( "value2" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
}
|
||||
QCOMPARE( MyClass::count, int(0) );
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include <windows.h> // needed for GetUserDefaultLCID
|
||||
#define _control87 _controlfp
|
||||
extern "C" DWORD GetThreadLocale(void) {
|
||||
return GetUserDefaultLCID();
|
||||
return GetUserDefaultLCID();
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -162,16 +162,16 @@ void tst_QLocale::ctor()
|
||||
QLocale::countryToString(default_country).toLatin1().constData());
|
||||
|
||||
{
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == default_lang);
|
||||
QVERIFY(l.country() == default_country);
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == default_lang);
|
||||
QVERIFY(l.country() == default_country);
|
||||
}
|
||||
|
||||
#define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \
|
||||
{ \
|
||||
QLocale l(QLocale::req_lang, QLocale::req_country); \
|
||||
QCOMPARE(l.language(), exp_lang); \
|
||||
QCOMPARE(l.country(), exp_country); \
|
||||
QLocale l(QLocale::req_lang, QLocale::req_country); \
|
||||
QCOMPARE(l.language(), exp_lang); \
|
||||
QCOMPARE(l.country(), exp_country); \
|
||||
}
|
||||
{
|
||||
QLocale l(QLocale::C, QLocale::AnyCountry);
|
||||
@ -195,9 +195,9 @@ void tst_QLocale::ctor()
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::France));
|
||||
|
||||
{
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedStates);
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedStates);
|
||||
}
|
||||
|
||||
TEST_CTOR(French, France, QLocale::French, QLocale::France)
|
||||
@ -211,9 +211,9 @@ void tst_QLocale::ctor()
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
|
||||
|
||||
{
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedKingdom);
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedKingdom);
|
||||
}
|
||||
|
||||
TEST_CTOR(French, France, QLocale::French, QLocale::France)
|
||||
@ -225,9 +225,9 @@ void tst_QLocale::ctor()
|
||||
QLocale::setDefault(QLocale(QLocale::Aymara, QLocale::France));
|
||||
|
||||
{
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedKingdom);
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == 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 l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedKingdom);
|
||||
QLocale l;
|
||||
QVERIFY(l.language() == QLocale::English);
|
||||
QVERIFY(l.country() == QLocale::UnitedKingdom);
|
||||
}
|
||||
|
||||
|
||||
TEST_CTOR(Aymara, AnyCountry, 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) \
|
||||
{ \
|
||||
QLocale l(req_lc); \
|
||||
QVERIFY2(l.language() == QLocale::exp_lang \
|
||||
&& l.country() == QLocale::exp_country, \
|
||||
QString("requested: \"" + QString(req_lc) + "\", got: " \
|
||||
+ QLocale::languageToString(l.language()) \
|
||||
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
|
||||
QLocale l(req_lc); \
|
||||
QVERIFY2(l.language() == QLocale::exp_lang \
|
||||
&& l.country() == QLocale::exp_country, \
|
||||
QString("requested: \"" + QString(req_lc) + "\", got: " \
|
||||
+ QLocale::languageToString(l.language()) \
|
||||
+ "/" + QLocale::countryToString(l.country())).toLatin1().constData()); \
|
||||
}
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::C));
|
||||
@ -442,8 +441,8 @@ void tst_QLocale::unixLocaleName()
|
||||
{
|
||||
#define TEST_NAME(req_lang, req_country, exp_name) \
|
||||
{ \
|
||||
QLocale l(QLocale::req_lang, QLocale::req_country); \
|
||||
QCOMPARE(l.name(), QString(exp_name)); \
|
||||
QLocale l(QLocale::req_lang, QLocale::req_country); \
|
||||
QCOMPARE(l.name(), QString(exp_name)); \
|
||||
}
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::C));
|
||||
@ -463,112 +462,112 @@ void tst_QLocale::double_conversion_data()
|
||||
QTest::addColumn<bool>("good");
|
||||
QTest::addColumn<double>("num");
|
||||
|
||||
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.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.234E10") << QString("C") << QString("1.234E10") << true << 1.234e10;
|
||||
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.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.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 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,") << 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,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,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,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,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 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 ,") << QString("C") << QString(",") << 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.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 , 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,") << QString("C") << QString("1,") << 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,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,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,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,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 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 ,") << QString("C") << QString(",") << 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.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 , e2") << QString("C") << QString(", e2") << 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 null") << 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 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,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 1e+") << QString("C") << QString("1e+") << false << 0.0;
|
||||
QTest::newRow("C 1e-") << QString("C") << QString("1e-") << 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 .") << QString("C") << QString(".") << 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,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 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 .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.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 .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.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("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.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.") << 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.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.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 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 .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,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 . 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.") << 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.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.") << 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.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.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 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 .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,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 . 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") << 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.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 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.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 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.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 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.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 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,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") << 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,E10") << QString("de_DE") << QString("1,E10") << true << 1.0e10;
|
||||
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,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") << 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,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 null") << 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 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 empty") << 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 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 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.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,876543.0e-2") << QString("C") << QString("9,876543.0e-2") << 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,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("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;
|
||||
@ -595,10 +594,10 @@ void tst_QLocale::double_conversion()
|
||||
QCOMPARE(ok, good);
|
||||
|
||||
if (ok) {
|
||||
double diff = d - num;
|
||||
if (diff < 0)
|
||||
diff = -diff;
|
||||
QVERIFY(diff <= MY_DOUBLE_EPSILON);
|
||||
double diff = d - num;
|
||||
if (diff < 0)
|
||||
diff = -diff;
|
||||
QVERIFY(diff <= MY_DOUBLE_EPSILON);
|
||||
}
|
||||
}
|
||||
|
||||
@ -609,50 +608,50 @@ void tst_QLocale::long_long_conversion_data()
|
||||
QTest::addColumn<bool>("good");
|
||||
QTest::addColumn<qlonglong>("num");
|
||||
|
||||
QTest::newRow("C null") << 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," << 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,234") << QString("C") << "1,234" << true << (qlonglong) 1234;
|
||||
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 12,34567") << QString("C") << "12,34567"<< 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 12345,67") << QString("C") << "12345,67"<< 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 null") << 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," << 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,234") << QString("C") << "1,234" << true << (qlonglong) 1234;
|
||||
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 12,34567") << QString("C") << "12,34567" << 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 12345,67") << QString("C") << "12345,67" << 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("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.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.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 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 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 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 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 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") << QString("de_DE") << "1" << true << (qlonglong) 1;
|
||||
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.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 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 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 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 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 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 ldtrspcs") << QString("de_DE") << " 1.234.567 " << true << (qlonglong) 1234567;
|
||||
|
||||
// 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_space") << QString("nb_NO")<< QString("1")+QChar(0x20)+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 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 ldtrspcs") << 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 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()
|
||||
@ -670,7 +669,7 @@ void tst_QLocale::long_long_conversion()
|
||||
QCOMPARE(ok, good);
|
||||
|
||||
if (ok) {
|
||||
QCOMPARE(l, num);
|
||||
QCOMPARE(l, num);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1105,13 +1104,13 @@ void tst_QLocale::macDefaultLocale()
|
||||
|
||||
int diff = currentTime.hour() - utcTime.hour();
|
||||
|
||||
// Check if local time and utc time are on opposite sides of the 24-hour wrap-around.
|
||||
if (diff < -12)
|
||||
diff += 24;
|
||||
if (diff > 12)
|
||||
diff -= 24;
|
||||
// Check if local time and utc time are on opposite sides of the 24-hour wrap-around.
|
||||
if (diff < -12)
|
||||
diff += 24;
|
||||
if (diff > 12)
|
||||
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")));
|
||||
|
||||
QCOMPARE(locale.toCurrencyString(qulonglong(1234)), QString("$1,234.00"));
|
||||
|
@ -85,24 +85,24 @@ class MyClass
|
||||
{
|
||||
public:
|
||||
MyClass() {
|
||||
++count;
|
||||
// qDebug("creating MyClass count=%d", count);
|
||||
++count;
|
||||
// qDebug("creating MyClass count=%d", count);
|
||||
}
|
||||
MyClass( const QString& c) {
|
||||
count++; str = c;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
count++; str = c;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
~MyClass() {
|
||||
count--;
|
||||
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
|
||||
count--;
|
||||
// qDebug("deleting MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
MyClass( const MyClass& c ) {
|
||||
count++; str = c.str;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
count++; str = c.str;
|
||||
// qDebug("creating MyClass '%s' count = %d", str.latin1(), count);
|
||||
}
|
||||
MyClass &operator =(const MyClass &o) {
|
||||
// qDebug("copying MyClass '%s'", o.str.latin1());
|
||||
str = o.str; return *this;
|
||||
// qDebug("copying MyClass '%s'", o.str.latin1());
|
||||
str = o.str; return *this;
|
||||
}
|
||||
|
||||
QString str;
|
||||
@ -121,145 +121,145 @@ void tst_QMap::init()
|
||||
void tst_QMap::count()
|
||||
{
|
||||
{
|
||||
MyMap map;
|
||||
MyMap map2( map );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 0 );
|
||||
QCOMPARE( MyClass::count, int(0) );
|
||||
// detach
|
||||
map2["Hallo"] = MyClass( "Fritz" );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
MyMap map;
|
||||
MyMap map2( map );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 0 );
|
||||
QCOMPARE( MyClass::count, int(0) );
|
||||
// detach
|
||||
map2["Hallo"] = MyClass( "Fritz" );
|
||||
QCOMPARE( map.count(), 0 );
|
||||
QCOMPARE( map2.count(), 1 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 1 );
|
||||
QCOMPARE( MyClass::count, 1 );
|
||||
#endif
|
||||
}
|
||||
QCOMPARE( MyClass::count, int(0) );
|
||||
|
||||
{
|
||||
typedef QMap<QString, MyClass> Map;
|
||||
Map map;
|
||||
QCOMPARE( map.count(), 0);
|
||||
map.insert( "Torben", MyClass("Weis") );
|
||||
QCOMPARE( map.count(), 1 );
|
||||
map.insert( "Claudia", MyClass("Sorg") );
|
||||
QCOMPARE( map.count(), 2 );
|
||||
map.insert( "Lars", MyClass("Linzbach") );
|
||||
map.insert( "Matthias", MyClass("Ettrich") );
|
||||
map.insert( "Sue", MyClass("Paludo") );
|
||||
map.insert( "Eirik", MyClass("Eng") );
|
||||
map.insert( "Haavard", MyClass("Nord") );
|
||||
map.insert( "Arnt", MyClass("Gulbrandsen") );
|
||||
map.insert( "Paul", MyClass("Tvete") );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
map.insert( "Paul", MyClass("Tvete 1") );
|
||||
map.insert( "Paul", MyClass("Tvete 2") );
|
||||
map.insert( "Paul", MyClass("Tvete 3") );
|
||||
map.insert( "Paul", MyClass("Tvete 4") );
|
||||
map.insert( "Paul", MyClass("Tvete 5") );
|
||||
map.insert( "Paul", MyClass("Tvete 6") );
|
||||
typedef QMap<QString, MyClass> Map;
|
||||
Map map;
|
||||
QCOMPARE( map.count(), 0);
|
||||
map.insert( "Torben", MyClass("Weis") );
|
||||
QCOMPARE( map.count(), 1 );
|
||||
map.insert( "Claudia", MyClass("Sorg") );
|
||||
QCOMPARE( map.count(), 2 );
|
||||
map.insert( "Lars", MyClass("Linzbach") );
|
||||
map.insert( "Matthias", MyClass("Ettrich") );
|
||||
map.insert( "Sue", MyClass("Paludo") );
|
||||
map.insert( "Eirik", MyClass("Eng") );
|
||||
map.insert( "Haavard", MyClass("Nord") );
|
||||
map.insert( "Arnt", MyClass("Gulbrandsen") );
|
||||
map.insert( "Paul", MyClass("Tvete") );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
map.insert( "Paul", MyClass("Tvete 1") );
|
||||
map.insert( "Paul", MyClass("Tvete 2") );
|
||||
map.insert( "Paul", MyClass("Tvete 3") );
|
||||
map.insert( "Paul", MyClass("Tvete 4") );
|
||||
map.insert( "Paul", MyClass("Tvete 5") );
|
||||
map.insert( "Paul", MyClass("Tvete 6") );
|
||||
|
||||
QCOMPARE( map.count(), 9 );
|
||||
QCOMPARE( map.count(), 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
Map map2( map );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
Map map2( map );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
QVERIFY( map.count() == 9 );
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
QVERIFY( map.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
#endif
|
||||
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
map2.insert( "Kay", MyClass("Roemer") );
|
||||
QVERIFY( map2.count() == 10 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
QCOMPARE( MyClass::count, 19 );
|
||||
#endif
|
||||
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
map2 = map;
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 9 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map2.clear();
|
||||
QVERIFY( map.count() == 9 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
QCOMPARE( MyClass::count, 9 );
|
||||
#endif
|
||||
|
||||
map.remove( "Lars" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map.remove( "Lars" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
#endif
|
||||
|
||||
map.remove( "Mist" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
map.remove( "Mist" );
|
||||
QVERIFY( map.count() == 8 );
|
||||
QVERIFY( map2.count() == 0 );
|
||||
#ifndef Q_CC_SUN
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
QCOMPARE( MyClass::count, 8 );
|
||||
#endif
|
||||
}
|
||||
QVERIFY( MyClass::count == 0 );
|
||||
|
||||
{
|
||||
typedef QMap<QString,MyClass> Map;
|
||||
Map map;
|
||||
map["Torben"] = MyClass("Weis");
|
||||
typedef QMap<QString,MyClass> Map;
|
||||
Map map;
|
||||
map["Torben"] = MyClass("Weis");
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 1 );
|
||||
QVERIFY( MyClass::count == 1 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 1 );
|
||||
QVERIFY( map.count() == 1 );
|
||||
|
||||
(void)map["Torben"].str;
|
||||
(void)map["Lars"].str;
|
||||
(void)map["Torben"].str;
|
||||
(void)map["Lars"].str;
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( map.count() == 2 );
|
||||
|
||||
const Map& cmap = map;
|
||||
(void)cmap["Depp"].str;
|
||||
const Map& cmap = map;
|
||||
(void)cmap["Depp"].str;
|
||||
#ifndef Q_CC_SUN
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
QVERIFY( MyClass::count == 2 );
|
||||
#endif
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( cmap.count() == 2 );
|
||||
QVERIFY( map.count() == 2 );
|
||||
QVERIFY( cmap.count() == 2 );
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
{
|
||||
for ( int i = 0; i < 100; ++i )
|
||||
{
|
||||
QMap<int, MyClass> map;
|
||||
for (int j = 0; j < i; ++j)
|
||||
map.insert(j, MyClass(QString::number(j)));
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
for ( int i = 0; i < 100; ++i )
|
||||
{
|
||||
QMap<int, MyClass> map;
|
||||
for (int j = 0; j < i; ++j)
|
||||
map.insert(j, MyClass(QString::number(j)));
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
}
|
||||
QCOMPARE( MyClass::count, 0 );
|
||||
}
|
||||
@ -267,17 +267,17 @@ void tst_QMap::count()
|
||||
void tst_QMap::clear()
|
||||
{
|
||||
{
|
||||
MyMap map;
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key", MyClass( "value" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key0", MyClass( "value0" ) );
|
||||
map.insert( "key0", MyClass( "value1" ) );
|
||||
map.insert( "key1", MyClass( "value2" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
MyMap map;
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key", MyClass( "value" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
map.insert( "key0", MyClass( "value0" ) );
|
||||
map.insert( "key0", MyClass( "value1" ) );
|
||||
map.insert( "key1", MyClass( "value2" ) );
|
||||
map.clear();
|
||||
QVERIFY( map.isEmpty() );
|
||||
}
|
||||
QCOMPARE( MyClass::count, int(0) );
|
||||
}
|
||||
@ -302,8 +302,8 @@ void tst_QMap::beginEnd()
|
||||
// test iteration
|
||||
QString result;
|
||||
for ( StringMap::ConstIterator it = map.constBegin();
|
||||
it != map.constEnd(); ++it )
|
||||
result += *it;
|
||||
it != map.constEnd(); ++it )
|
||||
result += *it;
|
||||
QCOMPARE( result, QString( "ab" ) );
|
||||
|
||||
// maps should still be identical
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -137,79 +137,79 @@ void tst_QRegExp::indexIn_data()
|
||||
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 + "anc02" ) << QString("a(?:(?=)|(?=))z") << QString("az") << 0 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "anc03" ) << QString("a(?:(?=)|(?!))z") << QString("az") << 0 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "anc04" ) << QString("a(?:(?!)|(?=))z") << QString("az") << 0 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
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
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
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
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "anc09" ) << QString("a(?:(?!)|b)z") << QString("abz") << 0 << 3
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
#if 0
|
||||
QTest::newRow( stri + "anc10" ) << QString("a?(?=^b$)") << QString("ab") << 0 << 1
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "anc11" ) << QString("a?(?=^b$)") << QString("b") << 0 << 0
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
#endif
|
||||
|
||||
// back-references
|
||||
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</>")
|
||||
<< 0 << 13 << QStringList( QStringList() << "b" );
|
||||
<< 0 << 13 << QStringList( QStringList() << "b" );
|
||||
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
|
||||
<< QStringList( QStringList() << QString("aaaa") << "aa" );
|
||||
<< QStringList( QStringList() << QString("aaaa") << "aa" );
|
||||
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)"
|
||||
"\\14\\13\\12\\11\\10\\9\\8\\7\\6\\5\\4\\3\\2\\1")
|
||||
<< 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"
|
||||
<< "12" << "13" << "14");
|
||||
|
||||
// captures
|
||||
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
|
||||
<< QStringList( QStringList() << "aaa" );
|
||||
<< QStringList( QStringList() << "aaa" );
|
||||
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
|
||||
<< QStringList( QStringList() << QString("aaa") << QString("") );
|
||||
<< QStringList( QStringList() << QString("aaa") << QString("") );
|
||||
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
|
||||
<< QStringList( QStringList() << QString("aaa") );
|
||||
<< QStringList( QStringList() << QString("aaa") );
|
||||
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
|
||||
<< 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
|
||||
<< QStringList( QStringList() << QString("") << QString("") << QString("") << QString("") );
|
||||
<< QStringList( QStringList() << QString("") << QString("") << QString("") << QString("") );
|
||||
QTest::newRow( stri + "cap10" ) << QString("(((a)*(b)*)c)*") << QString("abc") << 0 << 3
|
||||
<< QStringList( QStringList() << "abc" << "ab" << "a"
|
||||
<< "b" );
|
||||
<< QStringList( QStringList() << "abc" << "ab" << "a"
|
||||
<< "b" );
|
||||
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
|
||||
<< QStringList( QStringList() << "ac" << "a" << "a" << "" );
|
||||
<< QStringList( QStringList() << "ac" << "a" << "a" << "" );
|
||||
QTest::newRow( stri + "cap13" ) << QString("(to|top)?(o|polo)?(gical|o?logical)")
|
||||
<< QString("topological") << 0 << 11
|
||||
<< QStringList( QStringList() << "top" << "o"
|
||||
<< "logical" );
|
||||
<< QString("topological") << 0 << 11
|
||||
<< QStringList( QStringList() << "top" << "o"
|
||||
<< "logical" );
|
||||
QTest::newRow( stri + "cap14" ) << QString("(a)+") << QString("aaaa") << 0 << 4
|
||||
<< QStringList( QStringList() << "a" );
|
||||
<< QStringList( QStringList() << "a" );
|
||||
|
||||
// concatenation
|
||||
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 + "cat06" ) << QString("ab") << QString("ab") << 0 << 2 << QStringList();
|
||||
QTest::newRow( stri + "cat07" ) << QString("ab") << QString("ba") << -1 << -1 << QStringList();
|
||||
QTest::newRow( stri + "cat08" ) << QString("abab") << QString("abbaababab") << 4 << 4
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "cat08" ) << QString("abab") << QString("abbaababab") << 4 << 4 << QStringList();
|
||||
|
||||
indexIn_addMoreRows(stri);
|
||||
indexIn_addMoreRows(stri);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tst_QRegExp::indexIn_addMoreRows(const QByteArray &stri)
|
||||
{
|
||||
|
||||
// from Perl Cookbook
|
||||
QTest::newRow( stri + "cook00" ) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0"
|
||||
",3}|i[vx])$")
|
||||
<< QString("mmxl") << 0 << 4
|
||||
<< QStringList( QStringList() << "mm" << "" << "xl"
|
||||
<< "" );
|
||||
QTest::newRow( stri + "cook00" ) << QString("^(m*)(d?c{0,3}|c[dm])(1?x{0,3}|x[lc])(v?i{0,3}|i[vx])$")
|
||||
<< QString("mmxl") << 0 << 4
|
||||
<< QStringList( QStringList() << "mm" << "" << "xl"
|
||||
<< "" );
|
||||
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
|
||||
<< 7 << QStringList( QStringList() << "PATH" << ". " );
|
||||
<< 7 << QStringList( QStringList() << "PATH" << ". " );
|
||||
QTest::newRow( stri + "cook03" ) << QString(".{80,}")
|
||||
<< QString("0000000011111111222222223333333344444444555"
|
||||
"5555566666666777777778888888899999999000000"
|
||||
"00aaaaaaaa")
|
||||
<< 0 << 96 << QStringList();
|
||||
<< QString("0000000011111111222222223333333344444444555"
|
||||
"5555566666666777777778888888899999999000000"
|
||||
"00aaaaaaaa")
|
||||
<< 0 << 96 << QStringList();
|
||||
QTest::newRow( stri + "cook04" ) << QString("(\\d+)/(\\d+)/(\\d+) (\\d+):(\\d+):(\\d+)")
|
||||
<< QString("1978/05/24 07:30:00") << 0 << 19
|
||||
<< QStringList( QStringList() << "1978" << "05" << "24"
|
||||
<< "07" << "30" << "00" );
|
||||
<< QString("1978/05/24 07:30:00") << 0 << 19
|
||||
<< QStringList( QStringList() << "1978" << "05" << "24"
|
||||
<< "07" << "30" << "00" );
|
||||
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
|
||||
<< QStringList( QStringList() << "7f" );
|
||||
<< QStringList( QStringList() << "7f" );
|
||||
QTest::newRow( stri + "cook07" ) << QString("/\\*.*\\*/") << QString("i++; /* increment i */") << 5
|
||||
<< 17 << QStringList();
|
||||
<< 17 << QStringList();
|
||||
QTest::newRow( stri + "cook08" ) << QString("^\\s+") << QString(" aaa ") << 0 << 3
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "cook09" ) << QString("\\s+$") << QString(" aaa ") << 6 << 3
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
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]?\\"
|
||||
"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["
|
||||
"0-5])$")
|
||||
<< QString("255.00.40.30") << 0 << 12
|
||||
<< QStringList( QStringList() << "255" << "00" << "40"
|
||||
<< "30" );
|
||||
"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["
|
||||
"0-5])$")
|
||||
<< QString("255.00.40.30") << 0 << 12
|
||||
<< QStringList( QStringList() << "255" << "00" << "40"
|
||||
<< "30" );
|
||||
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
|
||||
<< QStringList( QStringList() << "55" );
|
||||
<< QStringList( QStringList() << "55" );
|
||||
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
|
||||
<< QStringList( QStringList() << "0.0" );
|
||||
<< QStringList( QStringList() << "0.0" );
|
||||
|
||||
// mathematical trivia
|
||||
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
|
||||
<< QStringList( QStringList() << "aa" );
|
||||
<< QStringList( QStringList() << "aa" );
|
||||
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
|
||||
<< QStringList( QStringList() << "aaaa" );
|
||||
<< QStringList( QStringList() << "aaaa" );
|
||||
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
|
||||
<< QStringList( QStringList() << QString() );
|
||||
<< QStringList( QStringList() << QString() );
|
||||
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
|
||||
<< QStringList( QStringList() << "aaaaaaaa" );
|
||||
<< QStringList( QStringList() << "aaaaaaaa" );
|
||||
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
|
||||
<< QStringList( QStringList() << "" );
|
||||
<< QStringList( QStringList() << "" );
|
||||
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|("
|
||||
"?=a$)))*a$")
|
||||
<< QString("aaa") << 0 << 3
|
||||
<< QStringList( QStringList() << "a" << "a" << "" );
|
||||
"?=a$)))*a$")
|
||||
<< QString("aaa") << 0 << 3
|
||||
<< QStringList( QStringList() << "a" << "a" << "" );
|
||||
QTest::newRow( stri + "math14" ) << QString("^(?:((?:^a)?\\2\\3)(\\3\\1|(?=a$))(\\1\\2|("
|
||||
"?=a$)))*a$")
|
||||
<< QString("aaaaa") << 0 << 5
|
||||
<< QStringList( QStringList() << "a" << "a" << "aa" );
|
||||
"?=a$)))*a$")
|
||||
<< QString("aaaaa") << 0 << 5
|
||||
<< QStringList( QStringList() << "a" << "a" << "aa" );
|
||||
QTest::newRow( stri + "math17" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaa") << 0 << 3
|
||||
<< QStringList( QStringList() << "" << "" << "" << "aaa"
|
||||
<< "a" << "aa" );
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaa") << 0 << 3
|
||||
<< QStringList( QStringList() << "" << "" << "" << "aaa" << "a" << "aa" );
|
||||
QTest::newRow( stri + "math18" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaa") << 0 << 5
|
||||
<< QStringList( QStringList() << "aaaaa" << "a" << "aaa"
|
||||
<< "" << "" << "" );
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaa") << 0 << 5
|
||||
<< QStringList( QStringList() << "aaaaa" << "a" << "aaa" << "" << "" << "" );
|
||||
QTest::newRow( stri + "math19" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaaaaa") << 0 << 8
|
||||
<< QStringList( QStringList() << "" << "" << ""
|
||||
<< "aaaaaaaa" << "a"
|
||||
<< "aa" );
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaaaaa") << 0 << 8
|
||||
<< QStringList( QStringList() << "" << "" << "" << "aaaaaaaa" << "a" << "aa" );
|
||||
QTest::newRow( stri + "math20" ) << QString("^(?:(a(?:(\\1\\3)(\\1\\2))*(?:\\1\\3)?)|((?"
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaaaaaa") << -1 << -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
":(\\4(?:^a)?\\6)(\\4\\5))*(?:\\4\\6)?))$")
|
||||
<< QString("aaaaaaaaa") << -1 << -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
QTest::newRow( stri + "math21" ) << QString("^(aa+)\\1+$") << QString("aaaaaaaaaaaa") << 0 << 12
|
||||
<< QStringList( QStringList() << "aa" );
|
||||
<< QStringList( QStringList() << "aa" );
|
||||
|
||||
static const char * const squareRegExp[] = {
|
||||
"^a(?:(\\1aa)a)*$",
|
||||
"^(\\2(\\1a))+$",
|
||||
"^((\\2a)*)\\1\\2a$",
|
||||
0
|
||||
};
|
||||
"^a(?:(\\1aa)a)*$",
|
||||
"^(\\2(\\1a))+$",
|
||||
"^((\\2a)*)\\1\\2a$",
|
||||
0
|
||||
};
|
||||
|
||||
int ii = 0;
|
||||
|
||||
while ( squareRegExp[ii] != 0 ) {
|
||||
for ( int j = 0; j < 100; j++ ) {
|
||||
QString name;
|
||||
name.sprintf( "square%.1d%.2d", ii, j );
|
||||
for ( int j = 0; j < 100; j++ ) {
|
||||
QString name;
|
||||
name.sprintf( "square%.1d%.2d", ii, j );
|
||||
|
||||
QString target = "";
|
||||
target.fill( 'a', j );
|
||||
QString target = "";
|
||||
target.fill( 'a', j );
|
||||
|
||||
int pos = -1;
|
||||
int len = -1;
|
||||
int pos = -1;
|
||||
int len = -1;
|
||||
|
||||
for ( int k = 1; k * k <= j; k++ ) {
|
||||
if ( k * k == j ) {
|
||||
pos = 0;
|
||||
len = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( int k = 1; k * k <= j; k++ ) {
|
||||
if ( k * k == j ) {
|
||||
pos = 0;
|
||||
len = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QTest::newRow( name.toLatin1() ) << QString( squareRegExp[ii] ) << target
|
||||
<< pos << len << QStringList( "IGNORE ME" );
|
||||
}
|
||||
ii++;
|
||||
QTest::newRow( name.toLatin1() ) << QString( squareRegExp[ii] ) << target
|
||||
<< pos << len << QStringList( "IGNORE ME" );
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
|
||||
// miscellaneous
|
||||
QTest::newRow( stri + "misc00" ) << QString(email)
|
||||
<< QString("troll1@trolltech.com") << 0 << 20
|
||||
<< QStringList();
|
||||
<< QString("troll1@trolltech.com") << 0 << 20
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "misc01" ) << QString("[0-9]*\\.[0-9]+") << QString("pi = 3.14") << 5 << 4
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
|
||||
// or operator
|
||||
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 + "or09" ) << QString("(?:a|b)") << QString("cba") << 1 << 1 << QStringList();
|
||||
QTest::newRow( stri + "or10" ) << QString("(?:ab|ba)") << QString("aba") << 0 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "or11" ) << QString("(?:ab|ba)") << QString("bab") << 0 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "or12" ) << QString("(?:ab|ba)") << QString("caba") << 1 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "or13" ) << QString("(?:ab|ba)") << QString("cbab") << 1 << 2
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
|
||||
// quantifiers
|
||||
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
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
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
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
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
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
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
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
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
|
||||
<< QStringList( QStringList() << "a" << "a" << "a" );
|
||||
<< QStringList( QStringList() << "a" << "a" << "a" );
|
||||
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
|
||||
<< QStringList( QStringList() << "abc" << "c" << "c" );
|
||||
<< QStringList( QStringList() << "abc" << "c" << "c" );
|
||||
QTest::newRow( stri + "qua12" ) << QString("((([a-j])){2,4})") << QString("a") << -1 << -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
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
|
||||
<< QStringList( QStringList() << "abcd" << "d" << "d" );
|
||||
<< QStringList( QStringList() << "abcd" << "d" << "d" );
|
||||
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
|
||||
<< QStringList( QStringList() << "bcd" << "d" << "d" );
|
||||
<< QStringList( QStringList() << "bcd" << "d" << "d" );
|
||||
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
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
<< QStringList( QStringList() << "" << "" << "" );
|
||||
QTest::newRow( stri + "qua19" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("123332333") << 0
|
||||
<< 9
|
||||
<< QStringList( QStringList() << "123332333" << "2333"
|
||||
<< "3" );
|
||||
<< 9
|
||||
<< QStringList( QStringList() << "123332333" << "2333"
|
||||
<< "3" );
|
||||
QTest::newRow( stri + "qua20" ) << QString("(1(2(3){3,4}){2,3}){1,2}")
|
||||
<< QString("12333323333233331233332333323333") << 0 << 32
|
||||
<< QStringList( QStringList() << "1233332333323333"
|
||||
<< "23333" << "3" );
|
||||
<< QString("12333323333233331233332333323333") << 0 << 32
|
||||
<< QStringList( QStringList() << "1233332333323333"
|
||||
<< "23333" << "3" );
|
||||
QTest::newRow( stri + "qua21" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("") << -1 << -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
QTest::newRow( stri + "qua22" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333") << -1
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
QTest::newRow( stri + "qua23" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("12333233") << -1
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
QTest::newRow( stri + "qua24" ) << QString("(1(2(3){3,4}){2,3}){1,2}") << QString("122333") << -1
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
<< -1
|
||||
<< QStringList( QStringList() << QString()
|
||||
<< QString()
|
||||
<< QString() );
|
||||
|
||||
// star operator
|
||||
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 + "star04" ) << QString("(?:a)*") << QString("aaa") << 0 << 3 << QStringList();
|
||||
QTest::newRow( stri + "star05" ) << QString("(?:a)*") << QString("bbbbaaa") << 0 << 0
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star06" ) << QString("(?:a)*") << QString("bbbbaaabbaaaaa") << 0 << 0
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star07" ) << QString("(?:b)*(?:a)*") << QString("") << 0 << 0
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star08" ) << QString("(?:b)*(?:a)*") << QString("a") << 0 << 1
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star09" ) << QString("(?:b)*(?:a)*") << QString("aaa") << 0 << 3
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star10" ) << QString("(?:b)*(?:a)*") << QString("bbbbaaa") << 0 << 7
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
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 + "star13" ) << QString("(?:a|b)*") << QString("abac") << 0 << 3
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
QTest::newRow( stri + "star14" ) << QString("(?:a|b|)*") << QString("c") << 0 << 0
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
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
|
||||
<< QStringList();
|
||||
<< QStringList();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -544,19 +535,19 @@ void tst_QRegExp::exactMatch()
|
||||
QRegExp rx_W( "\\W" );
|
||||
|
||||
for ( int i = 0; i < 65536; i++ ) {
|
||||
QChar ch( i );
|
||||
bool is_d = ( ch.category() == QChar::Number_DecimalDigit );
|
||||
bool is_s = ch.isSpace();
|
||||
bool is_w = ( ch.isLetterOrNumber()
|
||||
QChar ch( i );
|
||||
bool is_d = ( ch.category() == QChar::Number_DecimalDigit );
|
||||
bool is_s = ch.isSpace();
|
||||
bool is_w = ( ch.isLetterOrNumber()
|
||||
|| ch.isMark()
|
||||
|| ch == '_' );
|
||||
|
||||
QVERIFY( rx_d.exactMatch(QString(ch)) == is_d );
|
||||
QVERIFY( rx_s.exactMatch(QString(ch)) == is_s );
|
||||
QVERIFY( rx_w.exactMatch(QString(ch)) == is_w );
|
||||
QVERIFY( rx_D.exactMatch(QString(ch)) != is_d );
|
||||
QVERIFY( rx_S.exactMatch(QString(ch)) != is_s );
|
||||
QVERIFY( rx_W.exactMatch(QString(ch)) != is_w );
|
||||
QVERIFY( rx_d.exactMatch(QString(ch)) == is_d );
|
||||
QVERIFY( rx_s.exactMatch(QString(ch)) == is_s );
|
||||
QVERIFY( rx_w.exactMatch(QString(ch)) == is_w );
|
||||
QVERIFY( rx_D.exactMatch(QString(ch)) != is_d );
|
||||
QVERIFY( rx_S.exactMatch(QString(ch)) != is_s );
|
||||
QVERIFY( rx_W.exactMatch(QString(ch)) != is_w );
|
||||
}
|
||||
}
|
||||
|
||||
@ -652,9 +643,9 @@ void tst_QRegExp::indexIn()
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,9 +661,9 @@ void tst_QRegExp::indexIn()
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
if ( caps.size() > 1 && caps[1] != "IGNORE ME" ) {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -702,14 +693,14 @@ void tst_QRegExp::lastIndexIn()
|
||||
QStringList mycaps = rx.capturedTexts();
|
||||
|
||||
if ( mypos <= pos || pos == -1 ) {
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
|
||||
if (caps.size() > 1 && caps[1] != "IGNORE ME") {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
}
|
||||
if (caps.size() > 1 && caps[1] != "IGNORE ME") {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,14 +713,14 @@ void tst_QRegExp::lastIndexIn()
|
||||
QStringList mycaps = rx.capturedTexts();
|
||||
|
||||
if ( mypos <= pos || pos == -1 ) {
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
QCOMPARE( mypos, pos );
|
||||
QCOMPARE( mylen, len );
|
||||
|
||||
if (caps.size() > 1 && caps[1] != "IGNORE ME") {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); i++ )
|
||||
QCOMPARE( mycaps[i], caps[i] );
|
||||
}
|
||||
if (caps.size() > 1 && caps[1] != "IGNORE ME") {
|
||||
QCOMPARE( mycaps.count(), caps.count() );
|
||||
for ( int i = 1; i < (int) mycaps.count(); 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("two true '\\' in input") << "\\\\Qt;" << "\\\\Qt;" << true;
|
||||
QTest::newRow("a '\\' at the end") << "\\\\Qt;" << "\\\\Qt;" << true;
|
||||
|
||||
}
|
||||
|
||||
void tst_QRegExp::testEscapingWildcard(){
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
void tst_QRegExp::testInvalidWildcard(){
|
||||
QFETCH(QString, pattern);
|
||||
|
||||
@ -1018,7 +1009,7 @@ void tst_QRegExp::rainersSlowRegExpCopyBug()
|
||||
// this test should take an extreme amount of time if QRegExp is broken
|
||||
QRegExp original(email);
|
||||
#if defined(Q_OS_WINCE)
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
#else
|
||||
for (int i = 0; i < 100000; ++i) {
|
||||
#endif
|
||||
@ -1071,7 +1062,7 @@ void Thread::run()
|
||||
int x;
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
#else
|
||||
for (int j = 0; j < 10000; ++j) {
|
||||
#endif
|
||||
@ -1113,7 +1104,7 @@ void Thread2::run()
|
||||
int x;
|
||||
|
||||
#if defined(Q_OS_WINCE)
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
#else
|
||||
for (int j = 0; j < 10000; ++j) {
|
||||
#endif
|
||||
|
@ -165,11 +165,11 @@ void tst_QSize::expandedTo_data()
|
||||
QTest::addColumn<QSize>("input2");
|
||||
QTest::addColumn<QSize>("expected");
|
||||
|
||||
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("data0") << QSize(10,12) << QSize(6,4) << QSize(10,12);
|
||||
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,
|
||||
// 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()
|
||||
@ -187,11 +187,11 @@ void tst_QSize::boundedTo_data()
|
||||
QTest::addColumn<QSize>("input2");
|
||||
QTest::addColumn<QSize>("expected");
|
||||
|
||||
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("data0") << QSize(10,12) << QSize(6,4) << QSize(6,4);
|
||||
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,
|
||||
// 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()
|
||||
@ -209,8 +209,8 @@ void tst_QSize::transpose_data()
|
||||
QTest::addColumn<QSize>("expected");
|
||||
|
||||
QTest::newRow("data0") << QSize(10,12) << QSize(12,10);
|
||||
QTest::newRow("data1") << QSize(0,0) << QSize(0,0);
|
||||
QTest::newRow("data3") << QSize(6,4) << QSize(4,6);
|
||||
QTest::newRow("data1") << QSize(0,0) << QSize(0,0);
|
||||
QTest::newRow("data3") << QSize(6,4) << QSize(4,6);
|
||||
}
|
||||
|
||||
void tst_QSize::transpose()
|
||||
|
@ -562,19 +562,19 @@ void tst_QString::utf8_data()
|
||||
QTest::addColumn<QString>("res" );
|
||||
|
||||
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")
|
||||
<< 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( 0x05d3 );
|
||||
str += QChar( 0x05d2 );
|
||||
QTest::newRow( "str2" ) << QByteArray("\327\251\327\223\327\222")
|
||||
<< str;
|
||||
<< str;
|
||||
|
||||
str = QChar( 0x20ac );
|
||||
str += " some text";
|
||||
QTest::newRow( "str3" ) << QByteArray("\342\202\254 some text")
|
||||
<< str;
|
||||
<< str;
|
||||
|
||||
str = "Old Italic: ";
|
||||
str += QChar(0xd800);
|
||||
@ -710,14 +710,14 @@ void tst_QString::acc_01()
|
||||
QVERIFY(*a.toLatin1().constData() == '\0');
|
||||
{
|
||||
#if defined(Q_OS_WINCE)
|
||||
int argc = 0;
|
||||
QCoreApplication app(argc, 0);
|
||||
int argc = 0;
|
||||
QCoreApplication app(argc, 0);
|
||||
#endif
|
||||
QFile f("COMPARE.txt");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream ts( &f );
|
||||
QFile f("COMPARE.txt");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
QTextStream ts( &f );
|
||||
ts.setCodec(QTextCodec::codecForName("UTF-16"));
|
||||
ts << "Abc";
|
||||
ts << "Abc";
|
||||
}
|
||||
}
|
||||
|
||||
@ -775,8 +775,6 @@ void tst_QString::constructor()
|
||||
QVERIFY( empty.isEmpty() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tst_QString::constructorQByteArray_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("src" );
|
||||
@ -1187,17 +1185,17 @@ void tst_QString::indexOf2()
|
||||
QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseInsensitive), resultpos );
|
||||
QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos );
|
||||
if ( needle.length() > 0 ) {
|
||||
got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive );
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
got = haystack.lastIndexOf( needle, -1, Qt::CaseInsensitive );
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive );
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
got = haystack.lastIndexOf( needle, -1, Qt::CaseInsensitive );
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
}
|
||||
|
||||
QCOMPARE( chaystack.indexOf(cneedle, 0), resultpos );
|
||||
QCOMPARE( QByteArrayMatcher(cneedle).indexIn(chaystack, 0), resultpos );
|
||||
if ( cneedle.length() > 0 ) {
|
||||
got = chaystack.lastIndexOf(cneedle, -1);
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
got = chaystack.lastIndexOf(cneedle, -1);
|
||||
QVERIFY( got == resultpos || (resultpos >= 0 && got >= resultpos) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1778,22 +1776,22 @@ void tst_QString::append_bytearray_data()
|
||||
void tst_QString::append_bytearray()
|
||||
{
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
str.append( ba );
|
||||
str.append( ba );
|
||||
|
||||
QTEST( str, "res" );
|
||||
QTEST( str, "res" );
|
||||
}
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str.append( ba );
|
||||
QTextCodec::setCodecForCStrings( 0 );
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str.append( ba );
|
||||
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()
|
||||
{
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
str += ba;
|
||||
str += ba;
|
||||
|
||||
QTEST( str, "res" );
|
||||
QTEST( str, "res" );
|
||||
}
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str += ba;
|
||||
QTextCodec::setCodecForCStrings( 0 );
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str += ba;
|
||||
QTextCodec::setCodecForCStrings( 0 );
|
||||
|
||||
QTEST( str, "res" );
|
||||
QTEST( str, "res" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1866,23 +1864,23 @@ void tst_QString::prepend_bytearray_data()
|
||||
void tst_QString::prepend_bytearray()
|
||||
{
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
str.prepend( ba );
|
||||
str.prepend( ba );
|
||||
|
||||
QFETCH( QString, res );
|
||||
QCOMPARE( str, res );
|
||||
QFETCH( QString, res );
|
||||
QCOMPARE( str, res );
|
||||
}
|
||||
{
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
QFETCH( QString, str );
|
||||
QFETCH( QByteArray, ba );
|
||||
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str.prepend( ba );
|
||||
QTextCodec::setCodecForCStrings( 0 );
|
||||
QTextCodec::setCodecForCStrings( QTextCodec::codecForMib(4) ); // Latin 1
|
||||
str.prepend( ba );
|
||||
QTextCodec::setCodecForCStrings( 0 );
|
||||
|
||||
QTEST( str, "res" );
|
||||
QTEST( str, "res" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1902,13 +1900,13 @@ void tst_QString::replace_uint_uint()
|
||||
QTEST( s2, "result" );
|
||||
|
||||
if ( after.length() == 1 ) {
|
||||
QString s3 = string;
|
||||
s3.replace( (uint) index, (uint) len, QChar(after[0]) );
|
||||
QTEST( s3, "result" );
|
||||
QString s3 = string;
|
||||
s3.replace( (uint) index, (uint) len, QChar(after[0]) );
|
||||
QTEST( s3, "result" );
|
||||
|
||||
QString s4 = string;
|
||||
s4.replace( (uint) index, (uint) len, QChar(after[0]).toLatin1() );
|
||||
QTEST( s4, "result" );
|
||||
QString s4 = string;
|
||||
s4.replace( (uint) index, (uint) len, QChar(after[0]).toLatin1() );
|
||||
QTEST( s4, "result" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1961,17 +1959,17 @@ void tst_QString::replace_string()
|
||||
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
|
||||
if ( before.length() == 1 ) {
|
||||
QChar ch = before.at( 0 );
|
||||
QChar ch = before.at( 0 );
|
||||
|
||||
QString s1 = string;
|
||||
s1.replace( ch, after, cs );
|
||||
QTEST( s1, "result" );
|
||||
QString s1 = string;
|
||||
s1.replace( ch, after, cs );
|
||||
QTEST( s1, "result" );
|
||||
|
||||
if ( QChar(ch.toLatin1()) == ch ) {
|
||||
QString s2 = string;
|
||||
s2.replace( ch.toLatin1(), after, cs );
|
||||
QTEST( s2, "result" );
|
||||
}
|
||||
if ( QChar(ch.toLatin1()) == ch ) {
|
||||
QString s2 = string;
|
||||
s2.replace( ch.toLatin1(), after, cs );
|
||||
QTEST( s2, "result" );
|
||||
}
|
||||
}
|
||||
|
||||
QString s3 = string;
|
||||
@ -2006,11 +2004,11 @@ void tst_QString::remove_uint_uint()
|
||||
QFETCH( QString, after );
|
||||
|
||||
if ( after.length() == 0 ) {
|
||||
QString s1 = string;
|
||||
s1.remove( (uint) index, (uint) len );
|
||||
QTEST( s1, "result" );
|
||||
QString s1 = string;
|
||||
s1.remove( (uint) index, (uint) len );
|
||||
QTEST( s1, "result" );
|
||||
} else
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
}
|
||||
|
||||
void tst_QString::remove_string()
|
||||
@ -2023,33 +2021,33 @@ void tst_QString::remove_string()
|
||||
Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
|
||||
if ( after.length() == 0 ) {
|
||||
if ( before.length() == 1 && cs ) {
|
||||
QChar ch = before.at( 0 );
|
||||
if ( before.length() == 1 && cs ) {
|
||||
QChar ch = before.at( 0 );
|
||||
|
||||
QString s1 = string;
|
||||
s1.remove( ch );
|
||||
QTEST( s1, "result" );
|
||||
QString s1 = string;
|
||||
s1.remove( ch );
|
||||
QTEST( s1, "result" );
|
||||
|
||||
if ( QChar(ch.toLatin1()) == ch ) {
|
||||
QString s2 = string;
|
||||
s2.remove( ch );
|
||||
QTEST( s2, "result" );
|
||||
}
|
||||
}
|
||||
if ( QChar(ch.toLatin1()) == ch ) {
|
||||
QString s2 = string;
|
||||
s2.remove( ch );
|
||||
QTEST( s2, "result" );
|
||||
}
|
||||
}
|
||||
|
||||
QString s3 = string;
|
||||
s3.remove( before, cs );
|
||||
QTEST( s3, "result" );
|
||||
QString s3 = string;
|
||||
s3.remove( before, cs );
|
||||
QTEST( s3, "result" );
|
||||
|
||||
QString s4 = string;
|
||||
s4.replace( QRegExp(QRegExp::escape(before), cs), after );
|
||||
QTEST( s4, "result" );
|
||||
QString s4 = string;
|
||||
s4.replace( QRegExp(QRegExp::escape(before), cs), after );
|
||||
QTEST( s4, "result" );
|
||||
|
||||
QString s5 = string;
|
||||
s5.replace( QRegExp(before, cs, QRegExp::FixedString), after );
|
||||
QTEST( s5, "result" );
|
||||
QString s5 = string;
|
||||
s5.replace( QRegExp(before, cs, QRegExp::FixedString), after );
|
||||
QTEST( s5, "result" );
|
||||
} else {
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
}
|
||||
}
|
||||
|
||||
@ -2060,10 +2058,10 @@ void tst_QString::remove_regexp()
|
||||
QFETCH( QString, after );
|
||||
|
||||
if ( after.length() == 0 ) {
|
||||
string.remove( QRegExp(regexp) );
|
||||
QTEST( string, "result" );
|
||||
string.remove( QRegExp(regexp) );
|
||||
QTEST( string, "result" );
|
||||
} else {
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
QCOMPARE( 0, 0 ); // shut QtTest
|
||||
}
|
||||
}
|
||||
|
||||
@ -2354,15 +2352,15 @@ void tst_QString::toUShort()
|
||||
QVERIFY(ok);
|
||||
|
||||
if (sizeof(short) == 2) {
|
||||
a = "65536";
|
||||
QCOMPARE(a.toUShort(),(ushort)0);
|
||||
QCOMPARE(a.toUShort(&ok),(ushort)0);
|
||||
QVERIFY(!ok);
|
||||
a = "65536";
|
||||
QCOMPARE(a.toUShort(),(ushort)0);
|
||||
QCOMPARE(a.toUShort(&ok),(ushort)0);
|
||||
QVERIFY(!ok);
|
||||
|
||||
a = "123456";
|
||||
QCOMPARE(a.toUShort(),(ushort)0);
|
||||
QCOMPARE(a.toUShort(&ok),(ushort)0);
|
||||
QVERIFY(!ok);
|
||||
a = "123456";
|
||||
QCOMPARE(a.toUShort(),(ushort)0);
|
||||
QCOMPARE(a.toUShort(&ok),(ushort)0);
|
||||
QVERIFY(!ok);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2430,15 +2428,15 @@ void tst_QString::toShort()
|
||||
QVERIFY(ok);
|
||||
|
||||
if (sizeof(short) == 2) {
|
||||
a = "32768";
|
||||
QCOMPARE(a.toShort(),(short)0);
|
||||
QCOMPARE(a.toShort(&ok),(short)0);
|
||||
QVERIFY(!ok);
|
||||
a = "32768";
|
||||
QCOMPARE(a.toShort(),(short)0);
|
||||
QCOMPARE(a.toShort(&ok),(short)0);
|
||||
QVERIFY(!ok);
|
||||
|
||||
a = "-32769";
|
||||
QCOMPARE(a.toShort(),(short)0);
|
||||
QCOMPARE(a.toShort(&ok),(short)0);
|
||||
QVERIFY(!ok);
|
||||
a = "-32769";
|
||||
QCOMPARE(a.toShort(),(short)0);
|
||||
QCOMPARE(a.toShort(&ok),(short)0);
|
||||
QVERIFY(!ok);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2506,25 +2504,25 @@ void tst_QString::toInt()
|
||||
QVERIFY(ok);
|
||||
|
||||
if (sizeof(int) == 4) {
|
||||
a = "-2147483647"; // -(2**31 - 1)
|
||||
QCOMPARE(a.toInt(),-2147483647);
|
||||
QCOMPARE(a.toInt(&ok),-2147483647);
|
||||
QVERIFY(ok);
|
||||
a = "-2147483647"; // -(2**31 - 1)
|
||||
QCOMPARE(a.toInt(),-2147483647);
|
||||
QCOMPARE(a.toInt(&ok),-2147483647);
|
||||
QVERIFY(ok);
|
||||
|
||||
a = "2147483648"; // 2**31
|
||||
QCOMPARE(a.toInt(),0);
|
||||
QCOMPARE(a.toInt(&ok),0);
|
||||
QVERIFY(!ok);
|
||||
a = "2147483648"; // 2**31
|
||||
QCOMPARE(a.toInt(),0);
|
||||
QCOMPARE(a.toInt(&ok),0);
|
||||
QVERIFY(!ok);
|
||||
|
||||
a = "-2147483648"; // -2**31
|
||||
QCOMPARE(a.toInt(),-2147483647 - 1);
|
||||
QCOMPARE(a.toInt(&ok),-2147483647 - 1);
|
||||
QVERIFY(ok);
|
||||
a = "-2147483648"; // -2**31
|
||||
QCOMPARE(a.toInt(),-2147483647 - 1);
|
||||
QCOMPARE(a.toInt(&ok),-2147483647 - 1);
|
||||
QVERIFY(ok);
|
||||
|
||||
a = "2147483649"; // 2**31 + 1
|
||||
QCOMPARE(a.toInt(),0);
|
||||
QCOMPARE(a.toInt(&ok),0);
|
||||
QVERIFY(!ok);
|
||||
a = "2147483649"; // 2**31 + 1
|
||||
QCOMPARE(a.toInt(),0);
|
||||
QCOMPARE(a.toInt(&ok),0);
|
||||
QVERIFY(!ok);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2547,10 +2545,10 @@ void tst_QString::toUInt()
|
||||
QVERIFY(ok);
|
||||
|
||||
if (sizeof(int) == 4) {
|
||||
a = "4294967296"; // 2**32
|
||||
QCOMPARE(a.toUInt(),0u);
|
||||
QCOMPARE(a.toUInt(&ok),0u);
|
||||
QVERIFY(!ok);
|
||||
a = "4294967296"; // 2**32
|
||||
QCOMPARE(a.toUInt(),0u);
|
||||
QCOMPARE(a.toUInt(&ok),0u);
|
||||
QVERIFY(!ok);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2649,9 +2647,9 @@ void tst_QString::toLongLong()
|
||||
|
||||
str = "-9223372036854775808"; // LLONG_MIN
|
||||
QCOMPARE( str.toLongLong( 0 ),
|
||||
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
|
||||
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
|
||||
QCOMPARE( str.toLongLong( &ok ),
|
||||
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
|
||||
-Q_INT64_C(9223372036854775807) - Q_INT64_C(1) );
|
||||
QVERIFY( ok );
|
||||
|
||||
str = "aaaa9223372036854775807aaaa";
|
||||
@ -2738,10 +2736,10 @@ void tst_QString::toDouble()
|
||||
bool ok;
|
||||
double d = str.toDouble( &ok );
|
||||
if ( result_ok ) {
|
||||
QTEST( d, "result" );
|
||||
QVERIFY( ok );
|
||||
QTEST( d, "result" );
|
||||
QVERIFY( ok );
|
||||
} 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_UINT64_C(1099511627776)), QString("1099511627776"));
|
||||
QCOMPARE(a.setNum(Q_INT64_C(9223372036854775807)), // LLONG_MAX
|
||||
QString("9223372036854775807"));
|
||||
QString("9223372036854775807"));
|
||||
QCOMPARE(a.setNum(-Q_INT64_C(9223372036854775807) - Q_INT64_C(1)),
|
||||
QString("-9223372036854775808"));
|
||||
QString("-9223372036854775808"));
|
||||
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,'g',30),(QString)"9.31322574615478515625e-010");
|
||||
@ -2989,8 +2987,8 @@ void tst_QString::check_QDataStream()
|
||||
QString a;
|
||||
QByteArray ar;
|
||||
{
|
||||
QDataStream out(&ar,QIODevice::WriteOnly);
|
||||
out << QString("COMPARE Text");
|
||||
QDataStream out(&ar,QIODevice::WriteOnly);
|
||||
out << QString("COMPARE Text");
|
||||
}
|
||||
{
|
||||
QDataStream in(&ar,QIODevice::ReadOnly);
|
||||
@ -3004,13 +3002,13 @@ void tst_QString::check_QTextStream()
|
||||
QString a;
|
||||
QByteArray ar;
|
||||
{
|
||||
QTextStream out(&ar,QIODevice::WriteOnly);
|
||||
out << QString("This is COMPARE Text");
|
||||
QTextStream out(&ar,QIODevice::WriteOnly);
|
||||
out << QString("This is COMPARE Text");
|
||||
}
|
||||
{
|
||||
QTextStream in(&ar,QIODevice::ReadOnly);
|
||||
in >> a;
|
||||
QCOMPARE(a,(QString)"This");
|
||||
QTextStream in(&ar,QIODevice::ReadOnly);
|
||||
in >> a;
|
||||
QCOMPARE(a,(QString)"This");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3018,17 +3016,17 @@ void tst_QString::check_QTextIOStream()
|
||||
{
|
||||
QString a;
|
||||
{
|
||||
a="";
|
||||
QTextStream ts(&a);
|
||||
ts << "pi \261= " << 3.125;
|
||||
QCOMPARE(a,(QString)"pi \261= 3.125");
|
||||
a="";
|
||||
QTextStream ts(&a);
|
||||
ts << "pi \261= " << 3.125;
|
||||
QCOMPARE(a,(QString)"pi \261= 3.125");
|
||||
}
|
||||
{
|
||||
a="123 456";
|
||||
int x,y;
|
||||
QTextStream(&a) >> x >> y;
|
||||
QCOMPARE(x,123);
|
||||
QCOMPARE(y,456);
|
||||
a="123 456";
|
||||
int x,y;
|
||||
QTextStream(&a) >> x >> y;
|
||||
QCOMPARE(x,123);
|
||||
QCOMPARE(y,456);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3256,8 +3254,8 @@ void tst_QString::fromLocal8Bit_data()
|
||||
QString longQString;
|
||||
|
||||
for (int l=0;l<111;l++) {
|
||||
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
}
|
||||
|
||||
//QTest::newRow("longString") << longQByteArray << -1 << longQString;
|
||||
@ -3303,8 +3301,8 @@ void tst_QString::local8Bit_data()
|
||||
QString longQString;
|
||||
|
||||
for (int l=0;l<111;l++) {
|
||||
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQByteArray = longQByteArray + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
longQString += "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
}
|
||||
|
||||
QTest::newRow("longString") << longQString << longQByteArray;
|
||||
@ -3569,7 +3567,7 @@ void tst_QString::arg()
|
||||
QString firstName( "James" );
|
||||
QString lastName( "Bond" );
|
||||
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") );
|
||||
|
||||
// number overloads
|
||||
@ -3577,7 +3575,7 @@ void tst_QString::arg()
|
||||
QCOMPARE( s4.arg(-1), QString("[-1]") );
|
||||
QCOMPARE( s4.arg(4294967295UL), QString("[4294967295]") ); // ULONG_MAX 32
|
||||
QCOMPARE( s4.arg(Q_INT64_C(9223372036854775807)), // LLONG_MAX
|
||||
QString("[9223372036854775807]") );
|
||||
QString("[9223372036854775807]") );
|
||||
|
||||
QCOMPARE( QString().arg(0), QString() );
|
||||
QCOMPARE( QString("").arg(0), QString("") );
|
||||
@ -4009,7 +4007,7 @@ void tst_QString::integer_conversion()
|
||||
QCOMPARE(ok, good);
|
||||
|
||||
if (ok) {
|
||||
QCOMPARE(d, num);
|
||||
QCOMPARE(d, num);
|
||||
}
|
||||
|
||||
QLocale::setDefault(QLocale::C);
|
||||
@ -4088,8 +4086,8 @@ void tst_QString::double_conversion_data()
|
||||
*/
|
||||
// Let's try some Arabic
|
||||
const quint16 arabic_str[] = { 0x0660, 0x066B, 0x0661, 0x0662,
|
||||
0x0663, 0x0664, 0x0065, 0x0662,
|
||||
0x0000 }; // "0.1234e2"
|
||||
0x0663, 0x0664, 0x0065, 0x0662,
|
||||
0x0000 }; // "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);
|
||||
|
||||
if (ok) {
|
||||
double diff = d - num;
|
||||
if (diff < 0)
|
||||
diff = -diff;
|
||||
QVERIFY(diff <= MY_DOUBLE_EPSILON);
|
||||
double diff = d - num;
|
||||
if (diff < 0)
|
||||
diff = -diff;
|
||||
QVERIFY(diff <= MY_DOUBLE_EPSILON);
|
||||
}
|
||||
|
||||
QLocale::setDefault(QLocale::C);
|
||||
@ -4130,11 +4128,11 @@ void tst_QString::tortureSprintfDouble()
|
||||
QString s;
|
||||
|
||||
for (; data->fmt != 0; ++data) {
|
||||
double d;
|
||||
char *buff = (char *)&d;
|
||||
# ifndef Q_BYTE_ORDER
|
||||
# error "Q_BYTE_ORDER not defined"
|
||||
# endif
|
||||
double d;
|
||||
char *buff = (char *)&d;
|
||||
# ifndef Q_BYTE_ORDER
|
||||
# error "Q_BYTE_ORDER not defined"
|
||||
# endif
|
||||
|
||||
# ifdef QT_ARMFPA
|
||||
buff[0] = data->bytes[4];
|
||||
@ -4145,20 +4143,20 @@ void tst_QString::tortureSprintfDouble()
|
||||
buff[5] = data->bytes[1];
|
||||
buff[6] = data->bytes[2];
|
||||
buff[7] = data->bytes[3];
|
||||
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
for (uint i = 0; i < 8; ++i)
|
||||
buff[i] = data->bytes[i];
|
||||
# else
|
||||
for (uint i = 0; i < 8; ++i)
|
||||
buff[7 - i] = data->bytes[i];
|
||||
# endif
|
||||
s.sprintf(data->fmt, d);
|
||||
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||
for (uint i = 0; i < 8; ++i)
|
||||
buff[i] = data->bytes[i];
|
||||
# else
|
||||
for (uint i = 0; i < 8; ++i)
|
||||
buff[7 - i] = data->bytes[i];
|
||||
# endif
|
||||
s.sprintf(data->fmt, d);
|
||||
#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");
|
||||
QCOMPARE(s.left(16), QString(data->expected).left(16));
|
||||
QCOMPARE(s.left(16), QString(data->expected).left(16));
|
||||
#else
|
||||
QCOMPARE(s, QString(data->expected));
|
||||
QCOMPARE(s, QString(data->expected));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -4361,7 +4359,7 @@ void tst_QString::localeAwareCompare()
|
||||
|
||||
#else
|
||||
if (!locale.isEmpty())
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -4374,7 +4372,7 @@ void tst_QString::split_data()
|
||||
|
||||
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")
|
||||
<< " "
|
||||
<< " "
|
||||
<< (QStringList() << "-rw-r--r--" << "" << "1" << "0" << "" << "0" << ""
|
||||
<< "519240" << "Jul" << "" << "9" << "" << "2002" << "bigfile");
|
||||
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);
|
||||
widths << 10 << 2 << 5;
|
||||
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();
|
||||
widths.clear();
|
||||
replaceValues << QVariant(QString("fisk"));
|
||||
widths << 100;
|
||||
QTest::newRow("str2") << QString("%9 og poteter") << replaceValues << widths << QString("f")
|
||||
<< QString("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffisk og poteter");
|
||||
<< QString("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffisk og poteter");
|
||||
}
|
||||
|
||||
void tst_QString::arg_fillChar()
|
||||
@ -4606,9 +4604,9 @@ void tst_QString::arg_fillChar()
|
||||
|
||||
QString actual = pattern;
|
||||
for (int i=0; i<replaceValues.count(); ++i) {
|
||||
const QVariant &var = replaceValues.at(i);
|
||||
const int width = widths.at(i);
|
||||
const QChar &fillChar = fillChars.at(i);
|
||||
const QVariant &var = replaceValues.at(i);
|
||||
const int width = widths.at(i);
|
||||
const QChar &fillChar = fillChars.at(i);
|
||||
switch (var.type()) {
|
||||
case QVariant::String: actual = actual.arg(var.toString(), width, fillChar); break;
|
||||
case QVariant::Int: actual = actual.arg(var.toInt(), width, base, fillChar); break;
|
||||
|
@ -410,20 +410,20 @@ void tst_QStringRef::indexOf2()
|
||||
QCOMPARE(haystackRef.indexOf(needle, 0, Qt::CaseInsensitive), resultpos);
|
||||
QCOMPARE(haystackRef.indexOf(needleRef, 0, Qt::CaseInsensitive), resultpos);
|
||||
if (needle.length() > 0) {
|
||||
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needle, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
|
||||
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystack.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
|
||||
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseSensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseInsensitive);
|
||||
QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,9 @@ void tst_QTimeLine::range()
|
||||
QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int)));
|
||||
timeLine.start();
|
||||
#ifdef Q_OS_WINCE
|
||||
QTest::qWait(1000);
|
||||
QTest::qWait(1000);
|
||||
#else
|
||||
QTest::qWait(100);
|
||||
QTest::qWait(100);
|
||||
#endif
|
||||
QCOMPARE(timeLine.state(), QTimeLine::Running);
|
||||
int oldValue = timeLine.currentFrame();
|
||||
@ -301,7 +301,7 @@ void tst_QTimeLine::loopCount()
|
||||
timeLine.stop();
|
||||
|
||||
timeLine.setDuration(2500); // ### some platforms have a very low resolution timer
|
||||
timeLine.setFrameRange(0, 2);
|
||||
timeLine.setFrameRange(0, 2);
|
||||
timeLine.setLoopCount(4);
|
||||
|
||||
QSignalSpy finishedSpy(&timeLine, SIGNAL(finished()));
|
||||
@ -333,9 +333,9 @@ void tst_QTimeLine::loopCount()
|
||||
|
||||
QCOMPARE(finishedSpy.count(), 2);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QTimeLine::interpolation()
|
||||
|
@ -118,39 +118,39 @@ void tst_QVarLengthArray::removeLast()
|
||||
void tst_QVarLengthArray::oldTests()
|
||||
{
|
||||
{
|
||||
QVarLengthArray<int, 256> sa(128);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
sa[0] = 0xfee;
|
||||
sa[10] = 0xff;
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
sa.resize(512);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
QVarLengthArray<int, 256> sa(128);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
sa[0] = 0xfee;
|
||||
sa[10] = 0xff;
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
sa.resize(512);
|
||||
QVERIFY(sa.data() == &sa[0]);
|
||||
QVERIFY(sa[0] == 0xfee);
|
||||
QVERIFY(sa[10] == 0xff);
|
||||
QVERIFY(sa.at(0) == 0xfee);
|
||||
QVERIFY(sa.at(10) == 0xff);
|
||||
QVERIFY(sa.value(0) == 0xfee);
|
||||
QVERIFY(sa.value(10) == 0xff);
|
||||
QVERIFY(sa.value(1000) == 0);
|
||||
QVERIFY(sa.value(1000, 12) == 12);
|
||||
QVERIFY(sa.size() == 512);
|
||||
sa.reserve(1024);
|
||||
QVERIFY(sa.capacity() == 1024);
|
||||
QVERIFY(sa.size() == 512);
|
||||
QVERIFY(sa.size() == 512);
|
||||
sa.reserve(1024);
|
||||
QVERIFY(sa.capacity() == 1024);
|
||||
QVERIFY(sa.size() == 512);
|
||||
}
|
||||
{
|
||||
QVarLengthArray<QString> sa(10);
|
||||
sa[0] = "Hello";
|
||||
sa[9] = "World";
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.reserve(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.resize(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
QVarLengthArray<QString> sa(10);
|
||||
sa[0] = "Hello";
|
||||
sa[9] = "World";
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.reserve(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
sa.resize(512);
|
||||
QVERIFY(*sa.data() == "Hello");
|
||||
QVERIFY(sa[9] == "World");
|
||||
}
|
||||
{
|
||||
int arr[2] = {1, 2};
|
||||
|
Loading…
Reference in New Issue
Block a user