diff options
Diffstat (limited to 'tests/auto/corelib')
5 files changed, 189 insertions, 20 deletions
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 5af1353a0f..70bda1a0ef 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -3885,12 +3885,17 @@ void tst_QVariant::moreCustomTypes() PLAY_WITH_VARIANT(data, false, QString(), 0, false); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { QList<QLinkedList<int> > data; PLAY_WITH_VARIANT(data, false, QString(), 0, false); data << (QLinkedList<int>() << 42); PLAY_WITH_VARIANT(data, false, QString(), 0, false); } +QT_WARNING_POP +#endif } void tst_QVariant::movabilityTest() diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index aed84cb14e..ff2e98e730 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -3064,39 +3064,45 @@ void tst_QDataStream::status_QHash_QMap() } \ } \ { \ - LinkedList expectedLinkedList; \ + Vector expectedVector; \ for (int i = 0; i < expectedList.count(); ++i) \ - expectedLinkedList << expectedList.at(i); \ + expectedVector << expectedList.at(i); \ QByteArray ba = byteArray; \ QDataStream stream(&ba, QIODevice::ReadOnly); \ if (inTransaction) \ stream.startTransaction(); \ stream.setStatus(initialStatus); \ - stream >> linkedList; \ + stream >> vector; \ QCOMPARE((int)stream.status(), (int)expectedStatus); \ if (!inTransaction || stream.commitTransaction()) { \ - QCOMPARE(linkedList.size(), expectedLinkedList.size()); \ - QCOMPARE(linkedList, expectedLinkedList); \ + QCOMPARE(vector.size(), expectedVector.size()); \ + QCOMPARE(vector, expectedVector); \ } else { \ - QVERIFY(linkedList.isEmpty()); \ + QVERIFY(vector.isEmpty()); \ } \ } \ + if (inTransaction) \ + break; \ + } + +#define LINKED_LIST_TEST(byteArray, initialStatus, expectedStatus, expectedList) \ + for (bool inTransaction = false;; inTransaction = true) { \ { \ - Vector expectedVector; \ + LinkedList expectedLinkedList; \ for (int i = 0; i < expectedList.count(); ++i) \ - expectedVector << expectedList.at(i); \ + expectedLinkedList << expectedList.at(i); \ QByteArray ba = byteArray; \ QDataStream stream(&ba, QIODevice::ReadOnly); \ if (inTransaction) \ stream.startTransaction(); \ stream.setStatus(initialStatus); \ - stream >> vector; \ + stream >> linkedList; \ QCOMPARE((int)stream.status(), (int)expectedStatus); \ if (!inTransaction || stream.commitTransaction()) { \ - QCOMPARE(vector.size(), expectedVector.size()); \ - QCOMPARE(vector, expectedVector); \ + QCOMPARE(linkedList.size(), expectedLinkedList.size()); \ + QCOMPARE(linkedList, expectedLinkedList); \ } else { \ - QVERIFY(vector.isEmpty()); \ + QVERIFY(linkedList.isEmpty()); \ } \ } \ if (inTransaction) \ @@ -3105,10 +3111,8 @@ void tst_QDataStream::status_QHash_QMap() void tst_QDataStream::status_QLinkedList_QList_QVector() { - typedef QLinkedList<QString> LinkedList; typedef QList<QString> List; typedef QVector<QString> Vector; - LinkedList linkedList; List list; Vector vector; @@ -3155,6 +3159,61 @@ void tst_QDataStream::status_QLinkedList_QList_QVector() LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::ReadCorruptData, QDataStream::ReadCorruptData, List()); LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, List()); } + +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + // The same as above with QLinkedList + + typedef QLinkedList<QString> LinkedList; + LinkedList linkedList; + + // ok + { + List listWithEmptyString; + listWithEmptyString.append(""); + + List someList; + someList.append("J"); + someList.append("MN"); + + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x00", 4), QDataStream::Ok, QDataStream::Ok, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::Ok, QDataStream::Ok, listWithEmptyString); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x02\x00J" + "\x00\x00\x00\x04\x00M\x00N", 18), QDataStream::Ok, QDataStream::Ok, someList); + } + + // past end + { + LINKED_LIST_TEST(QByteArray(), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00", 1), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00", 2), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00", 3), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + for (int i = 4; i < 12; ++i) { + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00", i), QDataStream::Ok, QDataStream::ReadPastEnd, List()); + } + } + + // corrupt data + { + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::Ok, QDataStream::ReadCorruptData, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x02\x00\x00\x00\x01\x00J" + "\x00\x00\x00\x02\x00M\x00N", 18), QDataStream::Ok, QDataStream::ReadCorruptData, List()); + } + + // test the previously latched error status is not affected by reading + { + List listWithEmptyString; + listWithEmptyString.append(""); + + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x00", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, listWithEmptyString); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01", 4), QDataStream::ReadCorruptData, QDataStream::ReadCorruptData, List()); + LINKED_LIST_TEST(QByteArray("\x00\x00\x00\x01\x00\x00\x00\x01", 8), QDataStream::ReadPastEnd, QDataStream::ReadPastEnd, List()); + } + +QT_WARNING_POP +#endif } void tst_QDataStream::streamToAndFromQByteArray() diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index e79a4dba29..ec519ad362 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -96,7 +96,9 @@ private slots: void typeinfo(); void qstring(); void list(); +#if QT_DEPRECATED_SINCE(5, 15) void linkedList(); +#endif void vector(); void byteArray(); void stack(); @@ -109,7 +111,9 @@ private slots: #endif void pair(); void sharableQList(); +#if QT_DEPRECATED_SINCE(5, 15) void sharableQLinkedList(); +#endif void sharableQVector(); void sharableQMap(); void sharableQHash(); @@ -121,8 +125,10 @@ private slots: void vector_stl(); void list_stl_data(); void list_stl(); +#if QT_DEPRECATED_SINCE(5, 15) void linkedlist_stl_data(); void linkedlist_stl(); +#endif void q_init(); void pointersize(); void containerInstantiation(); @@ -736,8 +742,11 @@ void tst_Collections::list() } } +#if QT_DEPRECATED_SINCE(5, 15) void tst_Collections::linkedList() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { QLinkedList<int> list; QVERIFY(list.isEmpty()); @@ -955,7 +964,9 @@ void tst_Collections::linkedList() QCOMPARE(a.endsWith(1), false); QCOMPARE(a.endsWith(2), true); } +QT_WARNING_POP }; +#endif void tst_Collections::vector() @@ -2330,11 +2341,16 @@ void populate(QList<int> &container) container << 1 << 2 << 4 << 8; } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template <> void populate(QLinkedList<int> &container) { container << 1 << 2 << 4 << 8; } +QT_WARNING_POP +#endif template <> void populate(QVector<int> &container) @@ -2431,10 +2447,15 @@ void tst_Collections::sharableQList() TEST_SEQUENTIAL_CONTAINER(List); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_Collections::sharableQLinkedList() { TEST_SEQUENTIAL_CONTAINER(LinkedList); } +QT_WARNING_POP +#endif void tst_Collections::sharableQVector() { @@ -2755,7 +2776,12 @@ void tst_Collections::constAndNonConstStlIterators() { testListLikeStlIterators<QList<int> >(); testListLikeStlIterators<QStringList >(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED testLinkedListLikeStlIterators<QLinkedList<int> >(); +QT_WARNING_POP +#endif testListLikeStlIterators<QVector<int> >(); testMapLikeStlIterators<QMap<QString, QString> >(); testMapLikeStlIterators<QMultiMap<QString, QString> >(); @@ -2798,6 +2824,7 @@ void tst_Collections::vector_stl() QCOMPARE(QVector<QString>(stdVector.begin(), stdVector.end()), vector); } +#if QT_DEPRECATED_SINCE(5, 15) void tst_Collections::linkedlist_stl_data() { list_stl_data(); @@ -2805,6 +2832,8 @@ void tst_Collections::linkedlist_stl_data() void tst_Collections::linkedlist_stl() { +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QFETCH(QStringList, elements); QLinkedList<QString> list; @@ -2821,7 +2850,9 @@ void tst_Collections::linkedlist_stl() QCOMPARE(*it, *it2); QCOMPARE(QLinkedList<QString>::fromStdList(stdList), list); +QT_WARNING_POP } +#endif void tst_Collections::list_stl_data() { @@ -3070,6 +3101,10 @@ void tst_Collections::containerInstantiation() typedef QSet<EqualsComparable> Set; instantiateAssociative<Set, EqualsComparable>(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + //Instantiate QLinkedList member functions. typedef QLinkedList<EqualsComparable> LinkedList; instantiateSequence<LinkedList, EqualsComparable> (); @@ -3078,6 +3113,8 @@ void tst_Collections::containerInstantiation() LinkedList list; list.removeAll(value); } +QT_WARNING_POP +#endif //Instantiate QList member functions. typedef QList<EqualsComparable> List; @@ -3185,7 +3222,12 @@ void tst_Collections::containerTypedefs() testContainerTypedefs(QVector<int>()); testContainerTypedefs(QStack<int>()); testContainerTypedefs(QList<int>()); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED testContainerTypedefs(QLinkedList<int>()); +QT_WARNING_POP +#endif testContainerTypedefs(QQueue<int>()); testPairAssociativeContainerTypedefs(QMap<int, int>()); @@ -3207,7 +3249,12 @@ void tst_Collections::forwardDeclared() { typedef QMultiMap<Key1, T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QPair<T1, T2> C; C *x = 0; Q_UNUSED(x) } { typedef QList<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED { typedef QLinkedList<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } +QT_WARNING_POP +#endif { typedef QVector<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) Q_UNUSED(i) Q_UNUSED(j) } { typedef QStack<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) Q_UNUSED(i) Q_UNUSED(j) } { typedef QQueue<T1> C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } @@ -3441,7 +3488,12 @@ void tst_Collections::QTBUG13079_collectionInsideCollection() QTBUG13079_collectionInsideCollectionImpl<QVector>(); QTBUG13079_collectionInsideCollectionImpl<QStack>(); QTBUG13079_collectionInsideCollectionImpl<QList>(); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QTBUG13079_collectionInsideCollectionImpl<QLinkedList>(); +QT_WARNING_POP +#endif QTBUG13079_collectionInsideCollectionImpl<QQueue>(); { diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp index 88c0c5055c..2c7c8f6514 100644 --- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp +++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp @@ -324,11 +324,12 @@ private Q_SLOTS: #endif } - void ranged_ctor_QLinkedList_int() { ranged_ctor_non_associative_impl<QLinkedList<int>>(); } - void ranged_ctor_QLinkedList_Movable() { ranged_ctor_non_associative_impl<QLinkedList<Movable>>(); } - void ranged_ctor_QLinkedList_Complex() { ranged_ctor_non_associative_impl<QLinkedList<Complex>>(); } - void ranged_ctor_QLinkedList_duplicates_strategy() { non_associative_container_duplicates_strategy<QLinkedList>(); } - +#if QT_DEPRECATED_SINCE(5, 15) + void ranged_ctor_QLinkedList_int(); + void ranged_ctor_QLinkedList_Movable(); + void ranged_ctor_QLinkedList_Complex(); + void ranged_ctor_QLinkedList_duplicates_strategy(); +#endif void ranged_ctor_std_set_int() { ranged_ctor_non_associative_impl<std::set<int>>(); } void ranged_ctor_std_set_Movable() { ranged_ctor_non_associative_impl<std::set<Movable>>(); } void ranged_ctor_std_set_Complex() { ranged_ctor_non_associative_impl<std::set<Complex>>(); } @@ -482,7 +483,9 @@ private Q_SLOTS: void front_back_std_vector() { front_back_impl<std::vector<int>>(); } void front_back_QVector() { front_back_impl<QVector<int>>(); } void front_back_QList() { front_back_impl<QList<qintptr>>(); } - void front_back_QLinkedList() { front_back_impl<QLinkedList<int>>(); } +#if QT_DEPRECATED_SINCE(5, 15) + void front_back_QLinkedList(); +#endif void front_back_QVarLengthArray() { front_back_impl<QVarLengthArray<int>>(); } void front_back_QString() { front_back_impl<QString>(); } void front_back_QStringRef() { front_back_impl<QStringRef>(); } @@ -590,8 +593,13 @@ template<typename ... T> struct ContainerDuplicatedValuesStrategy<std::forward_list<T...>> : ContainerAcceptsDuplicateValues {}; #endif +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template<typename ... T> struct ContainerDuplicatedValuesStrategy<QLinkedList<T...>> : ContainerAcceptsDuplicateValues {}; +QT_WARNING_POP +#endif // assuming https://cplusplus.github.io/LWG/lwg-active.html#2844 resolution template<typename ... T> @@ -819,5 +827,35 @@ void tst_ContainerApiSymmetry::front_back_impl() const QCOMPARE(clean(qAsConst(c2).back()), V(2)); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_int() +{ + ranged_ctor_non_associative_impl<QLinkedList<int>>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_Movable() +{ + ranged_ctor_non_associative_impl<QLinkedList<Movable>>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_Complex() +{ + ranged_ctor_non_associative_impl<QLinkedList<Complex>>(); +} + +void tst_ContainerApiSymmetry::ranged_ctor_QLinkedList_duplicates_strategy() +{ + non_associative_container_duplicates_strategy<QLinkedList>(); +} + +void tst_ContainerApiSymmetry::front_back_QLinkedList() +{ + front_back_impl<QLinkedList<int>>(); +} +QT_WARNING_POP +#endif + QTEST_APPLESS_MAIN(tst_ContainerApiSymmetry) #include "tst_containerapisymmetry.moc" diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index df42b5dea9..b681676d09 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -29,6 +29,10 @@ #include <QtTest/QtTest> #include <QLinkedList> +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + struct Movable { Movable(char input = 'j') : i(input), state(Constructed) @@ -1129,5 +1133,16 @@ void tst_QLinkedList::setSharableInt() const #endif } +QT_WARNING_POP +#else +class tst_QLinkedList : public QObject +{ + Q_OBJECT +private slots: + void initTestCase() { QSKIP("Deprecated APIs are disabled, skipping this test."); } +}; + +#endif // QT_DEPRECATED_SINCE(5, 15) + QTEST_APPLESS_MAIN(tst_QLinkedList) #include "tst_qlinkedlist.moc" |