summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-07-12 09:08:28 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-12 11:04:04 +0200
commita3ac4f26e1bc699f1e4ef15853d6db32f13d5c7f (patch)
tree2ccf45507fc16442effd0c6c60ae77c1b2d97d11 /tests
parent6054ca2a313d6164874e3e57bd5fb12be66a5c44 (diff)
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qstring/tst_qstring.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index abec5102b5..8c725fa109 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -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)