diff options
Diffstat (limited to 'tests/auto/corelib/tools')
4 files changed, 113 insertions, 9 deletions
diff --git a/tests/auto/corelib/tools/qlocale/qlocale.pro b/tests/auto/corelib/tools/qlocale/qlocale.pro index abbe31d1ef..5161200260 100644 --- a/tests/auto/corelib/tools/qlocale/qlocale.pro +++ b/tests/auto/corelib/tools/qlocale/qlocale.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs -SUBDIRS += test \ - syslocaleapp +SUBDIRS += test +!winrt: SUBDIRS+=syslocaleapp diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 4777030dd7..d9004d1eb6 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -17,4 +17,4 @@ win32 { } } -TEST_HELPER_INSTALLS = ../syslocaleapp/syslocaleapp +!winrt: TEST_HELPER_INSTALLS = ../syslocaleapp/syslocaleapp diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index d88a70c1e5..76341db701 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -95,18 +95,18 @@ private slots: void creatingQObject(); void mixTrackingPointerCode(); void reentrancyWhileDestructing(); + void map(); + void hash(); + void qvariantCast(); + void sharedFromThis(); void threadStressTest_data(); void threadStressTest(); - void map(); - void hash(); void validConstructs(); void invalidConstructs_data(); void invalidConstructs(); - - void qvariantCast(); - void sharedFromThis(); - + // let invalidConstructs be the last test, because it's the slowest; + // add new tests above this block public slots: void cleanup() { safetyCheck(); } @@ -232,6 +232,14 @@ void tst_QSharedPointer::basics() QCOMPARE(sizeof(weakref), 2*sizeof(void*)); } + { + QSharedPointer<const Data> ptr; + QWeakPointer<const Data> weakref; + + QCOMPARE(sizeof(ptr), 2*sizeof(void*)); + QCOMPARE(sizeof(weakref), 2*sizeof(void*)); + } + QFETCH(bool, isNull); Data *aData = 0; if (!isNull) @@ -2232,6 +2240,16 @@ void tst_QSharedPointer::sharedFromThis() QVERIFY(const_scp.isNull()); QCOMPARE(Data::generationCounter, generations + 1); QCOMPARE(Data::destructorCounter, destructions); + + QWeakPointer<SomeClass> wcp = sc.sharedFromThis(); + QVERIFY(wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); + + QWeakPointer<const SomeClass> const_wcp = sc.sharedFromThis(); + QVERIFY(const_wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); } QCOMPARE(Data::generationCounter, generations + 1); @@ -2243,6 +2261,11 @@ void tst_QSharedPointer::sharedFromThis() QVERIFY(const_scp.isNull()); QCOMPARE(Data::generationCounter, generations + 2); QCOMPARE(Data::destructorCounter, destructions + 1); + + QWeakPointer<const SomeClass> const_wcp = sc.sharedFromThis(); + QVERIFY(const_wcp.isNull()); + QCOMPARE(Data::generationCounter, generations + 2); + QCOMPARE(Data::destructorCounter, destructions + 1); } QCOMPARE(Data::generationCounter, generations + 2); @@ -2434,6 +2457,21 @@ void tst_QSharedPointer::sharedFromThis() QCOMPARE(Data::generationCounter, generations + 5); QCOMPARE(Data::destructorCounter, destructions + 5); + + { + QSharedPointer<const SomeClass> scp2(new SomeClass()); + QVERIFY(!scp2.isNull()); + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 5); + + QWeakPointer<const SomeClass> wcp2(scp2.constCast<SomeClass>()); + QVERIFY(!wcp2.isNull()); + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 5); + } + + QCOMPARE(Data::generationCounter, generations + 6); + QCOMPARE(Data::destructorCounter, destructions + 6); } namespace ReentrancyWhileDestructing { diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 9556dfbd51..f8a4d8a00a 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -583,6 +583,7 @@ private slots: void compareQLatin1Strings(); void fromQLatin1StringWithLength(); void assignQLatin1String(); + void assignQChar(); void isRightToLeft_data(); void isRightToLeft(); void unicodeStrings(); @@ -6623,6 +6624,71 @@ void tst_QString::assignQLatin1String() QCOMPARE(foo.size(), latin1subfoo.size()); QCOMPARE(foo, QString::fromLatin1("foo")); + // check capacity re-use: + QString s; + QCOMPARE(s.capacity(), 0); + + // assign to null QString: + s = latin1foo; + QCOMPARE(s, QString::fromLatin1("foo")); + QCOMPARE(s.capacity(), 3); + + // assign to non-null QString with enough capacity: + s = QString::fromLatin1("foofoo"); + const int capacity = s.capacity(); + s = latin1foo; + QCOMPARE(s, QString::fromLatin1("foo")); + QCOMPARE(s.capacity(), capacity); + + // assign to shared QString (enough capacity, but can't use): + s = QString::fromLatin1("foofoo"); + QString s2 = s; + s = latin1foo; + QCOMPARE(s, QString::fromLatin1("foo")); + QCOMPARE(s.capacity(), 3); + + // assign to QString with too little capacity: + s = QString::fromLatin1("fo"); + QCOMPARE(s.capacity(), 2); + s = latin1foo; + QCOMPARE(s, QString::fromLatin1("foo")); + QCOMPARE(s.capacity(), 3); + +} + +void tst_QString::assignQChar() +{ + const QChar sp = QLatin1Char(' '); + QString s; + QCOMPARE(s.capacity(), 0); + + // assign to null QString: + s = sp; + QCOMPARE(s, QString(sp)); + QCOMPARE(s.capacity(), 1); + + // assign to non-null QString with enough capacity: + s = QLatin1String("foo"); + const int capacity = s.capacity(); + QCOMPARE(capacity, 3); + s = sp; + QCOMPARE(s, QString(sp)); + QCOMPARE(s.capacity(), capacity); + + // assign to shared QString (enough capacity, but can't use): + s = QLatin1String("foo"); + QString s2 = s; + s = sp; + QCOMPARE(s, QString(sp)); + QCOMPARE(s.capacity(), 1); + + // assign to empty QString: + s = QString(""); + s.detach(); + QCOMPARE(s.capacity(), 0); + s = sp; + QCOMPARE(s, QString(sp)); + QCOMPARE(s.capacity(), 1); } void tst_QString::isRightToLeft_data() |