summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization
Commit message (Collapse)AuthorAgeFilesLines
* Remove conditioning on Android embeddedEdward Welbourne2021-09-171-1/+1
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Add missing dependencies of tests on their helper programsEdward Welbourne2021-09-171-3/+4
| | | | | | | | | | | | | | | | | This ensures that a command such as $ ninja tst_qlocale && ninja tst_qlocale_check will automagically build the syslocaleapp program that the test runs from a subtest. Similar for testlib's selftests and tst_QProcess. As a drive-by, pruned some legacy comments from when CMakeLists.txt files were generated from .pro files. Change-Id: I67691a8175aaef124d4104cf1898193993408bdf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* tst_QtJson: add matching escape-generating testThiago Macieira2021-09-061-0/+55
| | | | | | | Change-Id: Ie72b0dd0fbe84d2caae0fffd16a11596eb61a90e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* JSON parsing: fix incorrect sign-extension for decoding bad escapesThiago Macieira2021-09-061-7/+64
| | | | | | | | | | | | | | The parser was lenient in accepting backslashes followed by invalid characters, but accidentally sign-extended everything above 0x7f causing broken outputs that weren't valid UTF-16 either. For example, the sequence "\\\xff" (backslash followed by 0xff) produced sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair). Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tests: Remove unused SRCDIR definesIevgenii Meshcheriakov2021-08-174-8/+0
| | | | | | | | | | | Remove SRCDIR defines from tests that don't use them. There is a standard define called QT_TESTCASE_SOURCEDIR that is available to all tests and serves the same purpose. Pick-to: 6.2 Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Prefer QFAIL("Informative message") over QVERIFY(false)Edward Welbourne2021-06-141-3/+3
| | | | | Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix BASE argument of qt_add_resourcesJoerg Bornemann2021-05-181-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The BASE argument of qt_add_resources now denotes the root point of the alias of the file. Before, BASE was merely prepended to every file that got passed to qt_add_resources. Old behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "images/button.png") Alias is "../shared/images/button.png", and pro2cmake generated QT_RESOURCE_ALIAS assignments to fix this. New behavior: qt_add_resources(app "images" PREFIX "/" BASE "../shared" FILES "../shared/images/button.png") The alias is "images/button.png". No extra QT_RESOURCE_ALIAS assignment is needed. The new behavior is in effect for user projects and for Qt repositories that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE. Qt repositories will be ported one by one to this new behavior. Then the old code path can be removed. Pick-to: 6.1 Task-number: QTBUG-86726 Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix compiler warning from int size mismatchVolker Hilsheimer2021-04-291-2/+2
| | | | | | | | Cast consistently to quint8, which is the type we are streaming out in the test. Change-Id: I44d360ca6b75f14e7a2b80962ad249a6f6b1cb31 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct prefix reported for end element in QXmlStreamReaderVincent Baijot2021-04-208-13/+13
| | | | | | | | | | | | | | | | | | | Before this change, QXmlStreamReader prefix value was always an empty string for EndElement when the documentation state : "Returns the prefix of a StartElement or EndElement." The error was a missing update of the prefix value when parsing EndElement. I updated the tests data which were also wrong because no prefix were reported even for </a:foo>. No new test is necessary, I think, the test data already cover the cases of EndElement with a prefix and without one (unchanged here). Fixes: QTBUG-86847 Pick-to: 5.15 6.0 6.1 Change-Id: I0ad38b9741d760f1ce688a36f969ec14e20a928c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qcborstreamwriter: don't pass char8_t strings to QByteArrayGiuseppe D'Angelo2021-04-161-2/+2
| | | | | | | | | | | | | | There isn't a QByteArray constructor taking a char8_t*. (I am not sure if there should be one; QByteArray is not going to anything special about that information anyways.) Change such strings to be "ordinary" narrow string literals. There should be no problems at doing so, as by default we build in UTF-8 mode under all compilers. Pick-to: 6.1 6.0 Change-Id: Ia200ec6e3b0453bad033d5d8ff34c013bb27abd1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonObject: Fix operator<=()Ulf Hermann2021-02-181-0/+31
| | | | | | | | | | We had a copy-paste error there. Pick-to: 6.0 6.1 Change-Id: Ib1448197ac4f4641c6559f133f41dcf326f210f1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move QEMU emulation detector to QTestSamuli Piippo2021-02-132-5/+3
| | | | | | | | | The emulation detection has been usable only on qtbase tests, move it to QTest so that it can be used in other modules as well. Pick-to: 6.1 Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJsonObject::take: add missing detach() callThiago Macieira2021-01-271-0/+19
| | | | | | | | | | We were modifying shared objects. Pick-to: 6.0 5.15 Fixes: QTBUG-89625 Change-Id: Id6bc735b79cf4beb9454fffd165c56476a5dec04 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Remove .prev_CMakeLists.txt filesJoerg Bornemann2021-01-122-50/+0
| | | | | | | | | | Those serve no purpose anymore, now that the .pro files are gone. Task-number: QTBUG-88742 Change-Id: I39943327b8c9871785b58e9973e4e7602371793e Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* tst_qdatastream: expect failure on 32bit system with large QBitArraySamuli Piippo2021-01-082-3/+4
| | | | | | | | | | Test data causes the QBitArray to be read as 0 byte length. Same issue on all 32bit systems, removing android blacklisting as this was the only one failing there. Task-number: QTBUG-87660 Change-Id: I63f0c1c6fa4e2242e6ebe70f50e422ab0fbf1c88 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-0714-145/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-2210-10/+32
| | | | | | | | | | | 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>
* CMake: Regenerate projects using pro2cmake one last timeAlexandru Croitor2020-12-101-0/+17
| | | | | | | | | And fix up some wrong qmake project files Pick-to: 6.0 Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QCborValue & QCborStreamReader tests: fix warning about %llx on 32-bitThiago Macieira2020-12-071-6/+6
| | | | | | | | | | | | | | | | | cborlargedatavalidation.cpp:93:60: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘qsizetype’ {aka ‘int’} [-Wformat=] 93 | QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v) | ~~~^ ~ | | | | | qsizetype {aka int} | long long unsigned int | %x The cast to size_t is required to make the 64-bit not complain due to the long vs long long difference. Pick-to: 5.15 6.0 Change-Id: I00b01c01a66748508ea1fffd164a9add2a2650cf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* tst_QCborValue: adjust the size of the minimum string that won't fitThiago Macieira2020-12-071-1/+3
| | | | | | | | | I don't know which of the previous commits caused this: as far as I can tell, this test should never have passed. Pick-to: 5.15 6.0 Change-Id: I55083c2909f64a1f8868fffd164e7e8c24eec1f8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCborStreamReader::next: don't allocate too much memory in a QBAThiago Macieira2020-12-072-12/+19
| | | | | | | | | | | | | | | | | | | | Because CBOR strings are encoded in UTF-8, it's possible that the string that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8 (e.g., anything US-ASCII and most Latin text). The previous solution was an improvement because we used to read into a QByteArray then convert the QByteArray to QString, thus using 3x the amount of memory (1x in QByteArray, 2x in QString). The previous commit skipped the middle allocation and made the regular readString() function do the decoding either directly on source memory or by reading in small chunks (16 kB). Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype) so we can do the validation / skipping at O(1) memory. Pick-to: 5.15 6.0 Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborValue: avoid allocating result if data is insufficientThiago Macieira2020-12-062-10/+11
| | | | | | | | | | | Similar to the previous commit which applied to QCborStreamReader, don't allocate too much data before checking that the stream actually has that much. Pick-to: 5.15 6.0 Fixes: QTBUG-88256 Change-Id: I7b9b97ae9b32412abdc6fffd16454b7568a063ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QCborStreamReader: avoid allocating result if data is insufficientThiago Macieira2020-12-063-8/+13
| | | | | | | | | | | | | | | | | | | | | | | By calling the internal readStringChunk() function with a QByteArray pointer, QCborStreamReader::readByteArray() can now avoid allocating the resulting buffer until the internals have confirmed that there is sufficient data in the incoming buffer. As a result, we first detect the EOF condition before we conclude the payload would have been too big for QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation() test ends up with a few conditions where it would have copied 1 GB of data, so limit that too. We make a choice of reporting OOM vs DataTooLarge only if QByteArray fails to allocate in the first place (QByteArray::resize() -> Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on). The QCborValue unit test needed a temporary work around until we apply the same allocation fix (see next commit). Pick-to: 5.15 6.0 Fixes: QTBUG-88253 Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Test conversion of ulonglong variant to JSONSona Kurazyan2020-11-201-0/+12
| | | | | | | | Make sure ulonglong variant converts to a double JSON value when the value is greater than 2^63. Change-Id: I4d4392b05de29c220624056d5d0d4664fb2c08b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Android: exclude tests crashing at startAssam Boudjelthia2020-11-162-2/+4
| | | | | | | | | | | These tests are failing with "java.lang.UnsatisfiedLinkError: dlopen failed: invalid ELF file" at the start, excluding them now to enable Android testing until they're fixed later. Task-number: QTBUG-87671 Task-number: QTBUG-87025 Change-Id: Ida7d7158fccdc31df1f9689f77fde832964d732f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QChar: make construction from integral explicitGiuseppe D'Angelo2020-11-152-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QChar should not be convertible from any integral type except from char16_t, short and possibly char (since it's a direct superset). David provided the perfect example: if (str == 123) { ~~~ } compiles, with 123 implicitly converted to QChar (str == "123" was meant instead). But similarly one can construct other scenarios where QString(123) gets accidentally used (instead of QString::number(123)), like QString s; s += 123;. Add a macro to revert to the implicit constructors, for backwards compatibility. The breaks are mostly in tests that "abuse" of integers (arithmetic, etc.). Maybe it's time for user-defined literals for QChar/QString, but that is left for another commit. [ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar constructors from integral types are now by default explicit. It is recommended to use explicit conversions, QLatin1Char, QChar::fromUcs4 instead of implicit conversions. The old behavior can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION macro. Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Android: blacklist a list of failing tests for androidAssam Boudjelthia2020-11-042-0/+10
| | | | | | | | | | | | | | | | We want to re-enable Android tests in QTQAINFRA-3867. However, many tests are failing already preventing that from happening. QTBUG-87025 is currently keeping track (links) to all of those failing tests. The current proposal is to hide those failing tests, and enable Android test running in COIN for other tests. After, that try to fix them one by one, and at the same time we can make sure no more failing tests go unnoticed. Task-number: QTBUG-87025 Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Update tst_qcborstreamwriter to use QMetaTypeDavid Skoland2020-10-301-10/+10
| | | | | | | Since the QVariant types are deprecated in Qt6, use QMetaType instead Change-Id: I7bddea15a3f1a534d3c6f6b9e7ddf9585a8423bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate QVariant::TypeLars Knoll2020-10-232-2/+2
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix some compiler warnings from testsVolker Hilsheimer2020-10-161-1/+1
| | | | | | | | For iterators that return a value, don't use reference in ranged for, and cast numeric literal to correct size type for QCOMPARE. Change-Id: Idfd09dbc2ef3ab1bf025c7859ea6e2e9572bc9a1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-072-2/+2
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QJsonObject: fix sorting after parsing from JSON textThiago Macieira2020-09-291-8/+43
| | | | | | | | | | | The logic was complex and missed the UTF-8 UTF-8 case. It ended up calling the UTF-8 to Latin1, resulting in an improperly-sorted container, which in turn meant keys were not found when searched. Fixes: QTBUG-86873 Pick-to: 5.15 Change-Id: I0d3ff441bec041728945fffd16379dec418637ca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add checks for new QBitArray versionAllan Sandfeld Jensen2020-09-291-46/+57
| | | | | | | Add a few checks for the new longer length. Change-Id: I642a64b91361d236457e7a89a02feb812b4e1cf8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Switch QBitArray to qsizetypeAllan Sandfeld Jensen2020-09-291-0/+1
| | | | | | | To make it consistent with other containers in Qt6. Change-Id: I5578845390248baf80daa282237b706857e57661 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-2313-19/+19
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Regenerate projectsAlexandru Croitor2020-09-221-2/+1
| | | | | | | | | Clean up the state of the projects, before changing the internal CMake API function names. Task-number: QTBUG-86815 Change-Id: I90f1b21b8ae4439a4a293872c3bb728dab44a50d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Deprecate implicit QPixmap conversion to QBitmapVolker Hilsheimer2020-09-171-1/+1
| | | | | | | | | | | | | | | | It is lossy, so should be requested explicitly, using a dedicated fromPixmap factory function. Deprecate the constructor and assignment operator, and make the constructor explicit. [ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning to a QBitmap from a QPixmap has been deprecated, and the respective constructor has been made explicit. Use the fromPixmap factory function instead. Change-Id: I68ce85b26c901415137b664a1db687021d48bae0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tests: fix json test for AndroidAssam Boudjelthia2020-09-152-3/+2
| | | | | | | | | test.bjon file doesn't exist, however, it's still included in json.qrc. That causes the test to fail on Android because it's using that resource file. Change-Id: I1e93076069073a1a621459a7d90aec5c0c03f768 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Use UTF-8 when converting 8 bit data in QTextStreamLars Knoll2020-09-151-2/+2
| | | | | | | | | This was overlooked when doing the conversion to use UTF-8 as the standard 8 bit encoding for text. Fixes: QTBUG-54942 Change-Id: Ib7b1b75b4d694648ab7143f6930b6bb1dcad19c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove the SAX parser from QtXmlLars Knoll2020-09-151-1/+0
| | | | | | | | It has been deprecated and will live in qt5compat from now on. Fixes: QTBUG-86480 Change-Id: I3744c7cee058d51d0fce633a174ab1a0f9235d2c Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
* Fix compiler warnings about missing overridesLars Knoll2020-09-131-1/+1
| | | | | Change-Id: I52bf9fe45607f4a99cafa441bd78dfe5f7adb0e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove most compiler warnings about missing overridesLars Knoll2020-09-112-3/+3
| | | | | | | | | | | | Remove around 1000 compiler warnings about missing overrides in our auto tests. This significantly reduce the compiler warning noise in our auto tests, so that one can actually better see the real problems inbetween. Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change QByteArray to handle large arraysLars Knoll2020-08-272-4/+8
| | | | | | | | | | Use qsizetype throughout. Change-Id: I787af7fcfa17e1be87decb64c41c609cc24be117 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate int based convert/canConvertLars Knoll2020-08-241-2/+2
| | | | | | | Better to provide the correct meta type to convert to. Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move QStringRef and remains to Qt5CompatKarsten Heimrich2020-08-201-3/+3
| | | | | | | | | Export some private functions from QUtf8 to resolve undefined symbols in Qt5Compat after moving QStringRef. Task-number: QTBUG-84437 Change-Id: I9046dcb14ed520d8868a511d79da6e721e26f72b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Constrain the data stream operators for containersLars Knoll2020-08-151-0/+8
| | | | | | | | | | | Check that we can successfully instantiate the data stream operator for a container before we actually try. This is required so we can automate registration of debug stream operators with QMetaType. Change-Id: Ib100a5242470d7fc8067058cc4d81af2fa9354b0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix conversions to JSON from QVariantSona Kurazyan2020-08-131-0/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After reimplementing Qt JSON support on top of CBOR, there were unintended behavior changes when converting QVariant{, List, Map} to QJson{Value, Array, List} due to reusing the code for converting QVariant* types to CBOR types, and from CBOR types to corresponding JSON types. In particular, conversions from QVariant containing QByteArray to JSON has been affected: according to RFC 7049, when converting from CBOR to JSON, raw byte array data must be encoded in base64url when converting to a JSON string. As a result QVariant* types containing QByteArray data ended up base64url-encoded when converted to JSON, instead of converting using QString::fromUtf8() as before. There were also differences when converting QRegularExpression. Reverted the behavior changes by adding a flag to internal methods for converting CBOR to JSON, to distinguish whether the conversion is done from QVariant* or CBOR types. These methods now will fall back to the old behavior, if the conversion is done using QJson*::fromVariant*(). Additionally fixed QJsonValue::fromVariant conversion for NaN and infinities: they should always convert to QJsonValue::Null. This works correctly when converting from variant to QJsonArray/QJsonObject, but has been wrong for QJsonValue. Added more tests to verify the expected behavior. [ChangeLog][Important Behavior Changes] Restored pre-5.15.0 behavior when converting from QVariant* to QJson* types. Unforeseen consequences of changes in 5.15.0 caused QByteArray data to be base64url-encoded; the handling of QRegularExpression was also unintentionally changed. These conversions are now reverted to the prior behavior. Additionally fixed QJsonValue::fromVariant conversions for NaN and infinities: they should always convert to QJsonValue::Null. Fixes: QTBUG-84739 Change-Id: Iaee667d00e5363906eedbb67948b7b39c9d0bc78 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Restrict comparison of variantsLars Knoll2020-08-131-2/+10
| | | | | | | | | | | | | | | | | | | | | Comparing two variants will not try to convert the types of the variant anymore. Exceptions are when both types are numeric types or one type is numeric and the other one a QString. The exceptions are there to keep compatibility with C++ and to not completely break QSettings (which needs automatic conversions from QString to numeric types). [ChangeLog][Important Behavior Changes] Comparing two variants in Qt 6 will not try attempt any type conversions before comparing the variants anymore. Instead variants of different type will not compare equal, with two exceptions: If both types are numeric types they will get compared according to C++ type promotion rules. If one type is a QString and the other type a numeric type, a conversion from the string to the numeric tpye will be attempted. Fixes: QTBUG-84636 Change-Id: I0cdd0b7259a525a41679fb6761f1e37e1d5b257f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborValue: add support for QCOMPARE string outputThiago Macieira2020-08-121-2/+138
| | | | | | Change-Id: Ibdc95e9af7bd456a94ecfffd16066c47ea9766d0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJsonDocument: fix comparison of valid vs defaultThiago Macieira2020-08-111-0/+61
| | | | | | | | | | | [ChangeLog][QtCore][QJsonDocument] Fixed a bug that caused QJsonDocument's equality operator to crash if one of the operands was default-constructed and the other wasn't. Pick-to: 5.15 Fixes: QTBUG-85969 Change-Id: I5e00996d7f4b4a10bc98fffd1629f835f570ef6b Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>