Add autotest for QStringLiteral
Change-Id: Ia5a82bf3bf489373bc0823065aa9c2990430440c Reviewed-on: http://codereview.qt.nokia.com/1486 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>bb10
parent
6054ca2a31
commit
a3ac4f26e1
|
|
@ -223,6 +223,7 @@ private slots:
|
|||
void QTBUG9281_arg_locale();
|
||||
|
||||
void toUpperLower_icu();
|
||||
void literals();
|
||||
};
|
||||
|
||||
typedef QList<int> IntList;
|
||||
|
|
@ -5107,6 +5108,31 @@ void tst_QString::toUpperLower_icu()
|
|||
// the cleanup function will restore the default locale
|
||||
}
|
||||
|
||||
void tst_QString::literals()
|
||||
{
|
||||
#if defined(QT_QSTRING_UNICODE_MARKER) && (defined(Q_COMPILER_LAMBDA) || defined(Q_CC_GNU))
|
||||
QString str(QStringLiteral("abcd"));
|
||||
|
||||
QVERIFY(str.length() == 4);
|
||||
QVERIFY(str == QLatin1String("abcd"));
|
||||
QVERIFY(str.data_ptr()->ref == -1);
|
||||
QVERIFY(str.data_ptr()->offset == 0);
|
||||
|
||||
const QChar *s = str.constData();
|
||||
QString str2 = str;
|
||||
QVERIFY(str2.constData() == s);
|
||||
|
||||
// detach on non const access
|
||||
QVERIFY(str.data() != s);
|
||||
|
||||
QVERIFY(str2.constData() == s);
|
||||
QVERIFY(str2.data() != s);
|
||||
|
||||
#else
|
||||
QSKIP("Only tested on c++0x compliant compiler or gcc", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QString)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue