summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.6' into devSimon Hausmann2016-01-121-0/+7
|\ | | | | | | Change-Id: I5839bded07e23af65ced9491c4f50242f964dd31
| * QVariant: make sure two floating points compare equal if they are equalThiago Macieira2016-01-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Not just fuzzily equal. The fuzzy comparison fails for infinities, since the expression p1 - p2 where p1 = p2 = infinity is NaN. And NaN comparisons are always false. As a nice side-effect, we don't do the more expensive computation of a multiplication if the two numbers really are equal. Task-number: QTBUG-50036 Change-Id: I11f559ef75544c50b3f8ffff1420cec7c7273295 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2015-12-181-0/+41
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/painting/painting.pri src/plugins/platforms/xcb/qxcbconnection.cpp tests/auto/corelib/thread/qthreadstorage/qthreadstorage.pro tests/auto/corelib/tools/qlocale/test/test.pro tests/auto/gui/kernel/qwindow/tst_qwindow.cpp tools/configure/environment.cpp Change-Id: I9c40f458b89b2c206de2d2c24e90b5f679c93495
| * QVariant: retain duplicate keys when convertingThiago Macieira2015-12-081-0/+41
| | | | | | | | | | | | | | Task-number: QTBUG-49520 Change-Id: I3e15a26e0e424169ac2bffff1417e3f4398c2277 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* | Interpret precision == -128 as "shortest" double conversionUlf Hermann2015-11-231-8/+43
| | | | | | | | | | | | | | | | | | | | | | | | Also use this for converting doubles with QVariant. We generally want exact results there, rather than adding rounding errors whenever we convert. [ChangeLog][QtCore][QLocale] Added special value for double conversion precision to get shortest accurate representation. Change-Id: I905b8a103f39adf31d24b6ce2c8a283cf271b597 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | tests/corelib: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).Friedemann Kleint2015-08-191-22/+22
|/ | | | | | | | | | | | | | - Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer). - Replace Q[TRY]_VERIFY(smartPointer == 0) by Q[TRY]_VERIFY(smartPointer.isNull()). - Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and add casts where necessary. The values will then be logged should a test fail. Tests from corelib/tools were omitted in this change. Change-Id: I4c8786d33fcf429d11b2b624c7cd89c28cadb518 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-03-161-2/+3
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbnativeinterface.h Change-Id: I31b38ba439b9341d51a01c0fd54bea33f7410076
| * Fix building tests on QNXAllan Sandfeld Jensen2015-03-091-2/+3
| | | | | | | | | | | | | | Use qmath and cmath methods instead of math.h methods. Change-Id: I86ee2465c999822bf00a7cefee1642c4c30590a6 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@digia.com>
* | tst_qvariant: Remove an obsolete QSKIPOlivier Goffart2015-03-111-3/+0
|/ | | | | | | | | | The QSkip was there because of a bug in QList. Since commit 8153386397087ce4f5c8997992edf5c1fd38b8db, the test is no longer using QList. We can remove the QSKIP Task-number: QTBUG-8959 Change-Id: Icc18d341d734d0605dcddaf925586f3bd603d6a0 Reviewed-by: Jocelyn Turcotte (Woboq GmbH) <jturcotte@woboq.com>
* Make QPersistentModelIndex an internal meta-typeGabriel de Dietrich2015-03-061-0/+13
| | | | | | | | | | | It was already a user meta-type, so it only gets promoted to internal. [ChangeLog][QtCore] QPersistentModel index becomes an built-in meta-type, including QVariant support. Change-Id: I63d733d1eb66aa61691e7afce27fe7372a83ac00 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QVariant: fix converting enum to stringOlivier Goffart2015-02-251-1/+1
| | | | | | | Use QMetaEnum::valueToKey instead of valueToKeys. Change-Id: I270f0820a03aaebde94c37c011c5e9b81421b50f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
* Add conversion between Q_ENUMs and strings in QVariantOlivier Goffart2015-02-151-2/+77
| | | | | Change-Id: I9264a68d162cf20db0167dd3f976a007477786d1 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Improve conversion of QVariants with QJsonValuesAllan Sandfeld Jensen2015-02-121-7/+20
| | | | | | | | Adds conversion from QJsonArray and QJsonObject, and report missing conversion failures for other QJsonValues. Change-Id: Ic0c3a952657912401db877b068f7fcc3c08c94c2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* QAssociativeIterable: add find()Marc Mutz2015-01-211-1/+4
| | | | | | | | | | This is like value(), but returns an iterator instead of the value(). [ChangeLog][QtCore][QAssociativeIterable] Added find(). Change-Id: I029fc8f91cef78f718d419587a2a50ffd2bf7632 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Implement proper C++ type numeric promotion for QVariant comparisonsThiago Macieira2014-12-031-1/+322
| | | | | | | | | | | | | | | | | | | | | | Previously, QVariant would try to convert one operand to the other's type, which would produce unexpected results: the results would depend in the order of the operands and whether there was data loss in the conversion. In addition, ordering comparisons were only done with signed values, yielding other unexpected results, like QVariant(LLONG_MAX / 2) < QVariant(Q_UINT64_C(0)). Instead, try to obey the C++ standard rules for type promotion in expressions. Our code is a little simpler than the standard would seem to require since we know some more details from the ABI. [ChangeLog][Important Behavior Changes][QVariant] QVariant now obeys the C++ type promotion rules when comparing numeric types (integrals, float and double), including the fact that unsigned comparisons are preferred for types of the same rank (that is, now QVariant(-1) > QVariant(0U)). Task-number: QTBUG-42722 Change-Id: Ie7b19073dcb45485354710975e561bcdb1a753f1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-11-241-6/+6
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice.cpp src/plugins/bearer/linux_common/qofonoservice_linux.cpp src/plugins/bearer/linux_common/qofonoservice_linux_p.h src/plugins/platforms/android/qandroidplatformtheme.cpp src/tools/bootstrap/bootstrap.pro src/widgets/styles/qmacstyle_mac.mm Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
| * tst_qvariant: automate testing of forward_listMarc Mutz2014-10-291-6/+6
| | | | | | | | | | | | | | ...using the SD-6 __has_include macro. Change-Id: I629e2ad1c8090aba9e86ab9febf6d09a504219f9 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | Fix asymmetry in QVariant::cmp when A converts to B but not the oppositeThiago Macieira2014-11-201-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This would result in (a == b) != (b == a). The == operation should be commutative as much as possible. Now, there's still an asymmetry in that b is forced to a type and the conversion may fail. QVariant should have an idea of what conversions are "promotion" and which ones are "demotion" (subject to loss of data and/or can fail), so it can do the promotion first Task-number: QTBUG-42254 Change-Id: I9fa4496bbbf0f8719ff8456cc24247290beac608 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Enhance precision of the FP conversion to strings in QVariantThiago Macieira2014-11-201-38/+73
|/ | | | | | | | | | | | | | | | | | | | | | This now guarantees that doing a round-trip from an FP number to string and back to number results in the same number. This change is required because DBL_DIG and FLT_DIG don't have the meaning that we were expecting them to, here: they mean the minimum number of digits of precision in decimal (i.e., changing the last decimal will always cause the FP number to change). We need the maximum number: there is one change in the last decimal place that causes the FP number to change. IEEE 754 single-precision has 24 binary digits and double precision has 53 binary digits in their mantissa. To convert that to decimal, multiply by the number of decimal digits a binary digit represents (log2(10) = 0.3), then add one for the rounding and one more digit for the actual precision we want. That is, for floats we now ask for 9 digits and for double, 17 decimal digits. Task-number: QTBUG-42574 Change-Id: Ic78beb60a218f75322f832d33d63fd84e7a65b65 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix QVariant associative container conversion from built-in types.Jędrzej Nowacki2014-10-241-0/+45
| | | | | | Task-number: QTBUG-41403 Change-Id: I9dab0f9450cac11678eb6d20abd2dd08e86e0900 Reviewed-by: Stephen Kelly <steveire@gmail.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* QVariant::compare shouldn't return match when QVariant::cmp does notAllan Sandfeld Jensen2014-09-111-0/+30
| | | | | | | | | | | | | | If the types doesn't match in QVariant::compare we do a comparison based on QString, this may end up indicating a full match, though the we don't match according to cmp. In this case it would be better if we preserved the non-matching to avoid breaking ordering. [ChangeLog][QtCore][QVariant] Fixed ordered comparison between QVariants that do not match but produce identical toString output. Task-number: QTBUG-40363 Change-Id: I84a8eca11e8875dba9948bde2906ae7c5aa35704 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix user defined conversions to numeric typesLars Knoll2014-09-101-0/+93
| | | | | | | | | The old code was completely broken. It did dereference val for user types, but val does in this case only contain garbage. Instead use the pointer to the correct data. Change-Id: I20ccf0bfa3dd3774c787d08c51cc8dd7b1ec9a1a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Mark QByteArrayList as metatype built-in type.Jędrzej Nowacki2014-08-281-16/+41
| | | | | | | As a side effects it also adds core templates types to the tests Change-Id: I0e3338e0bffdf21982aa83d404c83288e54411f4 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Update QVariant testsJędrzej Nowacki2014-07-101-4/+2
| | | | | | | | Remove old message handler hack as we have a new and better api to ignore warning messages. Change-Id: Id967b2672fe3e3638db9977500118a19c2afb730 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* QVariant: Convert automatically from enum types to integral types.Olivier Goffart2013-11-081-0/+84
| | | | | | | | | [ChangeLog][QtCore][QVariant] Variant containing enum types can now be converted to integer Change-Id: Ibbbc9ae29ab45d67c582fa2d406afc19c5dc41ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix QVariant::canConvert with longlongOlivier Goffart2013-11-081-3/+26
| | | | | | | | | | | Add few cases where conversion to or from LongLong was missing We need to make it work if we want to use variant.canConvert<qint64> [ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert with longlong Change-Id: I0f65073802b62d99250601dd90a8cd2e4d934b60 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Revert 15da0a5af20fe6771bcb94ef8d46edbd5c8fb64c.Mitch Curtis2013-09-191-2/+2
| | | | | | | | | | It apparently breaks users' applications. Task-number: QTBUG-33487 Change-Id: Iaeceb3a02b5c7b9ab839c14693aaffcdf9394bc6 Reviewed-by: John Layt <jlayt@kde.org> Reviewed-by: hjk <hjk121@nokiamail.com>
* MetaType: Add assignment operator to the container iterators.Stephen Kelly2013-09-191-16/+5
| | | | | Change-Id: Ib4f2197a0ab6bd41c91de667cd3087fb40e44097 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Fix operator{++,--}(int) with the type-erased const_iterators.Stephen Kelly2013-09-171-0/+30
| | | | | | | | | | Similar to commit 8b062418 (MetaType: Fix operator{+,-}(int) with the type-erased const_iterators., 2013-09-11), explicitly create a copy of the iterator and intialise it. Change-Id: I8b9edef40ca00c826f72768cba4a0992e55371f8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* MetaType: Fix operator{+,-}(int) with the type-erased const_iterators.Stephen Kelly2013-09-131-0/+30
| | | | | | | | Make sure we don't modify the lhs. Instead copy it and advance the copy. Change-Id: I3440e8e175bfc299f8f83b816faca54fa3f79e43 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add a convenient way to get a type-erased smart pointer from a QVariant.Stephen Kelly2013-09-111-0/+53
| | | | | | | | | | | | Any known smart pointer in a QVariant can be handled in this way. The metatype system can be informed of new smart pointer types using an existing macro which is now documented. This is very similar to the existing infrastructure for containers. Change-Id: Iac4f9fabbc5a0626c04e1185d51d720b8b54603d Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add a simple test for QVariant carrying a QSharedPointer<QObject>Thiago Macieira2013-09-111-0/+36
| | | | | Change-Id: Ibe17355c7ed8d4af7fda6261d72cfd64779471a7 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Metatype: Remove the need for runtime-registration of 3rd party containers.Stephen Kelly2013-09-091-13/+15
| | | | | | | | | Replace that need with a macro so that registration of the container helper conversions is done at the time of registration of the container (usually when it is put into a QVariant). Change-Id: I823fb3fdbce306ebc9f146675ac43724cec678d5 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make the automatic 1arg and 2arg metatype macros work with namespaced Qt.Stephen Kelly2013-09-061-0/+25
| | | | | Change-Id: I64aa3cacd0cf57235ad43f089716765b384ef412 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix the automatic declaration of smart pointer types.Stephen Kelly2013-09-061-0/+26
| | | | | | | | | | | | Before this patch, qRegisterMetaType<QSharedPointer<double> >("QSharedPointer<double>") without a metatype declaration fails to compile, whereas it works with Qt 5.1 (ie, before commit e9a69c3ba928bd88974563b386b000ad6583f969) Change-Id: I9408f711c9df810ff29b879b7696dab81c1160f1 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* QVariant: Make it possible to extract a QObject* from a wrapper without ↵Stephen Kelly2013-09-051-0/+1
| | | | | | | conversion. Change-Id: I3a054d87d12e08d72dd4c77b6d467dc63f9a2231 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QVariant: Don't crash when doing user-defined conversion to QObject*Stephen Kelly2013-09-051-0/+36
| | | | | | | | | The destructor of the ConverterFunctor calls unregisterConverter. If the instance is static (as it is in qmetatype.h), then this method can be called after the QGlobalStatic has already been destroyed. Change-Id: I33b70734cbe09dfa888e887280c349e43ad1b855 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-06-201-0/+42
|\ | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp tools/configure/configureapp.cpp Change-Id: I3092bd3276af14304b7ab3ae1e1cc05d11cdede0
| * Add basic conversion functions from QVariant(QJsonValue).Jędrzej Nowacki2013-06-141-0/+42
| | | | | | | | | | | | | | | | There is a mismatch how QML and C++ converts QJsonValue. This patch unifies conversions by adding QJsonValue support in QVariant::convert(). Change-Id: I8a1db3d77c517945ef48064b4b66ba03aa4f2fd0 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* | Make QTime::toString output milliseconds for Qt::TextDate, Qt::ISODate.Mitch Curtis2013-06-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Section 4.2.2.4 of ISO 8601 allows for decimal fraction representations of dates and times. Currently, when calling QDateTime::toString(Qt::TextDate) or QDateTime::toString(Qt::ISODate), the milliseconds will be omitted. However, QDateTime::fromString(str, Qt::TextDate) and QDateTime::fromString(str, Qt::ISODate) already support decimal fraction representations, so this patch just adds this support to QTime::toString, and hence QDateTime::toString(). Task-number: QTBUG-30250 Change-Id: If58e4b3d3105322c51d11a76b832e5e634d8991f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Make it possible to access QPair and std::pair elements from a QVariant.Stephen Kelly2013-05-201-0/+28
| | | | | | | | | | Change-Id: I9dc73748073d0d1e43bdadbce73339dfcc1bc647 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | Add container access functionality for associative containers in QVariant.Stephen Kelly2013-05-201-0/+85
| | | | | | | | | | Change-Id: I4763a4c157e52918a0a68cba63624c0649aca235 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Add automatic container access registration for built-in containers.Stephen Kelly2013-05-081-19/+0
| | | | | | | | | | Change-Id: I4d590c23e072994930922ff73367600f848fbcf0 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* | Add QVariantList extraction from a QVariant with a sequential container.Stephen Kelly2013-05-081-0/+51
| | | | | | | | | | Change-Id: Id9fac7bf47ed3fbb385222b25941215ac24b8b88 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Add QVariant container iteration API.Stephen Kelly2013-05-081-0/+165
|/ | | | | | | | | | | | | | | | | | A new set of classes is introduced for iterating over the contents of a container within a QVariant without knowing the exact type of the container, but with the guarantee that the element type within the container is a metatype. The implementation of the iterable interface uses the stl-compatible container API so that we can also iterate over stl containers, or any other container which also conforms to stl norms. This enables the functionality in the bug report. Task-number: QTBUG-23566 Change-Id: I92a2f3458516de201b8f0e470982c4d030e8ac8b Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* tests: Fix some more old references and links to NokiaSergio Ahumada2013-02-011-1/+1
| | | | | | | Task-number: QTBUG-28156 Change-Id: Ifb768b167203c901c5e42ce58c9aaf3db2739320 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QVariant streaming in Qt3 compatibility mode.Jędrzej Nowacki2012-11-241-0/+40
| | | | | | Task-number: QTBUG-27700 Change-Id: I0408293e43c3330dbc4746198a19709e795f552a Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>