summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlocale/tst_qlocale.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-03-30 09:38:17 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-03-30 10:06:56 (GMT)
commitdcdafbcb132341bb22b6159f0f1dea1ef00f7c18 (patch)
tree29aca268024a8ae0d5a3aa8032e69690e264c428 /tests/auto/qlocale/tst_qlocale.cpp
parent5ef6ac6550f1692d66611e7918d85c7ebedda439 (diff)
downloadQt-dcdafbcb132341bb22b6159f0f1dea1ef00f7c18.zip
Qt-dcdafbcb132341bb22b6159f0f1dea1ef00f7c18.tar.gz
Qt-dcdafbcb132341bb22b6159f0f1dea1ef00f7c18.tar.bz2
String-to-number conversion functions should ignore trailing whitespaces.
According to our documentation we should ignore leading and trailing whitespaces when converting a string to number with QLocale::toInt and similar functions. However that didn't work for some locales - for those ones that declare groupseparator as 0xa0 (which looks similar to space) since we provide a workaround to accept space as a group separator for those locales. And since the workaround was there for a long time it doesn't make sense to change the behavior and the fix is to explicitely remove leading and trailing whitespaces before doing any conversion. Reviewed-by: mariusSO
Diffstat (limited to 'tests/auto/qlocale/tst_qlocale.cpp')
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 5e3e334..b8f7c22 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -591,6 +591,17 @@ void tst_QLocale::long_long_conversion_data()
QTest::newRow("de_DE 12345.67") << QString("de_DE") << "12345.67"<< false << (qlonglong) 0;
QTest::newRow("de_DE 123456.7") << QString("de_DE") << "123456.7"<< false << (qlonglong) 0;
QTest::newRow("de_DE 1.234.567") << QString("de_DE")<< "1.234.567"<< true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 ldspcs") << QString("de_DE")<< " 1.234.567" << true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 trspcs") << QString("de_DE")<< "1.234.567 "<< true << (qlonglong) 1234567;
+ QTest::newRow("de_DE 1.234.567 ldtrspcs") << QString("de_DE")<< " 1.234.567 "<< true << (qlonglong) 1234567;
+
+ // test that space is also accepted whenever QLocale::groupSeparator() == 0xa0 (which looks like space).
+ QTest::newRow("nb_NO 123 groupsep") << QString("nb_NO")<< QString("1")+QChar(0xa0)+QString("234") << true << (qlonglong) 1234;
+ QTest::newRow("nb_NO 123 groupsep_space") << QString("nb_NO")<< QString("1")+QChar(0x20)+QString("234") << true << (qlonglong) 1234;
+
+ QTest::newRow("nb_NO 123 ldspcs") << QString("nb_NO")<< " 123" << true << (qlonglong) 123;
+ QTest::newRow("nb_NO 123 trspcs") << QString("nb_NO")<< "123 "<< true << (qlonglong) 123;
+ QTest::newRow("nb_NO 123 ldtrspcs") << QString("nb_NO")<< " 123 "<< true << (qlonglong) 123;
QTest::newRow("C 1234") << QString("C") << " 1234" << true << (qlonglong) 1234;
QTest::newRow("C 1234 ") << QString("C") << "1234 " << true << (qlonglong) 1234;