diff options
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/global/qlogging/app/app.pro | 1 | ||||
-rw-r--r-- | tests/auto/corelib/global/qlogging/test/test.pro | 1 | ||||
-rw-r--r-- | tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 73 | ||||
-rw-r--r-- | tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 18 |
4 files changed, 81 insertions, 12 deletions
diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro index b11e792a4c..a7f6e68448 100644 --- a/tests/auto/corelib/global/qlogging/app/app.pro +++ b/tests/auto/corelib/global/qlogging/app/app.pro @@ -10,6 +10,7 @@ CONFIG += console SOURCES += main.cpp DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 +DEFINES += QT_MESSAGELOGCONTEXT gcc:!mingw: QMAKE_LFLAGS += -rdynamic diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index 788a2064cd..d4dce4a0c3 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -5,5 +5,6 @@ TARGET = ../tst_qlogging QT = core testlib SOURCES = ../tst_qlogging.cpp +DEFINES += QT_MESSAGELOGCONTEXT TEST_HELPER_INSTALLS = ../app/app DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index f1c99e5dab..015a13775d 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -116,9 +116,13 @@ private: */ void tst_QDebug::warningWithoutDebug() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { qWarning() << "A qWarning() message"; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtWarningMsg); QCOMPARE(s_msg, QString::fromLatin1("A qWarning() message")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -131,9 +135,13 @@ void tst_QDebug::warningWithoutDebug() const */ void tst_QDebug::criticalWithoutDebug() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { qCritical() << "A qCritical() message"; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtCriticalMsg); QCOMPARE(s_msg, QString::fromLatin1("A qCritical() message")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -143,9 +151,13 @@ void tst_QDebug::criticalWithoutDebug() const void tst_QDebug::debugWithBool() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { qDebug() << false << true; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("false true")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -291,6 +303,8 @@ void tst_QDebug::stateSaver() const void tst_QDebug::veryLongWarningMessage() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); QString test; { @@ -299,7 +313,9 @@ void tst_QDebug::veryLongWarningMessage() const test.append(part); qWarning("Test output:\n%s\nend", qPrintable(test)); } - QString file = __FILE__; int line = __LINE__ - 2; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 3; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtWarningMsg); QCOMPARE(s_msg, QString::fromLatin1("Test output:\n")+test+QString::fromLatin1("\nend")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -309,13 +325,17 @@ void tst_QDebug::veryLongWarningMessage() const void tst_QDebug::qDebugQChar() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); d << QChar('f'); d.nospace().noquote() << QChar('o') << QChar('o'); } - QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("'f' oo")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -328,12 +348,16 @@ void tst_QDebug::qDebugQStringRef() const { /* Use a basic string. */ { + QString file, function; + int line = 0; const QString in(QLatin1String("input")); const QStringRef inRef(&in); MessageHandlerSetter mhs(myMessageHandler); { qDebug() << inRef; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("\"input\"")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -343,11 +367,16 @@ void tst_QDebug::qDebugQStringRef() const /* Use a null QStringRef. */ { + QString file, function; + int line = 0; + const QStringRef inRef; MessageHandlerSetter mhs(myMessageHandler); { qDebug() << inRef; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("\"\"")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -358,13 +387,17 @@ void tst_QDebug::qDebugQStringRef() const void tst_QDebug::qDebugQLatin1String() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); d << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); d.nospace().noquote() << QLatin1String("baz"); } - QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -374,13 +407,17 @@ void tst_QDebug::qDebugQLatin1String() const void tst_QDebug::qDebugQByteArray() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); d << QByteArrayLiteral("foo") << QByteArrayLiteral("") << QByteArray("barbaz", 3); d.nospace().noquote() << QByteArrayLiteral("baz"); } - QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -397,11 +434,15 @@ Q_DECLARE_FLAGS(TestFlags, TestEnum) void tst_QDebug::qDebugQFlags() const { + QString file, function; + int line = 0; QFlags<TestEnum> flags(Flag1 | Flag2); MessageHandlerSetter mhs(myMessageHandler); { qDebug() << flags; } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("QFlags(0x1|0x10)")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -412,9 +453,13 @@ void tst_QDebug::qDebugQFlags() const void tst_QDebug::textStreamModifiers() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { qDebug() << hex << short(0xf) << int(0xf) << unsigned(0xf) << long(0xf) << qint64(0xf) << quint64(0xf); } - QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 2; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("f f f f f f")); QCOMPARE(QString::fromLatin1(s_file), file); @@ -424,13 +469,17 @@ void tst_QDebug::textStreamModifiers() const void tst_QDebug::resetFormat() const { + QString file, function; + int line = 0; MessageHandlerSetter mhs(myMessageHandler); { QDebug d = qDebug(); d.nospace().noquote() << hex << int(0xf); d.resetFormat() << int(0xf) << QStringLiteral("foo"); } - QString file = __FILE__; int line = __LINE__ - 4; QString function = Q_FUNC_INFO; +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif QCOMPARE(s_msgType, QtDebugMsg); QCOMPARE(s_msg, QString::fromLatin1("f15 \"foo\"")); QCOMPARE(QString::fromLatin1(s_file), file); diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 422340747b..77a60997a6 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -120,6 +120,7 @@ private slots: void testEmptyData(); void testResourceFiles(); void testRegistryShortRootNames(); + void trailingWhitespace(); #ifdef Q_OS_MAC void fileName(); #endif @@ -2053,6 +2054,23 @@ void tst_QSettings::testRegistryShortRootNames() #endif } +void tst_QSettings::trailingWhitespace() +{ + { + QSettings s("tst_QSettings_trailingWhitespace"); + s.setValue("trailingSpace", "x "); + s.setValue("trailingTab", "x\t"); + s.setValue("trailingNewline", "x\n"); + } + { + QSettings s("tst_QSettings_trailingWhitespace"); + QCOMPARE(s.value("trailingSpace").toString(), QLatin1String("x ")); + QCOMPARE(s.value("trailingTab").toString(), QLatin1String("x\t")); + QCOMPARE(s.value("trailingNewline").toString(), QLatin1String("x\n")); + s.clear(); + } +} + void tst_QSettings::fromFile_data() { populateWithFormats(); |