summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/util/qdoublevalidator/tst_qdoublevalidator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Fix digit grouping: m_grouping_top doesn't mean what I thought it didEdward Welbourne2023-08-081-6/+22
| | | | | | | | | | | | | | | | | I'd previously understood CLDR's minimumGroupingDigits to mean the most significant group must have that many digits. It turns out to mean only that the first grouping separator doesn't get added unless the more significant group has this many. Once we have one separator, more can be added that do isolate a single digit. In the process, I discover some of the prior arithmetic is incorrect; it is now fixed. Added some basic testing, amended some existing tests. In the process, fixed naming of some double validator tests. Pick-to: 6.6 6.5 Fixes: QTBUG-115740 Change-Id: Ia6ce011ba72e72428b015ca22b97d815ebf751b2 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-30/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QDoubleValidator::setRangeOverloads(): rename a data rowEdward Welbourne2022-10-181-1/+1
| | | | | | | | | | | Two rows shared the same name. They claimed the value used was out of range, but actually that was only true for one of them. The other was in range, but the test reduced the number of digits allowed after the decimal point, thereby making it invalid, so rename that one to reflect this. Change-Id: I0936ea25ec799c0069cd148b9f9bae5d35906093 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Don't skip QDoubleConverter's digit-count check for non-whole boundEdward Welbourne2022-08-081-0/+1
| | | | | | | | | | | | | | | | Using convertDoubleTo() to get a whole number, from which to determine the number of digits we're allowed before the fractional part, fails if the double isn't a whole number, which lead to the skip being checked. Use qFloor() of the double (as this should have as many digits as the double had before its decimal point, which is what we care about; qCeil() might round up to a power of ten). This amends commit ff6d2cb0d5779d81e89d94d65c8d164602fa2567 Fixes: QTBUG-105341 Pick-to: 6.4 6.3 6.2 Change-Id: I4e0105d4602682c59e9830ec9a37556c96db884e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Introduce QDoubleValidator::setRange overload with two parametersIvan Solovev2021-09-201-12/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QDoubleValidator::setRange() used to have 3 parameters, with the third one (the number of decimals) having a default value of 0. Such default value does not make much sense for a *double* validator. Also, since a default value was used, omitting the decimals was silently overwriting the previous decimals value, discarding the value that could be previously explicitly specified by user. [ChangeLog][QtCore][QDoubleValidator][Important Behavior Changes] The QDoubleValidator::setRange() method now has two overloads. The first overload takes 3 parameters, but does not support a default value for decimals. The second overload takes only two parameters, not changing the number of decimals at all. Hence, the number of decimals will only be changed if the user explicitly specifies it. To maintain the old behavior of setRange(), pass 0 as the 3rd argument explicitly. Note that it is a source-incompatible change. But it should be fine, because using QDoubleValidator with 0 digits after decimal point does not make much sense and so, hopefully, is not that common. At the same time, change the default-constructed QDoubleValidator to use -1 for decimals, which allows arbitrarily many digits in the fractional part. The value was previously 1000, which allowed more than anyone would reasonably use, so this should make no practical difference. Some more unit tests to cover the behavior of the setRange() overloads are also added. As a dirve-by: remove unnecessary QValidator::State to int conversions in the unit tests. QCOMPARE is capable of comparing these enums and provides a better output in case of failure for enums. Task-number: QTBUG-90719 Change-Id: I523d6086231912e4c07555a89cacd45854136978 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Introduce QDoubleValidator::fixup()Ivan Solovev2021-09-171-0/+220
| | | | | | | | | | | | | The provided implementation tries to fix positions for the group separator. In case of scientific notation it can also converts the value to normalized form. It uses QLocale::FloatingPointShortest internally to convert the double value back to string, so the number of decimals may change after calling this method. Change-Id: I963bc5f97b653e2bb912f4b95b09a4d1ee201e7f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDoubleValidator: fix NaN check in validateWithLocaleIvan Solovev2021-09-011-0/+8
| | | | | | | | We can't really compare two NaN's. Should use qIsNaN() for that. Pick-to: 6.2 Change-Id: Ia514cabe65cfcdeafb39cab91ecdb66f8fae725c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-2/+2
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDoubleValidator: Fix thousand separator handlingFabian Kosmale2019-12-051-0/+1
| | | | | | | | | | | QDoubleValidator would accept "1,23" as valid in a locale which has ',' as a thousand separator. However, it should have been Intermediate instead, as there is still one digit missing. Fixes: QTBUG-75110 Change-Id: I6de90f0b6f1eae95dc8dfc8e5f9658e482e46db3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDoubleValidator: Allow intermediate values as close as possible to one ↵Andy Shaw2018-04-171-0/+8
| | | | | | | | | | | | | | | | | | considered invalid The documentation states that if you have a range of 0.00-2.00 with the number of decimals set to 2 then any number up to 9.99 would be considered intermediate. This is because the number of digits still matches both before and after the decimal point. If it is 10.0 or 9.999 then it is still considered invalid. In the case of 9.999 being invalid in this case, the documentation is corrected as this was incorrectly indicated as Intermediate, as the code indicates it as Invalid. Change-Id: I07b433e856f355916a1240deafdf4ef58e680639 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add flags to omit/reject padding in scientific notation exponentsUlf Hermann2015-11-231-0/+57
| | | | | | | | | | | | | | The EcmaScript format for printing doubles in exponent form differs from Qt's format only in this aspect. EcmaScript explicitly prohibits leading zeroes in exponents. It is thus worthwhile to add those flags in order to be able to generate and parse doubles in compliance with EcmaScript. [ChangeLog][QtCore][QLocale] Additional flags in QLocale::NumberOption allow generating and parsing doubles in EcmaScript compliant format. Change-Id: Ia7b82c2e67bb8b80bd890014ff5cd4563faf2a03 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* tests/auto/gui: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).Friedemann Kleint2015-07-311-16/+16
| | | | | | | | | | | | - Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer). - Replace Q[TRY]_VERIFY(smartPointer == 0) by Q[TRY]_VERIFY(smartPointer.isNull()). - Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and add casts where necessary. The values will then be logged should a test fail. Change-Id: I624deb320c378c18a29b3707f48583d53bfd5186 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Observe QLocale::RejectGroupSeparator in QInt/DoubleValidator.Friedemann Kleint2014-11-201-9/+18
| | | | | | | | Pass it as additional boolean parameter to QLocaleData::validateChars(). Task-number: QTBUG-42522 Change-Id: I4b2367f4e2fdcbd17e343d215edad57e6687697a Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move QValidator tests to QtGuiGiuseppe D'Angelo2012-10-101-0/+408
Q*Validator classes are not in QtWidgets, so move them where they should stay. Change-Id: Ie6ea45a026e640fad131002bc9762c575235f3f4 Reviewed-by: David Faure <david.faure@kdab.com>