summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-17 16:48:28 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2011-03-17 16:48:28 (GMT)
commit08d5655d4ac291f97d164c96ecfe0a0d7e4ba654 (patch)
tree9ea65423fcb04e6f33d12a46582a730a4d1358fe /tests
parent903a52cd764ba4ace6c4d2d3b692f5b563fb326c (diff)
parenta70f9f5908f2db187e6818103d9599e1e45c130d (diff)
downloadQt-08d5655d4ac291f97d164c96ecfe0a0d7e4ba654.zip
Qt-08d5655d4ac291f97d164c96ecfe0a0d7e4ba654.tar.gz
Qt-08d5655d4ac291f97d164c96ecfe0a0d7e4ba654.tar.bz2
Merge branch 'master-i18n' of scm.dev.nokia.troll.no:qt/qt-earth-team into master-i18n
Conflicts: src/corelib/tools/qlocale.h
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp35
-rw-r--r--tests/manual/qlocale/miscellaneous.cpp11
-rw-r--r--tests/manual/qlocale/miscellaneous.h3
3 files changed, 49 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"
diff --git a/tests/manual/qlocale/miscellaneous.cpp b/tests/manual/qlocale/miscellaneous.cpp
index 0b2250a..a9694bf 100644
--- a/tests/manual/qlocale/miscellaneous.cpp
+++ b/tests/manual/qlocale/miscellaneous.cpp
@@ -49,6 +49,7 @@ MiscWidget::MiscWidget()
createLineEdit("Alternate quotes:", &alternateQuotedTextLabel, &alternateQuotedText);
textToQuote->setText("some text");
createLineEdit("Text direction:", &textDirectionLabel, &textDirection);
+ createLineEdit("List to seperated string:", &listToSeparatedStringLabel, &listToSeparatedStringText);
l->addWidget(textToQuoteLabel, 0, 0);
l->addWidget(textToQuote, 0, 1);
@@ -58,6 +59,8 @@ MiscWidget::MiscWidget()
l->addWidget(alternateQuotedText, 1, 3);
l->addWidget(textDirectionLabel, 2, 0);
l->addWidget(textDirection, 2, 1, 1, 3);
+ l->addWidget(listToSeparatedStringLabel, 3, 0);
+ l->addWidget(listToSeparatedStringText, 3, 1, 1, 3);
connect(textToQuote, SIGNAL(textChanged(QString)), this, SLOT(updateQuotedText(QString)));
@@ -72,10 +75,18 @@ void MiscWidget::updateQuotedText(QString str)
alternateQuotedText->setText(locale().quoteString(str, QLocale::AlternateQuotation));
}
+void MiscWidget::updateListToSeparatedStringText()
+{
+ QStringList test;
+ test << "aaa" << "bbb" << "ccc" << "ddd";
+ listToSeparatedStringText->setText(locale().createSeparatedList(test));
+}
+
void MiscWidget::localeChanged(QLocale locale)
{
setLocale(locale);
updateQuotedText(textToQuote->text());
+ updateListToSeparatedStringText();
textDirection->setText(locale.textDirection() == Qt::LeftToRight ? "Left To Right" : "Right To Left");
}
diff --git a/tests/manual/qlocale/miscellaneous.h b/tests/manual/qlocale/miscellaneous.h
index 33d8ef9..3b635b8 100644
--- a/tests/manual/qlocale/miscellaneous.h
+++ b/tests/manual/qlocale/miscellaneous.h
@@ -56,14 +56,17 @@ private:
QLabel *standardQuotedTextLabel;
QLabel *alternateQuotedTextLabel;
QLabel *textDirectionLabel;
+ QLabel *listToSeparatedStringLabel;
QLineEdit *textToQuote;
QLineEdit *standardQuotedText;
QLineEdit *alternateQuotedText;
QLineEdit *textDirection;
+ QLineEdit *listToSeparatedStringText;
private slots:
void localeChanged(QLocale locale);
void updateQuotedText(QString str);
+ void updateListToSeparatedStringText();
};
#endif // MISCELLANEOUS_H