summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Get rid of some QTextCodec leftoversLars Knoll2020-05-145-6/+0
| | | | | | | There's no real dependency to QTextCodec in those files anymore. Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QTextCodec dependency from testLars Knoll2020-05-141-5/+1
| | | | | Change-Id: Ie546065c3179d475df46b284ca7df502c4465b93 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Document the string converter classesLars Knoll2020-05-142-11/+11
| | | | | | | | | | Document QStringConverter, QStringDecoder and QStringEncoder. In addition, do some touches to the API, renaming one enum value, add a flags argument to one constructor and make some members private. Change-Id: I8f99dc3d98fb8860cf6fa46301e34b7eb400511b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QTextCodec in QTextStreamLars Knoll2020-05-142-65/+5
| | | | | | | | Use QStringConverter instead. Also change the default encoding of QTextStream to utf8. Change-Id: I30682e75fe0462d1a937539f773640c83a2d82e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Start porting QTextStream away from QTextCodecLars Knoll2020-05-143-846/+38
| | | | | | | | | | | | As a first step add setEncoding/encoding() methods that use the QStringConverter::Encoding enum, and port all uses of setCodec()/ codec() over to the new API. Internally QTextStream still uses QTextCodec, this will be ported over to QStringConverter in a follow-up change. Change-Id: Icd764cf47b449b57f4ebd010c2dad89e6717d6c0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a method to determine the encoding for encoded HTML dataLars Knoll2020-05-141-0/+89
| | | | | | | This is a replacement for Qt::codecForHtml(). Change-Id: I31f03518fd9c70507cbd210a8bcf405b6a0106b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringConverter::encodingForData()Lars Knoll2020-05-141-0/+58
| | | | | | | | Add method that tries to determine the encoding of the data from an initial byte order mark. Change-Id: I348c51a3d4db9b434af53359b739a7e17acfc760 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add methods to convert between encoding and name to QStringConverterLars Knoll2020-05-141-0/+53
| | | | | | | | Add static methods that allow converting between a name for an encoding and the Encoding enum. Change-Id: I12bc503cf757ea31d3ca8d5e1f1216efddcb16d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Construct a string converter by nameLars Knoll2020-05-141-0/+27
| | | | | | | | | | | Add a constructor, that allows constructing a string converter by name. This is required in some cases and also makes it possible to (in the future) extend the API to 3rd party encodings. Also add a name() accessor. Change-Id: I606d6ce9405ee967f76197b803615e27c5b001cf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QSettings::iniCodec()Lars Knoll2020-05-141-108/+5
| | | | | | | | | | | | | | | | | | Always encodee INI files as utf-8 in Qt6. This is mostly backwards compatible, as old ini files would encode all non ascii characters. [ChangeLog][Important behavioral changes] QSettings will now always encode INI files as utf-8 (and the iniCodec/setIniCode methods are removed). This is a change from Qt 5 and earlier, where QSettings would by default escape all non ascii characters. The behavior is equivalent to what you got in Qt5 by setting a utf-8 iniCodec on the settings object. Settings files written in Qt 5 will still be readable in Qt 6 (unless an iniCodec different from utf-8 was used), but to read Qt6 based ini files in Qt 5 applications, setting the iniCodec to utf-8 is required. Change-Id: Ic7dffcca17779bd5e3dae50d42ce633170289f6c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Add some incremental testsLars Knoll2020-05-141-20/+63
| | | | | | | | | Feed the data one by one to the encoder or decoder to verify that the handling of incremental decoding is correct. Change-Id: I565e4f1872e00859026334f7662b6778772e159d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up the Flag handling in QStringConverterLars Knoll2020-05-142-52/+52
| | | | | | | | | | | | | | | IgnoreHeader was a rather badly defined enum, in addition the utf8 and utf16 codecs where handling BOMs somewhat different for stateless decoding. Fix this by introducing explicit flags for writing a bom when encoding and not skipping the initial bom when decoding. Source compatibility for QTextCodec is done with a couple of static constexpr variables. Change-Id: I0b2d94f84c937cec1e0494c16ef448c00382691d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Always write XML documents as UTF-8Lars Knoll2020-05-141-91/+0
| | | | | | | | | | | Remove support for setting a codec different from UTF-8 for writing XML files. All XML readers today can handle UTF-8, and there is no reason anymore to write a file in a different encoding. Change-Id: If89fb2d2474a2b55644d9bed7473c11ad91033eb Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* Start work on a new API to replace QTextCodecLars Knoll2020-05-147-1/+1609
| | | | | | | | | | | | | | | The new QStringEncoder and QStringDecoder classes (with a common QStringConverter base class) are there to replace QTextCodec in Qt 6. It currently uses a trivial wrapper around the utf encoding functionality. Added some autotests, mostly copied from the text codec tests. Change-Id: Ib6eeee55fba918b9424be244cbda9dfd5096f7eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port qt_punycodeEncoder() to QStringViewMarc Mutz2020-05-131-1/+1
| | | | | Change-Id: I264e67bc08413f8a39e2d16c774bfd2c76c320ac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString: remove op+=(char) and op+=(QChar::SpecialCharacter)Marc Mutz2020-05-131-2/+12
| | | | | | | | | | | | | | | | | | | The former messes in bad ways with the overload set (it, fatally, attracts char16_t, e.g.). The latter was probably added in response to ambiguities between (char) and (QChar). While it's harmless now, remove it, since it no longer pulls its weight. The no-ascii warning is now coming from QChar(char), so the protection isn't lost. [ChangeLog][QtCore][QString] The += operators taking char and QChar::SpecialCharacter have been removed as they cause adding a char16_t to QString to call the char overload, losing information. The append() function was not affected. Change-Id: I57116314bcc71c0d9476159513c0c10048239db3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port qt_check_std3rules() to QStringViewMarc Mutz2020-05-131-1/+1
| | | | | | | Also port its callees. These functions scream to the QStringView-ified... Change-Id: I13c95d65941eb8d02223306d80efd1437b4bd9b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port qt_urlRecode() to QStringViewMarc Mutz2020-05-121-6/+6
| | | | | | | It's about time :) Change-Id: I27e597516318382850d4c193fd5b66a35fb9c316 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Teach QDateTimeParser some common time-zone offset formatsAndrei Golubev2020-05-121-2/+129
| | | | | | | | Fixes: QTBUG-83687 Fixes: QTBUG-83844 Pick-to: 5.15 Change-Id: Ia1c827017b93cf8277aa5a0266805d773d2d9818 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Sweep of int-ish → char-ish types near calls to QString::fromU*()Marc Mutz2020-05-127-130/+130
| | | | | | | | | | | | The fromUtf16(ushort*) and fromUcs4(uint*) overloads are going to be deprecated. Use the newer fromUtf16(char16_t*) and fromUcs4(char32_t*) overloads. As a drive-by, use std::end()/std::size() where applicable. Change-Id: I5a93e38cae4a2e33d49c90d06c5f14f7cb7ce90c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QChar::fromUcs4() moreMarc Mutz2020-05-122-4/+4
| | | | | | Change-Id: I02be41de92d84145186de9ac5f5ea3541a941964 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make qtbase compile without QT_CONFIG(timezone)Andrei Golubev2020-05-113-9/+56
| | | | | | | | Fixes: QTBUG-83795 Pick-to: 5.15 Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QChar: add fromUcs{2,4}()Marc Mutz2020-05-091-7/+31
| | | | | | | | | | | | | | | | | | | | The fromUcs2() named ctor is designed to replace all the non-char integral-type constructors of QChar which make it very hard to control the implicit QChar conversions, which have caused a few bugs in Qt itself. As a classical named contructor, it simply returns QChar. The fromUcs4() named "ctor", however, needs to expand surrogate pairs, and thus can't just return QChar. Instead, it returns a small struct that contains one or two char16_t's, can be iterated over and be implicitly converted to QStringView. To avoid bikeshedding the name (FromUcs4Result, of course :), it's defined inline and thus can't be named outside the function. This function replaces most uses of QChar::requiresSurrogates() in QtBase. [ChangeLog][QtCore][QChar] Added fromUcs2(), fromUcs4(). Change-Id: I803708c14001040f75cb599e33c24a3fb8d2579c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_stringview: remove dead codeMarc Mutz2020-05-081-54/+0
| | | | | | | | | | wchar_t hasn't been QStringView's storage_type for a very long time (at least since 5.10). And in Qt 6, we require char16_t support not only in the compiler, but also in the stdlib, so drop the guards and the alternative code paths. Change-Id: I99f28b575f61c16a2497840708beaa4b54a80f57 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_qstringview: modernize functions in help namespaceMarc Mutz2020-05-081-4/+4
| | | | | | | | | | | | | They don't work with std::span, since std::span has neither const_iterator nor cbegin()/cend(). To fix, perfectly forward the return type with decltype(auto) instead of mentioning T::const_iterator, and rely on the const-qualfication of the help::c{r,}{begin,end}() functions' arguments to select the correct T::{r,}{begin,end}() overload. Change-Id: I4992d4bd521d2dc0f9ea51ae70cde8286ae543a5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_qstringapisymmetry: test split() with char16_t sepsMarc Mutz2020-05-081-1/+5
| | | | | Change-Id: I6744291b88d5334764da78375899313ac771294b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Catch overflow in QDateTime::fromSecsSinceEpoch()Edward Welbourne2020-05-081-0/+31
| | | | | | | | | | It's documented to be undefined if the number of seconds is outside the allowed range, but it doesn't hurt for that undefined behavior to happen to be that the result is invalid. Added a simple test. Change-Id: I20c3f680c7948b3904f213452272133be77e4d62 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove all locale-dependence from Q(Date|Time)+Edward Welbourne2020-05-081-10/+0
| | | | | | | | | | | | | | | [ChangeLog][Important Behavior Changes][QDateTime] Removed all locale-dependence from QDate, QTime and QDateTime, including the Qt::DateFormat members that select the formats of the default and system locales and the toString(Qt::DateFormat, QCalendar) overload, which only used its calendar for these formats. All toString() methods now use, and all fromString() methods only recognize, the C locale's names for days and months. Use QLocale's methods if you need to take locale into account. Fixes: QTBUG-80441 Change-Id: I3a8968438741afb00f44262f79659c51e9b06c35 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move a test of QLocale's methods out of tst_QDateTimeEdward Welbourne2020-05-082-81/+70
| | | | | | | | | | | | It clearly belonged in tst_QDate::toDateTime(), for which it adds a few more test-case and in which it inspires some further testing. The new testing of case-insensitivity doesn't work if the format contains stray non-format characters, so added a new data column to take care of that. Pick-to: 5.15 Change-Id: I73619be02091c97024a84cb963c7029e9fd0569a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Condition some date-time tests on feature textdateEdward Welbourne2020-05-081-8/+18
| | | | | | | | | | They use the Qt::TextDate format, so do depend on the feature. Rename one in the process; nothing in its test has anything to do with de_DE locale. Pick-to: 5.15 Change-Id: I2adae5c46e6009c13b433993ed2c3c761a500bfb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Handle disk full situations by skipping QFile::moveToTrash testVolker Hilsheimer2020-05-071-3/+9
| | | | | | | | | | If any of the temporary directories and files can't be created, skip the test. Otherwise, the cleanup routine would recursively delete "/". Change-Id: I51f908a468be8fd2ebd523ff7ce27a7c78d1b4e2 Fixes: QTBUG-83863 Pick-to: 5.15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFile::moveToTrash: work with relative file paths on WindowsVolker Hilsheimer2020-05-071-8/+12
| | | | | | | | | | | | | | | | | | | | The system APIs expect an absolute "display name" of the file path, so make it absolute. The test was overly tolerant in accepting failure, as a QStorageInfo initialized with a file path that doesn't exist is invalid, and thus always different from the QStorageInfo of the home directory. Fix the test to compare only valid QStorageInfo objects, and postpone the check until the file we want to move has been created. [ChangeLog][QtCore][QFile] moveToTrash supports relative file paths on Windows Change-Id: I94c8cd40c60fde469e38f76a98f867f20c6a0b15 Fixes: QTBUG-84015 Pick-to: 5.15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove Perforce commands from setupSuite.shThiago Macieira2020-05-051-3/+1
| | | | | | | | | | | | | | | This file mustn't have changed at all, aside from the copyright headers, since we switched to Git in October 2008. Quick check shows the data from W3C is still online: https://dev.w3.org/cvsweb/2001/XML-Test-Suite/ I didn't check that the CVS server is actually running because none of my machines even has the cvs command anymore... Pick-To: 5.15 Change-Id: I4e559af2a9a1455ab770fffd15f4e740114a2433 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QProcess: create a more reliable crashingThiago Macieira2020-05-051-6/+25
| | | | | | | | | | | | | Turns out that crashing on purpose is more difficult than it seems. It should be easy, given how often we do it accidentally... Let the null pointer dereferencing be the fall back. Some compilers are too smart for their own good and remove the fault. Instead, let's rely on raise(SIGABRT) on Unix and on the UD2 instruction on Windows. Pick-To: 5.15 Change-Id: Ibdc95e9af7bd456a94ecfffd1603f1c9b73b167d Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* tst_QResourceEngine: fix the order of arguments to QCOMPAREThiago Macieira2020-05-051-2/+2
| | | | | | | | Expected and actual were inverted. Pick-To: 5.15 Change-Id: Idc3fae4d0f614c389d27fffd15e9fa6a0a8f25e6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QChar: make std::hash'ableMarc Mutz2020-05-051-0/+7
| | | | | Change-Id: I2164df19cd17ab96a39020de66a3fe9fec838a36 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Purge from Q(Date|Time)+ most things marked to go at Qt 6Edward Welbourne2020-05-053-194/+3
| | | | | | Change-Id: Ib3f48c74132b47649dc7b4cbacf2cefed5a57687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge "Merge remote-tracking branch 'origin/5.15' into dev"Qt Forward Merge Bot2020-05-044-0/+247
|\
| * Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-05-044-0/+247
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/text/qlocale.cpp src/network/access/qnetworkaccessmanager.cpp Regenerated tests/auto/testlib/selftests/float/CMakeLists.txt Change-Id: I5a8ae42511380ca49a38b13c6fa8a3c5df8bed01
| | * QCommandLineParser: Wrap very long option names to leave room for descriptionsDavid Faure2020-05-012-0/+40
| | | | | | | | | | | | | | | | | | Fixes: QTBUG-79926 Change-Id: I3302e0ed5b58949a35ccb001c71b22a6400a6c81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QCborValue: check parsing of invalid URLThiago Macieira2020-04-301-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | QUrl will reject invalid URLs for us, so we don't get normalization. The original junk should be retrievable, of course. Change-Id: Ibdc95e9af7bd456a94ecfffd160610f5b2c8e1a2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | * QCborValue: add tests of parsing invalid ISO date-time stringsThiago Macieira2020-04-301-4/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | We rely on QDateTime::fromString being proper, so this is not extensive testing. Change-Id: Ibdc95e9af7bd456a94ecfffd160610cdac5d62e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | * QCborValue: add an extra check against producing invalid ISO datesThiago Macieira2020-04-301-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | By QCborValue design, we store the textual representation in ISO format, equivalent of CBOR tag 0, which isn't allowed to have negative years or beyond year 10000. Change-Id: Ibdc95e9af7bd456a94ecfffd16060ccff359c296 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| | * QCborValue: avoid signed integer oveflows when decoding time_tThiago Macieira2020-04-301-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDateTime::fromSecsSinceEpoch() multiplies by 1000 but does not check for overflow. That means we must do so in QCborValue validation. We can't use mul_overflow<qint64> on 32-bit platforms, so we do a compare- and-branch there. For 64-bit platforms, we prefer to do the multiplication with checked overflow, as the common case is that it will not overflow and we'll need the multiplication anyway. Change-Id: Ibdc95e9af7bd456a94ecfffd16060cba6f1c86b8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | * Fix data corruption regression in QJsonObject::erase()Eirik Aavitsland2020-04-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | The internal removeAt(index) method was implemented as taking cbor indexes directly, in contrast to the other ...At(index) methods. Fixes: QTBUG-83695 Change-Id: I16597eb6db1cf71e1585c041caa81bf8f7a75303 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Port more tests from qtbase/tests/auto/corelib/io/ to CMakeSona Kurazyan2020-05-0432-6/+528
|/ / | | | | | | | | | | Change-Id: I56427e3e1908047a0674c8c80c24eeda80e947c2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* | Remove useless codeLars Knoll2020-05-011-8/+0
| | | | | | | | | | | | | | | | | | We don't rely on a latin1 locale anymore for the test, and the other code was not doing anything. Change-Id: I08bc08d200c9e037884d8b680dfbb24c129f3d2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Remove QTextStream dependency from tst_qfileLars Knoll2020-05-011-15/+6
| | | | | | | | | | | | Change-Id: I83cb05da8c094185b50e9cedea2e705ad1c7f948 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* | Fix crash when using QProperty<T>::setBinding(Functor ...)Simon Hausmann2020-04-301-0/+12
| | | | | | | | | | | | | | | | We must move the functor properly into the binding object, otherwise we end up with stale pointers as pointed out by ASAN. Change-Id: Icd84f4c113dd48e1e3e2d744abac0902cdf9339e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | CMake: Fix build of qlogging test on MinGWAlexandru Croitor2020-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | The linker doesn't have a -rdynamic option. Otherwise the build fails with g++.exe error unrecognized command line option '-rdynamic' Task-number: QTBUG-75578 Change-Id: Ie89a19fd25e90bef14e64d1d98fd973fa0315997 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>