summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QLocale: use new comparison helper macrosTatiana Borisova9 days1-4/+34
| | | | | | | | | | Replace public friend operators operator==(), operator!=() of QLocale to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Task-number: QTBUG-120304 Change-Id: I759ef08269abe3b40e0dce3fd408a86cc3f34857 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Improve fidelity of approximation to CLDR zone representationsEdward Welbourne2024-04-221-6/+6
| | | | | | | | | | | | | | | | | | | | I neglected to update the CLDR dateconverter code when I expanded the range of forms we support for display of a timezone. Even that expanded range doesn't cover all the cases CLDR does, but we can at least approximate each of CLDR's options by the closest we do support. Make matching changes to how the Darwin backend for the system locale maps its ICU-derived formats to ours. This in practice changes all locales previously using t (abbreviation) as zone format to use tttt (IANA ID) instead. Test data updated to match. [ChangeLog][QtCore][QLocale] Date-time formats now more faithfully follow the CLDR data in handling timezones. In most cases this means the IANA ID is used in place of the abbreviation. Change-Id: I0276843085839ba9a7855a78922cffe285174643 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of am/pm indicators in mapping from CLDR to Qt formatsEdward Welbourne2024-04-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Both qlocale_mac.mm and dateconverter.py were mapping the CLDR am/pm indicator, 'a', to the Qt format token 'AP', forcing the indicator to uppercase. The LDML spec [0] says: May be upper or lowercase depending on the locale and other options. [0] https://www.unicode.org/reports/tr35/tr35-68/tr35-dates.html#Date_Field_Symbol_Table We don't support the "other options" mentioned, but we can at least (since 6.3) preserve the the locale-appropriate case, instead of forcing upper-case. As such, this change is a follow-up to commit 4641ff0f6a1b0da6f55db5e33c58a77be2032808 Changes locale data, as expected, to use "Ap" in place of "AP" in various formats in the time_format_data[] array. [ChangeLog][QtCore][QLocale] Where CLDR specifies an am/pm indicator, the case of the CLDR-supplied indicator is used, where previously QLocale forced it to upper-case. Change-Id: Iee7d55e6f3c78372659668b9798c8e24a1fa8982 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cope with CLDR's "day period" format specifiersEdward Welbourne2024-04-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The LDML spec includes a 'b' pattern character which is like the 'a' pattern, for AM and PM, but would rather use noon and midnight indicators for those specific times. We don't support those and using am/pm will be right enough of the time to be better than simply discarding this option, if it ever gets used (which it currently isn't), so treat as an alias for 'a'. No locale in CLDR currently uses this. CLDR also has a 'B' specifiers for "flexible day periods", including things like "at night" and "in the day". At present only zh_Hant uses 'B'. As a result, this change only affects zh_Hant's formats for time and datetime, which only zh_Hant_TW uses - zh_Hant_HK overrides them to use am/pm markers and zh_Hant_MO inherits that from zh_Hant_HK. Based on this and user feed-back, I've opted to treat 'B' as another synonym of 'a'. This removes an entry from the time_format_data[] table (it happened to occupy one whole twelve-character row), causing many other locales' offsets into that table to be shifted by 12. Only zh_Hant_TW has an actual change to which entry in the table it uses. Added a test-case. [ChangeLog][QtCore][QLocale] CLDR's 'B' (flexible day period, e.g. "at night" &c.) field, not currently supported, is now handled as a synonym for the AM/PM field 'a', instead of leaving the B as literal text. Only affects zh_TW at present. Fixes: QTBUG-123872 Change-Id: I6ba008c0a048190bf7af8c7df7629a885b05804f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass QVariant to QSystemLocale::query() as rvalue referenceEdward Welbourne2024-04-091-1/+1
| | | | | | | | | | QVariant is rather big for passing by value; and no caller has any further use for the QVariant it's passing in. Pick-to: 6.7 6.5 Task-number: QTBUG-122619 Change-Id: I2751745e715aacfa8982ac97b4ae777fde5e88de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSystemLocale(): disable copy and moveEdward Welbourne2024-04-091-0/+1
| | | | | | | | | | | | | Axivion (SV546) points out (based on a clazy "rule of three" that might be rule of five by now) the lack of move and copy assignment and construction. We don't want those anyway, so tell the compiler not to create them. Pick-to: 6.7 6.5 Task-number: QTBUG-122619 Change-Id: Ie951a2c3d60d76ad3448310d3f9bbda22190015b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "wasm: Disable problematic qlocal test for time being"Piotr Wierciński2024-03-141-4/+2
| | | | | | | | | | | | This reverts commit c23d3ca1f08a7c7c76bb71602a56a79898efa117. Reason for revert: Update to Emscripten 3.1.50 has been merged. Change-Id: Ie2082dcc2ee34a6d4e519c143037fda9678be234 Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
* 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>
* Modernize comparisons in tst_QLocaleEdward Welbourne2024-02-021-34/+23
| | | | | | | | | | | | | | | | | | | QCOMPARE() can report enum values by name just fine, no need to laboriously convert them to strings. While comparing all tags in one go did allow a more comprehensive report, it's enough to know we failed; this is testing cross-platform code, so a debugger can tell us all those extra details if we get a failure. Testing qHash() doesn't distinguish equal things is fairly low value; at least avoid duplicating the construction of the reference value. Replace a bunch of other QVERIFY()s with the new cousins of QCOMPARE() for ordered and different comparisons. In the process, mark some of the QLocale objects as const. Change-Id: Ic93b8ed60c6f2cc846fbba428983778896d61291 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Make TEST_CTOR macros use the "do { ... } while (false)" patternEdward Welbourne2024-02-021-121/+121
| | | | | | | | | They were expanding as simple blocks, so their uses didn't end in semicolon, which looks wrong when reading the code. Pick-to: 6.7 6.6 6.5 Change-Id: Ibea7b01ac165045604b6eb7a838765b2061c368a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Update QLocale and calendar data to CLDR v44.1Edward Welbourne2024-02-021-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (This turns out to be identical to v44, for our purposes.) The CLDR license has been revised at v44 to "UNICODE LICENSE V3", which is now included (as LICENSES/UNICODE-3.0.txt) in addition to the old license (still in use, presumably, by UCD - at least until its next update). Some new QLocale::Language entries are needed. There is no change to the time-zone data. Some tests needed changes: * Various Arabic locales now use U+0623 (Arabic letter aleph with hamza above) in exponent separator, replacing plain U+0627 (Arabic letter aleph); it is still followed by U+0633 (Arabic letter seen). * Where likely sub-tags used to fill in world, 001, as territory for a language, they now (e.g. for Prussian and Yiddish) give specific countries. * Tamil locales now have something of a mix of inherited and localized forms for AM/PM, which looks a lot like a mistake in CLDR. * New likely sub-tag rules fix ctor(und_US) and ctor(und_GB), which previously failed. [ChangeLog][Third-Party Code] Updated QLocale's data extracted from the Unicode Common Locale Data Repository (CLDR) to v44.1. The license changed to Unicode License V3. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-121485 Task-number: QTBUG-121325 Change-Id: Ide1a68016129526d7a5aa3fc67f1a674858696bc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add expect-fail test-cases for und_US, und_GB to tst_QLocale::ctor()Edward Welbourne2024-01-301-0/+4
| | | | | | | | These exhibit the problem described by a recent bug report. Task-number: QTBUG-121485 Change-Id: Ia09acfa22e687ba096091a73f30df1ffd22a6e32 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Rework tst_QLocale::ctor() - split up and make data-drivenEdward Welbourne2024-01-301-67/+111
| | | | | | | | | | | | | | | | | | | | | There were three things going on in this test (itself a sufficient reason to split it up): * Some reporting and checking of the default locale; the reporting is duplicated in defaulted_ctor() and the check fitted more naturally there. * Checks that various combinations of language, script and territory got resolved according to likely-subtag rules. These were handled via a macro and natural candidates to become data-driven. * A test that territory is preserved when it's the only given tag (with a few known exceptions); broken out as a steparate test. In the process, give the data-rows of the likely-subtag parts names that let me extend their testing to also test construction from string. The territory-only cases can't support that, as QLocale doesn't support und_* forms of tags for unspecified language. Change-Id: Id9f0fc46f30eb887b47931bad1619255acb44266 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTEST()-ify QLocale testsEdward Welbourne2024-01-301-33/+16
| | | | | | | | | Replace various QFETCH()/QCOMPARE() pairs with QTEST(). Just because it's terser. Change-Id: I8496a293e3634991dcb33b8c7939f1c3028a63c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_QLocale: add some basic endonym testsEdward Welbourne2024-01-291-0/+35
| | | | | | | | | | | | | Actually triggered by investigating QTBUG-121485, where the issue turns out to be at construction time, but the complete lack of any testing of endonyms clearly needed addressed in any case. In the process, break up the long list of private slots in the test-class declaration. Task-number: QTBUG-121485 Change-Id: I49021f78d3bea2e1e55b2755a45943ab3fc23722 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QLocale::dayName(): Convert some dangling code into test rowsEdward Welbourne2024-01-291-9/+12
| | | | | | | | | | Every test row was following its locale-specific test with tests for Irish and Greek day names, repeated regardless of the locale-specific data. Express these tests as rows in their own right and shorten the per-row testing, so we only do each once. Change-Id: I8f919b50ac54423bacab6e5a9d34254b7db59a55 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Package up a repeated piece of testing in a macroEdward Welbourne2024-01-291-24/+12
| | | | | | | In the process, change it to use QCOMPARE(A, B) rather than QVERIFY(A == B). Change-Id: I26c64100b08aef43c56f5266c0de71f5cde12816 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use localized time-zone abbreviations or offsetEdward Welbourne2023-10-271-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The actual formatting of date-time strings is handled by the calendar backend, but the code's in qlocale.cpp as it uses some of its tools. When feature timezone is unavailable, we're stuck (as before) with using QDateTime::timeZoneAbbreviation(), but when it's available we can use QTimeZone::displayName() to get the localized form of the abbreviation and offset string. Make matching changes in QDTP so that it recognizes these localized abbreviations. We now have another candidate for what local time might be called, to add to those that must be checked. This naturally implied some changes to tests. It turns out ICU believes en_US uses GMT+1/GMT+2 for CET/CEST. Replace some MS QEXPECT_FAIL()s by including the non-abbreviations we do in fact use on MS in the lists of "abbreviations" to accept. [ChangeLog][QtCore][QLocale] When a datetime format includes the timezone (or offset), the appropriately localised form is (to the extent the timezone backend in use supports this) used where, previously, a haphazard choice of system and C locale was used. This applies to both serialization and parsing. Task-number: QTBUG-115158 Change-Id: I04f9c1055c3b9008320bb8b758490287fd8be5cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Work round ICU disagreeing with TZDB about zone transitionsEdward Welbourne2023-10-261-1/+5
| | | | | | | | | | | | | | | | | | | | Since the TZ backend resorts to ICU for display names, we got inconsistent results if they disagree about when transitions happened. Also, ICU uses the current (or only recent history) names for the zone, so one currently not doing DST (Africa/Tripoli) doesn't get a report of its DST name at a historical time when it did DST (but ICU doesn't know about it). Since the ICU backend, in any case, doesn't override the displayName(qint64, ...), we can simply use the QTZP base version instead of overloading in the TZ back-end, so we only delegate to ICU when it might actually help. This also saves duplicating some locking and lazy-initialization code. In the process, turn a unique lock into a scoped lock within a suitable scope. Also, make a comment more grammatical and less verbose. Change-Id: Iaaed1fb6a380be8b4258c43cbc4bacd5784345fb Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* tst_QLocale: base europeanTimeZone test on 2013, actually used in testEdward Welbourne2023-10-251-6/+5
| | | | | | | | | | The test that needs this bool is using 2013, so test that year for a match. (Africa/Tunis toyed with DST in 1990, the year used before, but thought better of it.) In the process, move the initialization to the member-initialization of the class and make the member const. Change-Id: Ib87636cdb0b038fad0cdef9fbe49e96f7bf79d1f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Give QLocale's name() and bcp47Name() separator parametersEdward Welbourne2023-08-181-6/+28
| | | | | | | | | | | | | Previously name() has always used underscore and bcp47Name() dash; let the user chose which one best fits their needs. [ChangeLog][QtCore][QLocale] QLocale's name() and bcp47Name() now let the caller chose what separator to use between the tags making up the name, where there is more than one. Change-Id: Ia689e6a3fb581b42905e7fb1ae7a7b688244d267 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Give QLocale::uiLanguages() a separator parameterEdward Welbourne2023-08-161-5/+45
| | | | | | | | | | | | | | | | | | | It has always returned dash-joined forms of the locale names, and callers who need an underscore-joined form have been obliged to replace('-', '_') before using them. Given that everything it adds to the list comes from QLocaleId methods that accept a separator, it's trivial to let it offer the same choice to its callers and save them this hassle. Amended code in QTranslater and QMimeType to save them that hassle. [ChangeLog][CoreLib][QLocale] QLocale::uiLanguages() now lets the caller choose what separator to use between the tags that make up each locale-identifier in the list returned. Change-Id: I91fcd0b988d9a64e0e9ad9e851f6cb8c1be8ae50 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QLocale: clean out the last use of foreachEdward Welbourne2023-08-111-1/+2
| | | | | Change-Id: I0a4810dbae2137764ea1d14d515e9f06f7f2129d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use CLDR's names in QLocale::*ToName() for language, script, territoryEdward Welbourne2023-08-091-0/+49
| | | | | | | | | | | | | | | Various comments need to continue using the enumdata.py names, as they associate data with particular enum members, but we can now correctly use the en.xml versions of their names when we report them, rather than the enum-friendly names we use in the code. Since this now means the data may stray outside plain ASCII - it'll be UTF-8-encoded - this implies replacing the QLatin1StringView()s of the code that formerly read this data with QString::fromUtf8(). Fixes: QTBUG-94460 Change-Id: Id3b08875a46af58c0555c3e303b0e15a19441509 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revise enumdata.py's names to more closely match CLDR'sEdward Welbourne2023-08-091-0/+67
| | | | | | | | | | | | We could already use dashes in some, rather than spaces, and now no longer need to capitalize each word. This changes the *_name_list[] entries for affected languages to more closely match what CLDR gives as their names. It also amends various comments. Added tests for the QLocale::*ToString() functions to cover the entries changed. Task-number: QTBUG-94460 Change-Id: I0163795cb282881f15a97be00a5311c1936c3a09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QLocale: Use UTF-8 rather than Latin-1 for C-string-ificationEdward Welbourne2023-08-091-11/+11
| | | | | | | | | | | | | | | | | | | | Test names and output need to be UTF-8 for the XML data formats to not end up malformed - which would upset Coin's testrunner, when it validates the XML as part of checking - and the few other uses of toLatin1() were to ASCII content anyway, so can harmlessly (this being test code, where the slight performance advantage of Latin-1 doesn't matter) use toUtf8() as well, for the sake of uniformity. Use of toLatin1() broke an imminent commit in which some territory, script and language names depart from ASCII, leading to malformed UTF-8 when they appear in test-data-row names. Task-number: QTBUG-94460 Change-Id: Ifb826b1e417ba24fd862b93d24d0e7a38858a17f Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix digit grouping: m_grouping_top doesn't mean what I thought it didEdward Welbourne2023-08-081-1/+89
| | | | | | | | | | | | | | | | | 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>
* Update QLocale to CLDR v43Edward Welbourne2023-08-021-1/+3
| | | | | | | | | | | | Ran the scripts, added the new enum members to docs. Updated tests: * Two of the new languages are right-to-left, * Canada has replaced a silly date format with a sensible one. Fixes: QTBUG-111550 Change-Id: Ie6f1e6e94477167c9e2b5c67e6518ca0f6a7e7fb Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Use correct index for QLocale::system()'s staticEdward Welbourne2023-07-311-30/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nothing prevents client code from calling QLocale::setDefault() before we ever instantiate QLocale::system() - aside from some quirks that mean setDefault(), currently, does instantiate QLocale::system() to force initialization of defaultLocalePrivate - so using defaultIndex() could set the system QLocalePrivate instance's index incorrectly. In any case, even if the index is initially set correctly, a subsequent change to the system locale would change the correct index; and nothing outside QLocale::system() has access to the instance that would then be remembering an out-of-date index. Actually tripping over that inconsistency took some deviousness, but was possible. The index is (currently) only used for month name lookups and those special-case, for the Roman-derived calendars, the system locale, to only use the index if the system locale offers no name for a month. Meanwhile, updateSystemPrivate() uses the fallback locale's index for its look-up of which CLDR data to copy into the fallback QLocaleData for the system locale. None the less, a non-Roman calendar's lookup will go via the index to get at the CLDR data for that calendar, thereby exposing the system locale's index to use; and, sure enough, a setDefault() could lead that to produce wrong answers. In QLocale::system() there's a cached QLocalePrivate, whose index we need to ensure stays in sync with the active system locale. So pass its &m_index to systemData(), which will now (when passed this) ensure it's up to date. Since we always have called systemData(), to ensure it is up to date, we can skip that update in the initialization of the cached private and use m_index = -1 to let systemData() know when it's in the initial call, thereby making the static cache constinit. Amended a test to what proved the issue was present. Change-Id: I8d7ab5830cf0bbb9265c2af2a1edc9396ddef79f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QLocale: add testing of the extremes for doubleToStringThiago Macieira2023-07-241-0/+46
| | | | | Change-Id: I5f7f427ded124479baa6fffd1760b1ec36e7e827 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QLocale: rename "emptyCtor" test to better describe itEdward Welbourne2023-07-211-4/+4
| | | | | | | | | | It's actually testing that the system locale (which it obtains via the default constructor, relying on setDefault() not being called first in the helper program - which I'll soon change) behaves as expected. Change-Id: Iedd2c1bb549288661c910dfbaac509ede9506d04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Rename test using MySystemLocale and fix its #if-eryEdward Welbourne2023-07-211-12/+11
| | | | | | | | | | | | | Although QSystemLocale is (to make its query enum usable) defined despite the QT_NO_SYSTEMLOCALE define, it's not used in that case, so tests based on it won't work. So extend the reach of the #if-ery to include the test using a custom class based on it. Also rename the test from systemLocale(), as that's the name the emptyCtor() test really should have. Change-Id: Ief69bf161251cde47ee45014cc2627d42cfcc526 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
* Treat simple spaces as equivalent in date-time format separatorsEdward Welbourne2023-07-171-0/+4
| | | | | | | | | | | | | | | | The user might not be aware of, or able to see, the difference between Unicode's assorted horizontal spacing characters, leading them to expect their input to be accepted for a format despite differences in spacing. So treat the various horizontal spacing (other than tab) characters as equivalent when matching the separators in a date-time format. Add a test-case that failed before this fix. Fixes: QTBUG-114909 Pick-to: 6.6 6.5 Change-Id: I3e798d3e5b89adb8e86168ebd3954904b258d630 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* CI: Enable tests under corelib/text for Wasm platformPiotr Wierciński2023-07-101-6/+10
| | | | | | | | | | We are gradually enabling more tests for WebAssembly platform for better test coverage. Long linking time is no longer an issue due to test batching. Change-Id: I7ee9f877ecda726bc23d8dd2507c616bb381ebc1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Add tests of QLocale's toDate() and toTime()Edward Welbourne2023-07-101-0/+291
| | | | | | | | | | | Previously only toDateTime() was tested. Adding a test-case for toTime() provoked adding full testing for both it and toDate(), based on toDateTime() tests. Pick-to: 6.6 6.5 Task-number: QTBUG-114909 Change-Id: I5c24b3869b3deefc36a7125133822e8f41cd24ba Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Fix case-sensitivity of exponent separator check in Cyrillic fall-backEdward Welbourne2023-05-151-0/+4
| | | | | | | | | | | | | | | | | When matching the locale's correct exponent separator, QLocale was doing a case-insensitive match; but the Cyrillic fall-back was matching case-sensitively, so failed to catch the case of lower-case e and its Cyrillic equivalent, when used in a Cyrillic font in place of the upper-case form of the other, where that's the locale's official separator. So make this comparison case-insensitive. Added some test-cases for the lower-case exponential separator. Pick-to: 6.5 Fixes: QTBUG-113443 Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Test QLocale's parsing of small fractions with big exponentsEdward Welbourne2023-05-101-0/+14
| | | | | | | | | | | | | | Add some tests inspired by the initial form of a bug report (before we found out what the real issue was), that a small fraction with a large exponent is correctly handled. This should work as long as the result is representable, even if the fraction itself is too small to be represented by the floating-point type. Pick-to: 6.5 Task-number: QTBUG-113443 Change-Id: Ie004197961fc7b603e5024a6ebc5928261a0e2bb Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definitionEdward Welbourne2023-03-201-4/+4
| | | | | | | | | | I got tired of being told off by the inanity 'bot for faithfully reflecting existing #if-ery in new #if-ery. Retain only the documentation and definition of the deprecated define. Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Support Cyrillic's equivalent of 'E' as exponent separatorEdward Welbourne2023-02-241-0/+8
| | | | | | | | | | | | Only Ukrainian is actually recorded in CLDR as using U+0415 as exponent separator; all other Cyrillic-using locales officially use plain ASCII 'E'. However, it seems reasonable, in all Cyrillic locales, to recognize both (given that they look very similar). Task-number: QTBUG-107801 Change-Id: I70a1e60a2d9fe7e254e01d32c5bad909ea4b8c76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Fix parsing of numbers to cope with non-single-character tokensEdward Welbourne2023-02-241-10/+60
| | | | | | | | | | | | | | | | | | | | In some locales signs and the exponent are not single character tokens. Replace QLocaleData::numericToCLocale() with a tokenizer that will cope with this. At the same time, cache the locale data needed in support of that, so that we don't repeatedly recreate QString() objects just to compare them against input tokens. The caching class is inspired by Thiago's proposal for fixing the performance, which also inspires the optimization of the C locale in the tokenizer used here. Add some testing that round-tripping numbers via strings works for the locales with signs and exponents that use more than one character. Task-number: QTBUG-107801 Change-Id: I9fd8409a371ed62ed969d9ebc8b09584e752f7fb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update CLDR to v42Mate Barany2023-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | New languages (and one local for each) added with v42 - Haryanvi - Moksha - Northern Frisian - Obolo - Pijin - Rajasthani - Toki Pona It also appears that Canada has changed its date format. Modify the relevant test case to reflect this change. Task-number: QTBUG-110333 Pick-to: 6.5 Change-Id: Ia8975c2866cd54c9e565543d05bacd52f4987909 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Pass short time format to GetTimeFormat from GetLocaleInfoIlya Fedin2023-01-301-1/+1
| | | | | | | | | | TIME_NOSECONDS doesn't really switches to short time format, just removes the seconds from long time format Fixes: QTBUG-110627 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: add unittests for qstrtod of "NaN" and "nan"Ahmad Samir2023-01-171-0/+4
| | | | | | | | | | | | The tests pass. Drive-by change: Amend qstrntod API docs, the addition is heavily inspired by cppreference's strtod docs. Change-Id: Ic8e138e117a3249c752ae5ef2a8a21feb010befa Task-number: QTBUG-74325 Pick-to: 6.5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Verify land-preservation in locale constructionEdward Welbourne2023-01-121-2/+37
| | | | | | | | | | | For most territories, if we specify only that territory, we should get a locale specific to that territory. There are exceptions for various reasons, but check that it's true in most cases, at least. In the process, convert two QVERIFY(... == ...) into QCOMPARE(..., ...) Task-number: QTBUG-64940 Change-Id: I7590f20f37b0b459aafb3d1d08f6eb77932fa027 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Accept U+2212 as minus sign in negative year unit testØystein Heskestad2023-01-061-1/+5
| | | | | | | | | | | Not all locales use ASCII hyphen-minus U+002D as minus sign. On macOS using the nb_NO locale the U+2212 character is used instead when displaying negative years. Verify that one of the two characters is found. Fixes: QTBUG-109853 Change-Id: I424539cc8d427ac199b4528e44bef98e45312d07 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Adapt corelib to use QTimeZone in place of Qt::TimeSpecEdward Welbourne2022-12-091-8/+6
| | | | | | | | | This saves (mostly in corelib/time/) some complications that used to arise from needing different code-paths for different time-specs. Task-number: QTBUG-108199 Change-Id: I5dbd09859fce7599f1ba761f8a0bfc4633d0bef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: Have qstrntod() return end of parsed string also on underflowUlf Hermann2022-11-251-0/+8
| | | | | | | | | Underflows should be treated the same as overflows. Fixes: QTBUG-108628 Change-Id: I23aa7bbe1d103778cefca08bd3e584e72f306583 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Restore end-of-parse reporting to qstrntod()Edward Welbourne2022-11-241-3/+11
| | | | | | | | | | | | | | | | | | Rework QSimpleParsedNumber to store a qsizetype whose sign serves as ok flag (positive is ok, zero and negative are not) and magnitude is the number of characters used. This replaces an endptr that was set to null to indicate !ok, but that deprived us of end-of-parse information, which is needed for number-parsing. In particular, JS's parsing of numbers accepts overflow (where qstrntod() flags it as invalid) as infinity; so qstrntod() does need to say how long the overflowing (but JS-valid, none the less) number-text was. Modify all callers of functions using this (recently-introduced) type and add tests that fail without this fix. Fixes: QTBUG-108628 Change-Id: I416cd213e1fb8101b1af5a6d43615b970a5db9b4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add more tests of QLocale and "single character" data that aren'tEdward Welbourne2022-11-111-7/+41
| | | | | | | | | | | | | | | | This tests that strings using the first Unicode code-point of such a multi-character token don't get recognized as "valid" number strings. This would catch an implementation issue if the parsing code mistakenly matched against only the first code-point of each "single character" token. It also adds tests of integer formatting, with multi-character sign, and reworks some QStringView().toString()s to use u"..."_s. Task-number: QTBUG-107801 Change-Id: I7b868ce2955bb322b3ecfc200438a21437090a0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add tests of QLocale verifying some "single-characters" aren'tEdward Welbourne2022-10-281-1/+36
| | | | | | | | | | | | | | | Some of the entries in QLocale's single_character_data[] table are not, in fact, single characters; some RTL languages include bidi-markers in some of the fields, some locales use some denotation of "times ten to the power" as the exponent separator. There may be further complications, but let's just get some tests in that verify we are correctly serializing numbers in these locales. Include some parsing tests to show that we are indeed failing them. Task-number: QTBUG-107801 Change-Id: Iab9bfcea5fdcfcb991451920c9531e0e67d02913 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>