summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp35
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp10
-rw-r--r--tests/auto/corelib/tools/qarraydata/simplevector.h2
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp30
-rw-r--r--tests/auto/corelib/tools/qhash/tst_qhash.cpp2
-rw-r--r--tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp4
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp6
-rw-r--r--tests/auto/corelib/tools/qmap/tst_qmap.cpp4
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp22
9 files changed, 79 insertions, 36 deletions
diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
index 802bbe9963..8b1aa105de 100644
--- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
+++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp
@@ -27,14 +27,18 @@
****************************************************************************/
#include <QtTest/QtTest>
-
#include <QStorageInfo>
+#include <stdarg.h>
+
+#include "../../../../manual/qstorageinfo/printvolumes.cpp"
+
class tst_QStorageInfo : public QObject
{
Q_OBJECT
private slots:
void defaultValues();
+ void dump();
void operatorEqual();
#ifndef Q_OS_WINRT
void operatorNotEqual();
@@ -61,6 +65,33 @@ void tst_QStorageInfo::defaultValues()
QCOMPARE(storage.bytesAvailable(), -1);
}
+static int qInfoPrinter(const char *format, ...)
+{
+ static char buf[1024];
+ static size_t bufuse = 0;
+
+ va_list ap;
+ va_start(ap, format); // use variable arg list
+ int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap);
+ va_end(ap);
+
+ bufuse += n;
+ if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') {
+ // flush
+ QtMessageHandler qt_message_print = qInstallMessageHandler(0);
+ qInstallMessageHandler(qt_message_print); // restore the handler
+ qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf));
+ bufuse = 0;
+ }
+
+ return 1;
+}
+
+void tst_QStorageInfo::dump()
+{
+ printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter);
+}
+
void tst_QStorageInfo::operatorEqual()
{
{
@@ -157,6 +188,7 @@ void tst_QStorageInfo::tempFile()
#endif
qint64 free = storage1.bytesFree();
+ QVERIFY(free != -1);
file.write(QByteArray(1024*1024, '1'));
file.flush();
@@ -180,6 +212,7 @@ void tst_QStorageInfo::caching()
qint64 free = storage1.bytesFree();
QStorageInfo storage2(storage1);
QCOMPARE(free, storage2.bytesFree());
+ QVERIFY(free != -1);
file.write(QByteArray(1024*1024, '\0'));
file.flush();
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 7f6e26eecb..262d8ad44b 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -4659,6 +4659,16 @@ template<typename Enum> void testVariant(Enum value, bool *ok)
QVERIFY(var2.convert(QMetaType::Int));
QCOMPARE(var2.value<int>(), static_cast<int>(value));
+ if (static_cast<qint64>(value) <= INT_MAX) {
+ int intValue = static_cast<int>(value);
+ QVariant intVar = intValue;
+ QVERIFY(intVar.canConvert<Enum>());
+ QCOMPARE(intVar.value<Enum>(), value);
+ }
+ qint64 longValue = static_cast<qint64>(value);
+ QVERIFY(QVariant(longValue).canConvert<Enum>());
+ QCOMPARE(QVariant(longValue).value<Enum>(), value);
+
*ok = true;
}
diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h
index 90e86dca4e..9dd8b05796 100644
--- a/tests/auto/corelib/tools/qarraydata/simplevector.h
+++ b/tests/auto/corelib/tools/qarraydata/simplevector.h
@@ -88,7 +88,7 @@ public:
bool isStatic() const { return d->ref.isStatic(); }
bool isShared() const { return d->ref.isShared(); }
bool isSharedWith(const SimpleVector &other) const { return d == other.d; }
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
bool isSharable() const { return d->ref.isSharable(); }
void setSharable(bool sharable) { d.setSharable(sharable); }
#endif
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 0732a55063..0c41f66357 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -39,7 +39,7 @@ struct SharedNullVerifier
{
Q_ASSERT(QArrayData::shared_null[0].ref.isStatic());
Q_ASSERT(QArrayData::shared_null[0].ref.isShared());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
Q_ASSERT(QArrayData::shared_null[0].ref.isSharable());
#endif
}
@@ -96,7 +96,7 @@ void tst_QArrayData::referenceCounting()
QCOMPARE(array.ref.atomic.load(), 1);
QVERIFY(!array.ref.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(array.ref.isSharable());
#endif
@@ -118,7 +118,7 @@ void tst_QArrayData::referenceCounting()
// Now would be a good time to free/release allocated data
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
// Reference counting initialized to 0 (non-sharable)
QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 };
@@ -146,7 +146,7 @@ void tst_QArrayData::referenceCounting()
QCOMPARE(array.ref.atomic.load(), -1);
QVERIFY(array.ref.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(array.ref.isSharable());
#endif
@@ -173,7 +173,7 @@ void tst_QArrayData::sharedNullEmpty()
QCOMPARE(null->ref.atomic.load(), -1);
QCOMPARE(empty->ref.atomic.load(), -1);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(null->ref.isSharable());
QVERIFY(empty->ref.isSharable());
#endif
@@ -304,7 +304,7 @@ void tst_QArrayData::simpleVector()
QVERIFY(!v7.isShared());
QVERIFY(!v8.isShared());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v1.isSharable());
QVERIFY(v2.isSharable());
QVERIFY(v3.isSharable());
@@ -497,7 +497,7 @@ void tst_QArrayData::simpleVector()
for (int i = 0; i < 120; ++i)
QCOMPARE(v1[i], v8[i % 10]);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
v7.setSharable(true);
QVERIFY(v7.isSharable());
@@ -667,7 +667,7 @@ void tst_QArrayData::allocate_data()
QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0);
QVERIFY(shared_empty);
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable);
QVERIFY(unsharable_empty);
#endif
@@ -681,7 +681,7 @@ void tst_QArrayData::allocate_data()
} options[] = {
{ "Default", QArrayData::Default, false, true, shared_empty },
{ "Reserved", QArrayData::CapacityReserved, true, true, shared_empty },
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{ "Reserved | Unsharable",
QArrayData::CapacityReserved | QArrayData::Unsharable, true, false,
unsharable_empty },
@@ -731,7 +731,7 @@ void tst_QArrayData::allocate()
else
QCOMPARE(data->alloc, uint(capacity));
QCOMPARE(data->capacityReserved, uint(isCapacityReserved));
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(bool, isSharable);
QCOMPARE(data->ref.isSharable(), isSharable);
#endif
@@ -1311,7 +1311,7 @@ static inline bool arrayIsFilledWith(const QArrayDataPointer<int> &array,
void tst_QArrayData::setSharable_data()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QTest::addColumn<QArrayDataPointer<int> >("array");
QTest::addColumn<size_t>("size");
QTest::addColumn<size_t>("capacity");
@@ -1357,7 +1357,7 @@ void tst_QArrayData::setSharable_data()
void tst_QArrayData::setSharable()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(QArrayDataPointer<int>, array);
QFETCH(size_t, size);
QFETCH(size_t, capacity);
@@ -1487,7 +1487,7 @@ void fromRawData_impl()
QVERIFY((const T *)raw.constBegin() != array);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
{
// Immutable, unsharable
SimpleVector<T> raw = SimpleVector<T>::fromRawData(array,
@@ -1573,7 +1573,7 @@ void tst_QArrayData::literals()
QVERIFY(v.isStatic());
#endif
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v.isSharable());
#endif
QCOMPARE((void*)(const char*)(v.constBegin() + v.size()), (void*)(const char*)v.constEnd());
@@ -1624,7 +1624,7 @@ void tst_QArrayData::variadicLiterals()
QVERIFY(v.isStatic());
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QVERIFY(v.isSharable());
#endif
QCOMPARE((const int *)(v.constBegin() + v.size()), (const int *)v.constEnd());
diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
index 4336d02b2c..06ff09dc6c 100644
--- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp
+++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp
@@ -1188,7 +1188,7 @@ void tst_QHash::noNeedlessRehashes()
void tst_QHash::const_shared_null()
{
QHash<int, QString> hash2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QHash<int, QString> hash1;
hash1.setSharable(false);
QVERIFY(hash1.isDetached());
diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
index 4c4cb4879b..f17d6695f0 100644
--- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
+++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp
@@ -1022,7 +1022,7 @@ template<typename T>
void tst_QLinkedList::constSharedNull() const
{
QLinkedList<T> list2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QLinkedList<T> list1;
list1.setSharable(false);
QVERIFY(list1.isDetached());
@@ -1054,7 +1054,7 @@ void tst_QLinkedList::constSharedNullComplex() const
void tst_QLinkedList::setSharableInt() const
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QLinkedList<int> orglist;
orglist << 0 << 1 << 2 << 3 << 4 << 5;
int size = 6;
diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index bae8ece303..b3f8130d27 100644
--- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -1887,7 +1887,7 @@ template<typename T>
void tst_QList::constSharedNull() const
{
QList<T> list2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QList<T> list1;
list1.setSharable(false);
QVERIFY(list1.isDetached());
@@ -1921,7 +1921,7 @@ void tst_QList::constSharedNullComplex() const
template <class T>
void generateSetSharableData()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QTest::addColumn<QList<T> >("list");
QTest::addColumn<int>("size");
@@ -1933,7 +1933,7 @@ void generateSetSharableData()
template <class T>
void runSetSharableTest()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QFETCH(QList<T>, list);
QFETCH(int, size);
diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
index 0898c10ea6..8aa7a3e518 100644
--- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp
+++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp
@@ -1007,7 +1007,7 @@ void tst_QMap::qmultimap_specific()
void tst_QMap::const_shared_null()
{
QMap<int, QString> map2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QMap<int, QString> map1;
map1.setSharable(false);
QVERIFY(map1.isDetached());
@@ -1104,7 +1104,7 @@ const T &const_(const T &t)
void tst_QMap::setSharable()
{
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
QMap<int, QString> map;
map.insert(1, "um");
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index eb37d6b8e6..825cb05d74 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -426,7 +426,7 @@ void tst_QVector::copyConstructor() const
QVector<T> v2(v1);
QCOMPARE(v1, v2);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v1;
@@ -590,7 +590,7 @@ void tst_QVector::append() const
QVERIFY(v.size() == 3);
QCOMPARE(v.at(v.size() - 1), SimpleValue<T>::at(0));
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v(2);
@@ -926,7 +926,7 @@ void tst_QVector::eraseEmpty() const
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v;
@@ -965,7 +965,7 @@ void tst_QVector::eraseEmptyReserved() const
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v;
@@ -1081,7 +1081,7 @@ void tst_QVector::erase(bool shared) const
if (shared)
QCOMPARE(SimpleValue<T>::vector(12), *svc.copy);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v = SimpleValue<T>::vector(10);
@@ -1168,7 +1168,7 @@ template<typename T> void tst_QVector::eraseReserved() const
v.erase(v.begin() + 1, v.end() - 1);
QCOMPARE(v.size(), 2);
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
{
QVector<T> v(10);
@@ -1903,7 +1903,7 @@ void tst_QVector::resizePOD_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<int> nullNotShared;
QVector<int> emptyNotShared(0, 5);
@@ -1978,7 +1978,7 @@ void tst_QVector::resizeComplexMovable_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<Movable> nullNotShared;
QVector<Movable> emptyNotShared(0, 'Q');
@@ -2057,7 +2057,7 @@ void tst_QVector::resizeComplex_data() const
QTest::newRow("nonEmpty") << nonEmpty << 10;
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<Custom> nullNotShared;
QVector<Custom> emptyNotShared(0, '0');
@@ -2498,7 +2498,7 @@ void tst_QVector::initializeListCustom()
void tst_QVector::const_shared_null()
{
QVector<int> v2;
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
QVector<int> v1;
v1.setSharable(false);
@@ -2509,7 +2509,7 @@ void tst_QVector::const_shared_null()
QVERIFY(!v2.isDetached());
}
-#if QT_SUPPORTS(UNSHARABLE_CONTAINERS)
+#if !defined(QT_NO_UNSHARABLE_CONTAINERS)
// ### Qt6 remove this section
template<typename T>
void tst_QVector::setSharable_data() const