summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@digia.com>2012-06-08 11:33:41 +0300
committerQt by Nokia <qt-info@nokia.com>2012-06-26 08:14:17 +0200
commit0a6dc44f248c05bf179069e8cb3c2aebbeee7ac6 (patch)
treeadd2ce4cf3994672a3f07cb35f3789a4e82adf97
parented96d199f197b2f82fa3ad19484a809ec1c0a4a4 (diff)
QTBUG-26035: Remove positive sign from start of string
Updated removeGroupSeparators(QLocalePrivate::CharBuff *num) so that it removes also positive sign ('+') at the start of the string. Auto test included. Task-number: QTBUG-26035 Change-Id: I8e0e071d6c682d9192a8c6bb2f282510e21b3c48 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
-rw-r--r--src/corelib/tools/qlocale_tools.cpp2
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp18
2 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index 2d6b8047a6..565144bc01 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -249,7 +249,7 @@ bool removeGroupSeparators(QLocalePrivate::CharBuff *num)
// Check that we are not missing a separator
if (i < decpt_idx
&& (decpt_idx - i) % 4 == 0
- && !(i == 0 && c == '-')) // check for negative sign at start of string
+ && !(i == 0 && (c == '-' || c == '+'))) // check for negative or positive sign at start of string
return false;
++i;
}
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index ddfa23eefb..d5bcf0748b 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -134,6 +134,7 @@ private slots:
void listPatterns();
void measurementSystems();
+ void QTBUG_26035_positivesign();
private:
QString m_decimal, m_thousand, m_sdate, m_ldate, m_time;
@@ -2051,5 +2052,22 @@ void tst_QLocale::measurementSystems()
QCOMPARE(locale.measurementSystem(), QLocale::MetricSystem);
}
+void tst_QLocale::QTBUG_26035_positivesign()
+{
+ QLocale locale(QLocale::C);
+ bool ok (false);
+ QCOMPARE(locale.toInt(QString("+100,000"), &ok), 100000);
+ QVERIFY(ok);
+ ok = false;
+ QCOMPARE(locale.toInt(QString("+100,000,000"), &ok), 100000000);
+ QVERIFY(ok);
+ ok = false;
+ QCOMPARE(locale.toLongLong(QString("+100,000"), &ok), (qlonglong)100000);
+ QVERIFY(ok);
+ ok = false;
+ QCOMPARE(locale.toLongLong(QString("+100,000,000"), &ok), (qlonglong)100000000);
+ QVERIFY(ok);
+}
+
QTEST_MAIN(tst_QLocale)
#include "tst_qlocale.moc"