diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-12-09 09:59:10 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-12-09 10:04:05 (GMT) |
commit | b81b8e43ad57183ed66086ec90cabef5906ab9a2 (patch) | |
tree | 65615a52ebcf53b683f66be44c0a04bf44d04180 /tests/auto/qintvalidator | |
parent | 258bc1c288ec9be90a2a101b81f0a3c58d193bca (diff) | |
download | Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.zip Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.gz Qt-b81b8e43ad57183ed66086ec90cabef5906ab9a2.tar.bz2 |
Fix the int validator not handling the locale
Task-number: QTBUG-3179
Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto/qintvalidator')
-rw-r--r-- | tests/auto/qintvalidator/tst_qintvalidator.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qintvalidator/tst_qintvalidator.cpp b/tests/auto/qintvalidator/tst_qintvalidator.cpp index 3e0bd14..292a0cb 100644 --- a/tests/auto/qintvalidator/tst_qintvalidator.cpp +++ b/tests/auto/qintvalidator/tst_qintvalidator.cpp @@ -50,6 +50,7 @@ private slots: void validate_data(); void validate(); void validateArabic(); + void validateFrench(); }; Q_DECLARE_METATYPE(QValidator::State); @@ -182,6 +183,30 @@ void tst_QIntValidator::validateArabic() } + +void tst_QIntValidator::validateFrench() +{ + QIntValidator validator(-2000, 2000, 0); + validator.setLocale(QLocale::French); + int i; + + QString s = QLatin1String("1 "); + QCOMPARE(validator.validate(s, i), QValidator::Acceptable); + validator.fixup(s); + QCOMPARE(s, s); + + s = QLatin1String("1 000"); + QCOMPARE(validator.validate(s, i), QValidator::Acceptable); + validator.fixup(s); + QCOMPARE(s, s); + + + s = QLatin1String("1 0 00"); + QCOMPARE(validator.validate(s, i), QValidator::Intermediate); + validator.fixup(s); + QCOMPARE(s, validator.locale().toString(1000)); +} + void tst_QIntValidator::validate() { QFETCH(int, minimum); @@ -190,6 +215,7 @@ void tst_QIntValidator::validate() QFETCH(QValidator::State, state); QIntValidator iv(minimum, maximum, 0); + iv.setLocale(QLocale::C); int dummy; QCOMPARE((int)iv.validate(value, dummy), (int)state); } |