summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocale
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@nokia.com>2011-03-08 16:32:24 (GMT)
committerLiang Qi <liang.qi@nokia.com>2011-03-08 16:32:24 (GMT)
commit09fe2cd62df80373e602d47c570ae317a60a5293 (patch)
tree494689ed4f7ae7d75d938d851a18f382eb6ef464 /tests/auto/qlocale
parentdc2280dbcd27d3ff9cbcb230943cc1036e8a2761 (diff)
downloadQt-09fe2cd62df80373e602d47c570ae317a60a5293.zip
Qt-09fe2cd62df80373e602d47c570ae317a60a5293.tar.gz
Qt-09fe2cd62df80373e602d47c570ae317a60a5293.tar.bz2
Using list patterns to get a string from list in QLocale.
Reviewed-by: Denis Dzyubenko Task-number: QTBUG-17097
Diffstat (limited to 'tests/auto/qlocale')
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index cb69d54..b6c66d5 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -144,6 +144,7 @@ private slots:
void quoteString();
void uiLanguages();
void weekendDays();
+ void listPatterns();
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
@@ -2236,5 +2237,39 @@ void tst_QLocale::weekendDays()
QCOMPARE(c.weekendEnd(), Qt::Sunday);
}
+void tst_QLocale::listPatterns()
+{
+ QStringList sl1;
+ QStringList sl2;
+ sl2 << "aaa";
+ QStringList sl3;
+ sl3 << "aaa" << "bbb";
+ QStringList sl4;
+ sl4 << "aaa" << "bbb" << "ccc";
+ QStringList sl5;
+ sl5 << "aaa" << "bbb" << "ccc" << "ddd";
+
+ const QLocale c(QLocale::C);
+ QCOMPARE(c.createSeparatedList(sl1), QString(""));
+ QCOMPARE(c.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(c.createSeparatedList(sl3), QString("aaa, bbb"));
+ QCOMPARE(c.createSeparatedList(sl4), QString("aaa, bbb, ccc"));
+ QCOMPARE(c.createSeparatedList(sl5), QString("aaa, bbb, ccc, ddd"));
+
+ const QLocale en_US("en_US");
+ QCOMPARE(en_US.createSeparatedList(sl1), QString(""));
+ QCOMPARE(en_US.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(en_US.createSeparatedList(sl3), QString("aaa and bbb"));
+ QCOMPARE(en_US.createSeparatedList(sl4), QString("aaa, bbb, and ccc"));
+ QCOMPARE(en_US.createSeparatedList(sl5), QString("aaa, bbb, ccc, and ddd"));
+
+ const QLocale zh_CN("zh_CN");
+ QCOMPARE(zh_CN.createSeparatedList(sl1), QString(""));
+ QCOMPARE(zh_CN.createSeparatedList(sl2), QString("aaa"));
+ QCOMPARE(zh_CN.createSeparatedList(sl3), QString::fromUtf8("aaa" "\xe5\x92\x8c" "bbb"));
+ QCOMPARE(zh_CN.createSeparatedList(sl4), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe5\x92\x8c" "ccc"));
+ QCOMPARE(zh_CN.createSeparatedList(sl5), QString::fromUtf8("aaa" "\xe3\x80\x81" "bbb" "\xe3\x80\x81" "ccc" "\xe5\x92\x8c" "ddd"));
+}
+
QTEST_APPLESS_MAIN(tst_QLocale)
#include "tst_qlocale.moc"