summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp2
-rw-r--r--tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp3
-rw-r--r--tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp32
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp11
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp5
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp12
6 files changed, 41 insertions, 24 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 290afec776..4a50a45ea6 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -324,7 +324,7 @@ void tst_QGlobal::qCoreAppStartupFunction()
{
QCOMPARE(qStartupFunctionValue, 0);
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qglobal") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(qStartupFunctionValue, 124);
}
diff --git a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp
index 33146cafd1..21d03cd04d 100644
--- a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp
+++ b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp
@@ -70,8 +70,7 @@ void tst_QProcessNoApplication::initializationDeadlock()
}
};
- static char argv0[] = "tst_QProcessNoApplication";
- char *argv[] = { argv0, 0 };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()), 0 };
int argc = 1;
QCoreApplication app(argc, argv);
MyThread thread;
diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
index ccaa2bec4f..78f2cdae69 100644
--- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
+++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp
@@ -88,7 +88,7 @@ public:
void tst_QCoreApplication::sendEventsOnProcessEvents()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -110,7 +110,7 @@ void tst_QCoreApplication::getSetCheck()
// Test the property
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(app.property("applicationVersion").toString(), v);
}
@@ -135,7 +135,7 @@ void tst_QCoreApplication::argc()
{
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
QCOMPARE(app.arguments().count(), 1);
@@ -143,7 +143,7 @@ void tst_QCoreApplication::argc()
{
int argc = 4;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication"),
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()),
const_cast<char*>("arg1"),
const_cast<char*>("arg2"),
const_cast<char*>("arg3") };
@@ -162,7 +162,7 @@ void tst_QCoreApplication::argc()
{
int argc = 2;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication"),
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()),
const_cast<char*>("-qmljsdebugger=port:3768,block") };
QCoreApplication app(argc, argv);
QCOMPARE(argc, 1);
@@ -196,7 +196,7 @@ public:
void tst_QCoreApplication::postEvent()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -281,7 +281,7 @@ void tst_QCoreApplication::postEvent()
void tst_QCoreApplication::removePostedEvents()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
@@ -460,7 +460,7 @@ public:
void tst_QCoreApplication::deliverInDefinedOrder()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
DeliverInDefinedOrderObject obj(&app);
@@ -500,7 +500,7 @@ public:
void tst_QCoreApplication::globalPostedEventsCount()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QCoreApplication::sendPostedEvents();
@@ -546,7 +546,7 @@ public:
void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
ProcessEventsAlwaysSendsPostedEventsObject object;
@@ -564,7 +564,7 @@ void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents()
void tst_QCoreApplication::reexec()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once
@@ -579,7 +579,7 @@ void tst_QCoreApplication::reexec()
void tst_QCoreApplication::execAfterExit()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
app.exit(1);
@@ -590,7 +590,7 @@ void tst_QCoreApplication::execAfterExit()
void tst_QCoreApplication::eventLoopExecAfterExit()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// exec once and exit
@@ -648,7 +648,7 @@ void tst_QCoreApplication::customEventDispatcher()
QVERIFY(!weak_ed.isNull());
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
// instantiating app should not overwrite the ED
QCOMPARE(QCoreApplication::eventDispatcher(), ed);
@@ -763,7 +763,7 @@ private slots:
void tst_QCoreApplication::testQuitLock()
{
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
QuitTester tester;
@@ -782,7 +782,7 @@ void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock()
};
int argc = 1;
- char *argv[] = { const_cast<char*>("tst_qcoreapplication") };
+ char *argv[] = { const_cast<char*>(QTest::currentAppName()) };
QCoreApplication app(argc, argv);
EventSpy spy;
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index 9219ff72df..d8965dee5d 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -48,6 +48,9 @@ class tst_QCommandLineParser : public QObject
{
Q_OBJECT
+public slots:
+ void initTestCase();
+
private slots:
void parsingModes_data();
@@ -81,9 +84,15 @@ private slots:
void testQuoteEscaping();
};
-static char *empty_argv[] = { const_cast<char*>("tst_qcommandlineparser") };
+static char *empty_argv[] = { 0 };
static int empty_argc = 1;
+void tst_QCommandLineParser::initTestCase()
+{
+ Q_ASSERT(!empty_argv[0]);
+ empty_argv[0] = const_cast<char*>(QTest::currentAppName());
+}
+
Q_DECLARE_METATYPE(QCommandLineParser::SingleDashWordOptionMode)
void tst_QCommandLineParser::parsingModes_data()
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 8411cfe29b..d6dea05755 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -1407,10 +1407,7 @@ void tst_QLocale::macDefaultLocale()
QCOMPARE(locale.decimalPoint(), QChar('.'));
QCOMPARE(locale.groupSeparator(), QChar(','));
QCOMPARE(locale.dateFormat(QLocale::ShortFormat), QString("M/d/yy"));
- if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6)
- QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, y"));
- else
- QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy"));
+ QCOMPARE(locale.dateFormat(QLocale::LongFormat), QString("MMMM d, yyyy"));
QCOMPARE(locale.timeFormat(QLocale::ShortFormat), QString("h:mm AP"));
QCOMPARE(locale.timeFormat(QLocale::LongFormat), QString("h:mm:ss AP t"));
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 0148ba6d03..48874781c0 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -5240,6 +5240,18 @@ void tst_QString::resizeAfterReserve()
s += "hello world";
s.resize(0);
QVERIFY(s.capacity() == 100);
+
+ // reserve() can't be used to truncate data
+ s.fill('x', 100);
+ s.reserve(50);
+ QVERIFY(s.capacity() == 100);
+ QVERIFY(s.size() == 100);
+
+ // even with increased ref count truncation isn't allowed
+ QString t = s;
+ s.reserve(50);
+ QVERIFY(s.capacity() == 100);
+ QVERIFY(s.size() == 100);
}
void tst_QString::resizeWithNegative() const