diff options
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r-- | tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp | 57 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp | 28 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlist/qlist.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlist/tst_qlist.cpp | 28 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qpoint/tst_qpoint.cpp | 7 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qpointf/tst_qpointf.cpp | 7 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qset/qset.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qset/tst_qset.cpp | 28 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qsize/tst_qsize.cpp | 44 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qsizef/tst_qsizef.cpp | 44 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qtimeline/BLACKLIST | 4 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 29 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvector/qvector.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvector/tst_qvector.cpp | 28 |
16 files changed, 311 insertions, 3 deletions
diff --git a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp index d19eac7530..9a7c099228 100644 --- a/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp +++ b/tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp @@ -84,6 +84,8 @@ private slots: void operator_noteq(); void resize(); + void fromBits_data(); + void fromBits(); }; void tst_QBitArray::size_data() @@ -610,5 +612,60 @@ void tst_QBitArray::resize() } +void tst_QBitArray::fromBits_data() +{ + QTest::addColumn<QByteArray>("data"); + QTest::addColumn<int>("size"); + QTest::addColumn<QBitArray>("expected"); + + QTest::newRow("empty") << QByteArray() << 0 << QBitArray(); + + auto add = [](const QByteArray &tag, const char *data) { + QTest::newRow(tag) << QByteArray(data, (tag.size() + 7) / 8) << tag.size() + << QStringToQBitArray(tag); + }; + + // "0" to "0000000000000000" + for (int i = 1; i < 16; ++i) { + char zero[2] = { 0, 0 }; + QByteArray pattern(i, '0'); + add(pattern, zero); + } + + // "1" to "1111111111111111" + for (int i = 1; i < 16; ++i) { + char one[2] = { '\xff', '\xff' }; + QByteArray pattern(i, '1'); + add(pattern, one); + } + + // trailing 0 and 1 + char zero = 1; + char one = 0; + QByteArray pzero = "1"; + QByteArray pone = "0"; + for (int i = 2; i < 8; ++i) { + zero <<= 1; + pzero.prepend('0'); + add(pzero, &zero); + + one = (one << 1) | 1; + pone.prepend('1'); + add(pone, &one); + } +} + +void tst_QBitArray::fromBits() +{ + QFETCH(QByteArray, data); + QFETCH(int, size); + QFETCH(QBitArray, expected); + + QBitArray fromBits = QBitArray::fromBits(data, size); + QCOMPARE(fromBits, expected); + + QCOMPARE(QBitArray::fromBits(fromBits.bits(), fromBits.size()), expected); +} + QTEST_APPLESS_MAIN(tst_QBitArray) #include "tst_qbitarray.moc" diff --git a/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro b/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro index 378c574eb0..c53d553d6d 100644 --- a/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro +++ b/tests/auto/corelib/tools/qlinkedlist/qlinkedlist.pro @@ -1,5 +1,7 @@ CONFIG += testcase TARGET = tst_qlinkedlist QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = tst_qlinkedlist.cpp DEFINES -= QT_NO_LINKED_LIST diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index deb3b68c5c..df42b5dea9 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -187,6 +187,7 @@ private slots: void countInt() const; void countMovable() const; void countComplex() const; + void cpp17ctad() const; void emptyInt() const; void emptyMovable() const; void emptyComplex() const; @@ -594,6 +595,33 @@ void tst_QLinkedList::countComplex() const QCOMPARE(liveCount, Complex::getLiveCount()); } +void tst_QLinkedList::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_LIST_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QLinkedList<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QLinkedList v1 = {One, Two, Three}; \ + QVERIFY_IS_LIST_OF(v1, Type); \ + QLinkedList v2(v1.begin(), v1.end()); \ + QVERIFY_IS_LIST_OF(v2, Type); \ + QLinkedList v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_LIST_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_LIST_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + template<typename T> void tst_QLinkedList::empty() const { diff --git a/tests/auto/corelib/tools/qlist/qlist.pro b/tests/auto/corelib/tools/qlist/qlist.pro index 47f0140abb..118c607880 100644 --- a/tests/auto/corelib/tools/qlist/qlist.pro +++ b/tests/auto/corelib/tools/qlist/qlist.pro @@ -1,4 +1,6 @@ CONFIG += testcase TARGET = tst_qlist QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = $$PWD/tst_qlist.cpp diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 5a485e88d2..cc9a3a16d1 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -310,6 +310,7 @@ private slots: void lastComplex() const; void constFirst() const; void constLast() const; + void cpp17ctad() const; void beginOptimal() const; void beginMovable() const; void beginComplex() const; @@ -864,6 +865,33 @@ void tst_QList::constLast() const QVERIFY(listCopy.isSharedWith(list)); } +void tst_QList::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_LIST_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QList v1 = {One, Two, Three}; \ + QVERIFY_IS_LIST_OF(v1, Type); \ + QList v2(v1.begin(), v1.end()); \ + QVERIFY_IS_LIST_OF(v2, Type); \ + QList v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_LIST_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_LIST_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + template<typename T> void tst_QList::last() const { diff --git a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp index 8e184f3ef3..f25492d2db 100644 --- a/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp +++ b/tests/auto/corelib/tools/qpoint/tst_qpoint.cpp @@ -42,6 +42,8 @@ private slots: void getSet_data(); void getSet(); + void transposed(); + void rx(); void ry(); @@ -126,6 +128,11 @@ void tst_QPoint::getSet() QCOMPARE(point.y(), i); } +void tst_QPoint::transposed() +{ + QCOMPARE(QPoint(1, 2).transposed(), QPoint(2, 1)); +} + void tst_QPoint::rx() { const QPoint originalPoint(-1, 0); diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp index d4ccdf7ba6..e78a8e3082 100644 --- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp +++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp @@ -46,6 +46,8 @@ private slots: void getSet_data(); void getSet(); + void transposed(); + void rx(); void ry(); @@ -154,6 +156,11 @@ void tst_QPointF::getSet() QCOMPARE(point.y(), r); } +void tst_QPointF::transposed() +{ + QCOMPARE(QPointF(1, 2).transposed(), QPointF(2, 1)); +} + void tst_QPointF::rx() { const QPointF originalPoint(-1, 0); diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro index d0c6337147..3ae4bc4805 100644 --- a/tests/auto/corelib/tools/qset/qset.pro +++ b/tests/auto/corelib/tools/qset/qset.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qset QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = tst_qset.cpp DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 31b4c0449e..8a545712a2 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -54,6 +54,7 @@ private slots: void detach(); void isDetached(); void clear(); + void cpp17ctad(); void remove(); void contains(); void containsSet(); @@ -325,6 +326,33 @@ void tst_QSet::clear() QVERIFY(set2.size() == 0); } +void tst_QSet::cpp17ctad() +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_SET_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QSet<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QSet v1 = {One, Two, Three}; \ + QVERIFY_IS_SET_OF(v1, Type); \ + QSet v2(v1.begin(), v1.end()); \ + QVERIFY_IS_SET_OF(v2, Type); \ + QSet v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_SET_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_SET_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + void tst_QSet::remove() { QSet<QString> set1; diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp index 385ff18ce5..6824bad9c8 100644 --- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp +++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <qsize.h> +Q_DECLARE_METATYPE(QMargins) class tst_QSize : public QObject { @@ -43,6 +44,9 @@ private slots: void boundedTo_data(); void boundedTo(); + void grownOrShrunkBy_data(); + void grownOrShrunkBy(); + void transpose_data(); void transpose(); }; @@ -186,6 +190,46 @@ void tst_QSize::boundedTo() QCOMPARE( input1.boundedTo(input2), expected); } +void tst_QSize::grownOrShrunkBy_data() +{ + QTest::addColumn<QSize>("input"); + QTest::addColumn<QMargins>("margins"); + QTest::addColumn<QSize>("grown"); + QTest::addColumn<QSize>("shrunk"); + + auto row = [](QSize i, QMargins m, QSize g, QSize s) { + QTest::addRow("{%d,%d}/{%d,%d,%d,%d}", i.width(), i.height(), + m.left(), m.top(), m.right(), m.bottom()) + << i << m << g << s; + }; + + const QSize zero = {0, 0}; + const QSize some = {100, 200}; + const QMargins zeroMargins = {}; + const QMargins negative = {-1, -2, -3, -4}; + const QMargins positive = { 1, 2, 3, 4}; + + row(zero, zeroMargins, zero, zero); + row(zero, negative, {-4, -6}, { 4, 6}); + row(zero, positive, { 4, 6}, {-4, -6}); + row(some, zeroMargins, some, some); + row(some, negative, { 96, 194}, {104, 206}); + row(some, positive, {104, 206}, { 96, 194}); +} + +void tst_QSize::grownOrShrunkBy() +{ + QFETCH(const QSize, input); + QFETCH(const QMargins, margins); + QFETCH(const QSize, grown); + QFETCH(const QSize, shrunk); + + QCOMPARE(input.grownBy(margins), grown); + QCOMPARE(input.shrunkBy(margins), shrunk); + QCOMPARE(grown.shrunkBy(margins), input); + QCOMPARE(shrunk.grownBy(margins), input); +} + void tst_QSize::transpose_data() { QTest::addColumn<QSize>("input1"); diff --git a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp index 42801d63a9..bbffa74a62 100644 --- a/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp +++ b/tests/auto/corelib/tools/qsizef/tst_qsizef.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <qsize.h> +Q_DECLARE_METATYPE(QMarginsF) class tst_QSizeF : public QObject { @@ -45,6 +46,9 @@ private slots: void boundedTo_data(); void boundedTo(); + void grownOrShrunkBy_data(); + void grownOrShrunkBy(); + void transpose_data(); void transpose(); }; @@ -152,6 +156,46 @@ void tst_QSizeF::boundedTo() { QCOMPARE( input1.boundedTo(input2), expected); } +void tst_QSizeF::grownOrShrunkBy_data() +{ + QTest::addColumn<QSizeF>("input"); + QTest::addColumn<QMarginsF>("margins"); + QTest::addColumn<QSizeF>("grown"); + QTest::addColumn<QSizeF>("shrunk"); + + auto row = [](QSizeF i, QMarginsF m, QSizeF g, QSizeF s) { + QTest::addRow("{%g,%g}/{%g,%g,%g,%g}", i.width(), i.height(), + m.left(), m.top(), m.right(), m.bottom()) + << i << m << g << s; + }; + + const QSizeF zero = {0, 0}; + const QSizeF some = {100, 200}; + const QMarginsF zeroMargins = {}; + const QMarginsF negative = {-1, -2, -3, -4}; + const QMarginsF positive = { 1, 2, 3, 4}; + + row(zero, zeroMargins, zero, zero); + row(zero, negative, {-4, -6}, { 4, 6}); + row(zero, positive, { 4, 6}, {-4, -6}); + row(some, zeroMargins, some, some); + row(some, negative, { 96, 194}, {104, 206}); + row(some, positive, {104, 206}, { 96, 194}); +} + +void tst_QSizeF::grownOrShrunkBy() +{ + QFETCH(const QSizeF, input); + QFETCH(const QMarginsF, margins); + QFETCH(const QSizeF, grown); + QFETCH(const QSizeF, shrunk); + + QCOMPARE(input.grownBy(margins), grown); + QCOMPARE(input.shrunkBy(margins), shrunk); + QCOMPARE(grown.shrunkBy(margins), input); + QCOMPARE(shrunk.grownBy(margins), input); +} + void tst_QSizeF::transpose_data() { QTest::addColumn<QSizeF>("input1"); QTest::addColumn<QSizeF>("expected"); diff --git a/tests/auto/corelib/tools/qtimeline/BLACKLIST b/tests/auto/corelib/tools/qtimeline/BLACKLIST index b60cab31fa..9794b0059f 100644 --- a/tests/auto/corelib/tools/qtimeline/BLACKLIST +++ b/tests/auto/corelib/tools/qtimeline/BLACKLIST @@ -1,8 +1,6 @@ [interpolation] -osx-10.12 windows-10 msvc-2015 -osx-10.13 -windows-7sp1 +osx [frameRate] osx-10.12 osx-10.13 diff --git a/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro b/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro index 108fb33db5..14b2bc213b 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro +++ b/tests/auto/corelib/tools/qvarlengtharray/qvarlengtharray.pro @@ -1,4 +1,6 @@ CONFIG += testcase TARGET = tst_qvarlengtharray QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = tst_qvarlengtharray.cpp diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 3d90644aa3..a1d0100f96 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -44,6 +44,7 @@ private slots: void realloc(); void reverseIterators(); void count(); + void cpp17ctad(); void first(); void last(); void squeeze(); @@ -717,6 +718,34 @@ void tst_QVarLengthArray::count() } } +void tst_QVarLengthArray::cpp17ctad() +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_VLA_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QVarLengthArray<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QVarLengthArray v1 = {One, Two, Three}; \ + QVERIFY_IS_VLA_OF(v1, Type); \ + QVarLengthArray v2(v1.begin(), v1.end()); \ + QVERIFY_IS_VLA_OF(v2, Type); \ + QVarLengthArray v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_VLA_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_VLA_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif + +} + void tst_QVarLengthArray::first() { // append some items, make sure it stays sane diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qvector/qvector.pro index b9a4ae747b..689d9b87a2 100644 --- a/tests/auto/corelib/tools/qvector/qvector.pro +++ b/tests/auto/corelib/tools/qvector/qvector.pro @@ -1,5 +1,7 @@ CONFIG += testcase qtConfig(c++11): CONFIG += c++11 +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z TARGET = tst_qvector QT = core testlib SOURCES = $$PWD/tst_qvector.cpp diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 05b5579d64..08d5a8cd50 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -230,6 +230,7 @@ private slots: void countInt() const; void countMovable() const; void countCustom() const; + void cpp17ctad() const; void data() const; void emptyInt() const; void emptyMovable() const; @@ -914,6 +915,33 @@ void tst_QVector::countCustom() const QCOMPARE(instancesCount, Custom::counter.loadAcquire()); } +void tst_QVector::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_VECTOR_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QVector<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QVector v1 = {One, Two, Three}; \ + QVERIFY_IS_VECTOR_OF(v1, Type); \ + QVector v2(v1.begin(), v1.end()); \ + QVERIFY_IS_VECTOR_OF(v2, Type); \ + QVector v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_VECTOR_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_VECTOR_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + void tst_QVector::data() const { QVector<int> myvec; |