From 1e432f0a88b25098819fc9684b54606ba3a05123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 4 May 2012 15:19:17 +0200 Subject: Introduce a new built-in type: signed char. C++ distinguish between "char", "signed char" and "unsigned char", they are three independent types. Fix QVariant behavior on ARM. On ARM "char" may mean "unsigned char", but we depends on the sign during a numerical conversions. Change-Id: I610ce3fb88ed5964b67f3ae442d264fe16b2d261 Reviewed-by: Thiago Macieira --- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp') diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 569e448d88..47392a35a5 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -605,9 +605,18 @@ void tst_QVariant::canConvert_data() var = QVariant((uint)1); QTest::newRow("UInt") << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; + var = QVariant((int)1); + QTest::newRow("Int") + << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << Y << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; var = QVariant((qulonglong)1); QTest::newRow("ULongLong") << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; + var = QVariant::fromValue('a'); + QTest::newRow("Char") + << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; + var = QVariant::fromValue(-1); + QTest::newRow("SChar") + << var << N << N << Y << N << Y << N << N << N << N << Y << N << N << Y << N << N << N << Y << N << N << N << N << N << N << N << N << N << Y << N << N << Y << Y; #undef N #undef Y @@ -696,6 +705,9 @@ void tst_QVariant::toInt_data() QTest::newRow( "invalid" ) << QVariant() << 0 << false; QTest::newRow( "int" ) << QVariant( 123 ) << 123 << true; + QTest::newRow( "char" ) << QVariant::fromValue('a') << int('a') << true; + signed char signedChar = -13; + QTest::newRow( "signed char" ) << QVariant::fromValue(signedChar) << -13 << true; QTest::newRow( "double" ) << QVariant( 3.1415927 ) << 3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << 3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << 123 << true; @@ -744,6 +756,9 @@ void tst_QVariant::toUInt_data() QTest::addColumn("valueOK"); QTest::newRow( "int" ) << QVariant( 123 ) << (uint)123 << true; + QTest::newRow( "char" ) << QVariant::fromValue('a') << uint('a') << true; + signed char signedChar = 12; + QTest::newRow( "signed char" ) << QVariant::fromValue(signedChar) << uint(12) << true; QTest::newRow( "double" ) << QVariant( 3.1415927 ) << (uint)3 << true; QTest::newRow( "float" ) << QVariant( 3.1415927f ) << (uint)3 << true; QTest::newRow( "uint" ) << QVariant( 123u ) << (uint)123 << true; @@ -1710,8 +1725,16 @@ void tst_QVariant::writeToReadFromOldDataStream() void tst_QVariant::checkDataStream() { - QTest::ignoreMessage(QtWarningMsg, "Trying to construct an instance of an invalid type, type id: 49"); - const QByteArray settingsHex("00000031ffffffffff"); + const int typeId = QMetaType::LastCoreType + 1; + QVERIFY(!QMetaType::isRegistered(typeId)); + + QByteArray errorMessage("Trying to construct an instance of an invalid type, type id: "); + errorMessage.append(QString::number(typeId, 10)); + + QTest::ignoreMessage(QtWarningMsg, errorMessage.constData()); + QByteArray settingsHex("000000"); + settingsHex.append(QString::number(typeId, 16)); + settingsHex.append("ffffffffff"); const QByteArray settings = QByteArray::fromHex(settingsHex); QDataStream in(settings); QVariant v; -- cgit v1.2.3