summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/serialization/json
Commit message (Collapse)AuthorAgeFilesLines
* QJsonObject iterators: use new comparison helper macrosTatiana Borisova2024-04-121-0/+22
| | | | | | | | | | | | | | | | | New comparison macros are used for following classes: - QJsonObject::iterator - QJsonObject::const_iterator Replace public operators operator==(), operator!=(), operator!<(), etc of classes to friend methods comparesEqual(), compareThreeWay(); Use *_helper methods to have an access to protected members of QCborValueConstRef class from friend functions. Task-number: QTBUG-120300 Change-Id: I308e2c0a549ff186c1d6339b38e989b80dc388a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add equality comparison between QJsonObject and QJsonValueConstRefTatiana Borisova2024-04-031-0/+3
| | | | | | | | - amends 839cffd5212cc1437661e9c650eb2ff4b19fa4e8 Fixes: QTBUG-123927 Change-Id: I9174e747478937d4c9ed6522dd603fea50daf203 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Tests: check the output of QFile::openGiuseppe D'Angelo2024-03-271-2/+2
| | | | | | | | | | Wrap the call in QVERIFY. tst_QTextStream::read0d0d0a was also faulty as it *never* opened the file because of a broken path. Fix it with QFINDTESTDATA. Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonArray iterators: use new comparison helper macrosTatiana Borisova2024-03-261-0/+35
| | | | | | | | | | | | | | | | New comparison macros are used for following classes: - QJsonArray::iterator - QJsonArray::const_iterator Replace public operators operator==(), operator!=(), operator!<(), etc of classes to friend methods comparesEqual(), compareThreeWay(); Use *_helper methods to have an access to protected members of QCborValueConstRef class from friend functions. Task-number: QTBUG-120300 Change-Id: I9b41b619107ce69d8b6dab4938232fab841aab51 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonObject: use new comparison helper macrosTatiana Borisova2024-03-251-1/+21
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonObject to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonObject, QJsonValue) to the QJsonObject class, to support comparison between QJsonObject and QJsonValue elements, see test-case valueEquals(). Task-number: QTBUG-120300 Change-Id: Ibab0b4b39966205447e31c41e94e7e1a4e31e553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonValue: use new comparison helper macrosTatiana Borisova2024-03-221-35/+49
| | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonValue/QJsonValueConstRef/QJsonValueRef classes to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Delete non-exported public operators operator==(), operator!=() for QJsonValueConstRef/QJsonValueRef classes. Add comparison check to auto-test. Task-number: QTBUG-120300 Change-Id: I01434af4ce5a7589733db4a9b14f54ad42e852ed Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonDocument: use new comparison helper macrosTatiana Borisova2024-03-221-3/+20
| | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonDocument to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120300 Change-Id: I7b61765c34406b7a9fb7dd8b1fc554c87af6a3f3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonArray: use new comparison helper macrosTatiana Borisova2024-03-212-0/+41
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonArray to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonArray, QJsonValue) to the QJsonArray class, to support comparison between QJsonArray and QJsonValue elements, see test-case fromToVariantConversions() Task-number: QTBUG-120300 Change-Id: I8440ca0761bede8551ff792bfa7f22e47b56fa79 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-171-2/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-1/+1
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Rest of QtBase tests: port away from deprecated methodsIvan Solovev2022-08-301-5/+7
| | | | | | | | | | Small changes to fix builds with QT_DISABLE_DEPRECATED_UP_TO >= 0x060500 Task-number: QTBUG-104858 Change-Id: Ia531a3cee97f13827e36b3d63f28eed879fe9a40 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-281-1/+1
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QJsonValue: fix incorrect to{Array,Object} when the value is emptyThiago Macieira2022-06-211-2/+16
| | | | | | | | | | | | This is a repeat of commit de6ced66920600e659dbaa2509526a3bcb0b3360 "QCborValue: fix incorrect to{Array,Map} when the value is empty" (6.4), which fixed the same thing for QCborValue. I've just copied the exact same implementation onto the QJsonValue functions. Pick-to: 6.2 6.3 6.4 5.15 Fixes: QTBUG-104085 Change-Id: I175efddd75f24ae59057fffd16f6b257bf7ed36d Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+3
| | | | | | | | | | | | | 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>
* Don't use QSKIP() when merely eliding part of a testEdward Welbourne2022-04-071-25/+23
| | | | | | | | | | | | | | | | | Use of QSKIP() means the whole test is skipped; when all applicable parts of a test have passed and some part of the test is inapplicable, merely report that it is skipped, rather than discarding the PASS for all the parts that do work. In the process, eliminate a spurious layer of indentation; the earlier test only needed a scope to contain its declaration, a goal adequately achieved by the scope of the if constexpr block. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: Ie4790a24ebf49a7f3035ffad42d78450e1560832 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Tests: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+2
| | | | | Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QJsonObject::removeAt: stop dividing and multiplying by 2Thiago Macieira2022-02-151-2/+3
| | | | | Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJsonValueConcreteRef: optimize concrete()Thiago Macieira2022-02-151-4/+2
| | | | | | | | | | | | Inline the content to avoid a round-trip through qjsonarray.cpp and qjsonobject.cpp. This change revealed an inadviseable unit test check that dereferences the end() iterator to get its type. I haven't changed it, but have marked with ###. I also fixed a likely copy&paste mistake in that test. Change-Id: I89446ea06b5742efb194fffd16bb774f3bfbe5f5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJsonObject::erase: erase unnecessary and wrong codeThiago Macieira2022-02-151-9/+62
| | | | | | | | | | | | | | | | | | | | Commit 35adb74ddd915831789f0175423660f8e898942e ("Reimplement JSON support on top of Cbor") accidentally forgot to multiply by 2 the index stored in the QJsonObject::iterator. The same mistake was propagated when QJsonObject::iterator was converted to QJsonValueRef. This had no ill effects because the o->elements container would always contain more elements, but it meant the check was ineffective and meant nothing. So instead of doing nothing when the iterator does not point to this container, simply assume it does. Bad things will happen if you try to erase an iterator that points to another container, but that's true for almost all container/iterator mechanisms. Drive-by modernization of some of the surrounding lines. Change-Id: I89446ea06b5742efb194fffd16bb7c322c2fc4f2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Exclude denormal test cases if system doesn't support itTatiana Borisova2022-02-151-21/+75
| | | | | | | | | | | | - current INTEGRITY development pack don't support denormals for float and double. All values are rounded to 0. Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: Iaaacdc4210c7ac2ec3ec337c61164a1ade0efb01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Cleanup tests that add test data to resources explicitlyAlexey Edelev2022-02-111-26/+11
| | | | | | | | | | | | Remove Integrity and Android specific code that explicitly adds test data to the resource files. qt_internal_add_test functions implicitly adds test data to resources for Android and Integrity platforms by default. Change-Id: Ia1d58755b47442e1953462e38606f70fec262368 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix C++20 ambiguous relational operators between QJsonValue{,Ref}Marc Mutz2022-02-091-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In C++20, any given relational operator is also considered in its reversed form, so e.g. given op==(X, Y) and X x, Y y, then y == x will compile, by using the reversed op(X, Y) This, unfortunately, makes some existing asymmetric operator overload sets ambiguous, and instead of applying tie-breaker rules, at least Clang is warning about these. For us, this means we need to make our overload set non-ambiguous. The QJsonValue{,Ref} classes failed this, because they only provide the following member-operators: - QJsonValue::op==(const QJsonValue&) const - QJsonValueRef::op==(const QJsonValue &) const For member functions, there are no implicit conversions on the LHS. So in C++17, we have a nice dichotomous overload set: - LHS is QJsonValue -> use QJsonValue::op==(QJsonValue) - LHS is QJsonValueRef -> use QJsonValueRef::op==(QJsonValue) In both of these, it the RHS is a QJsonValueRef, it's implicitly converted to QJsonValue for the call. Enter C++20, and the reversed signatures are suddenly available, too, which is a problem for QJsonValueRef <> QJsonValueRef, which could be resolved, as in C++17, using lhs.QJVR::op==(QJV(rhs)) or it could now be rhs.QJVR::op==(QJV(lhs)); // reversed Says Clang 10: tst_qtjson.cpp:990:5: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'QJsonValueRef' and 'QJsonValueRef') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator] CHECK(r0, a0, r1); ^ ~~ ~~ qjsonvalue.h:189:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed inline bool operator==(const QJsonValue &other) const { return toValue() == other; } ^ A similar argument makes op!= ambiguous. Says Clang 10: tst_qtjson.cpp:988:5: error: use of overloaded operator '!=' is ambiguous (with operand types 'QJsonValueRef' and 'QJsonValueRef') CHECK(r0, r0, r1); ^ ~~ ~~ qjsonvalue.h:190:17: note: candidate function inline bool operator!=(const QJsonValue &other) const { return toValue() != other; } ^ qjsonvalue.h:189:17: note: candidate function inline bool operator==(const QJsonValue &other) const { return toValue() == other; } ^ qjsonvalue.h:189:17: note: candidate function (with reversed parameter order) To fix, provide the missing operators as free inline functions (so Qt 6.2 and 5.15 don't get new symbols added) so there's always exactly one best match. This is a fix for 6.2 and 5.15. At the time of writing, 6.3 isn't released, yet, so there, we could QT_REMOVED_SINCE the pre-existing member operators in favor of hidden friends (as per QTBUG-87973). Use C++17'isms to prevent an automatic merge to 5.15, which requires contains(QT_CONFIG,c++2a):CONFIG += c++2a added to tst_qtjson.pro. [ChangeLog][QtCore][QJsonValue] Fixed relational operators to not cause warnings/ambiguities when compiling in C++20. Pick-to: 6.3 6.2 5.15 Change-Id: Ic70f3cad9987c87f7346d426c29cc2079d85ad13 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* JSON: Further improve the duplicate handling in the parserUlf Hermann2022-01-215-10/+123
| | | | | | | | Avoid some unnecessary comparisons and add more tests. Task-number: QTBUG-99799 Change-Id: I3aee9f0b62461d38dadbe8e969444e1cd1f94e68 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_QtJson: fix test for numbers above the limit of qint64Thiago Macieira2022-01-191-10/+7
| | | | | | | | | | | | | Commit 289f909621a8d83320d33e3ff7d651c164034098 ("Test conversion of ulonglong variant to JSON") was trying to ensure the result becomes a double. So there's no reason to make a test in the _data() function. Drive-by fix the UB condition on Windows (ulong is 32-bit, so 1ul << 63 is UB). Change-Id: I0e5f6bec596a4a78bd3bfffd16ca4f8f5219f785 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* JSON: When clearing duplicate object entries, also clear containersUlf Hermann2022-01-181-0/+19
| | | | | | | | | | | | | | | | | Previously, if you had multiple entries with the same name in an object, and some of them were again objects or arrays, parsing the JSON document would leak memory. Also, we use std::stable_sort instead of std::sort now, so that we don't accidentally randomize the order of elements with equal keys. [ChangeLog][QtCore][JSON] A memory leak in the JSON parser when reading objects with duplicate keys was fixed. Pick-to: 5.15 6.2 6.3 Fixes: QTBUG-99799 Change-Id: Ic2065f2e490c2d3506a356745542148ad9c24262 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove unused .qrc filesJoerg Bornemann2022-01-171-8/+0
| | | | | | | | Task-number: QTBUG-94446 Change-Id: I136d8b4ab070a832866aa50b5701fc6bd863df8a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix tst_qtextstream / tst_json run time failures on INTEGRITY deviceTatiana Borisova2021-12-281-1/+1
| | | | | | | | | - add test resources to binaries Task-number: QTBUG-99123 Pick-to: 6.2 6.3 Change-Id: Ibeed93af43b4f951ca55f044fbfab00d4ab30468 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Remove expected failPasi Petäjäjärvi2021-12-121-14/+0
| | | | | | | | Works with QCC 8.3.0 (Based GCC 8.3.0 20190222 (stable)) Pick-to: 6.2 Change-Id: I130847627a4b77ced83d196a7a1674963c5cd3e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* Prefer QFAIL("Informative message") over QVERIFY(false)Edward Welbourne2021-06-141-3/+3
| | | | | Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a 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>
* 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 the qmake project filesJoerg Bornemann2021-01-071-12/+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-221-1/+1
| | | | | | | | | | | 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>
* 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>
* QChar: make construction from integral explicitGiuseppe D'Angelo2020-11-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-231-3/+3
| | | | | | | | | | | 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>
* 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>
* 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>
* 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>
* Remove deprecated binary json featureEdward Welbourne2020-07-3134-239/+0
| | | | | | | | | Deprecated in 5.15 in favor of CBOR. Fixes: QTBUG-81239 Change-Id: I711d4bd7dd1247f58e77ac9fa53304cbe5028918 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Disable deprecation warnings in some testsTor Arne Vestbø2020-07-291-0/+2
| | | | | | | | The tests are testing deprecated functionality, which we still want to test. Change-Id: Iad6ed35800896170c17fe019c7a6ecda22398ac3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>