summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp15
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp25
2 files changed, 32 insertions, 8 deletions
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index 9271630b32..231f37fa05 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -77,16 +77,15 @@ void tst_QIODevice::getSetCheck()
{
// OpenMode QIODevice::openMode()
// void QIODevice::setOpenMode(OpenMode)
- class MyIODevice : public QIODevice {
+ class MyIODevice : public QTcpSocket {
public:
- void setOpenMode(OpenMode openMode) { QIODevice::setOpenMode(openMode); }
+ using QTcpSocket::setOpenMode;
};
- QTcpSocket var1;
- MyIODevice *obj1 = reinterpret_cast<MyIODevice*>(&var1);
- obj1->setOpenMode(QIODevice::OpenMode(QIODevice::NotOpen));
- QCOMPARE(QIODevice::OpenMode(QIODevice::NotOpen), obj1->openMode());
- obj1->setOpenMode(QIODevice::OpenMode(QIODevice::ReadWrite));
- QCOMPARE(QIODevice::OpenMode(QIODevice::ReadWrite), obj1->openMode());
+ MyIODevice var1;
+ var1.setOpenMode(QIODevice::OpenMode(QIODevice::NotOpen));
+ QCOMPARE(QIODevice::OpenMode(QIODevice::NotOpen), var1.openMode());
+ var1.setOpenMode(QIODevice::OpenMode(QIODevice::ReadWrite));
+ QCOMPARE(QIODevice::OpenMode(QIODevice::ReadWrite), var1.openMode());
}
//----------------------------------------------------------------------------------
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 07257297e0..390794d806 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -69,6 +69,8 @@ private slots:
void resolving();
void toString_data();
void toString();
+ void toString_PreferLocalFile_data();
+ void toString_PreferLocalFile();
void toString_constructed_data();
void toString_constructed();
void toAndFromStringList_data();
@@ -1050,6 +1052,29 @@ void tst_QUrl::toString()
QCOMPARE(url.adjusted(opt).toString(), string);
}
+void tst_QUrl::toString_PreferLocalFile_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("string");
+
+#ifdef Q_OS_WIN
+ QTest::newRow("win-drive") << QUrl(QString::fromLatin1("file:///c:/windows/regedit.exe"))
+ << QString::fromLatin1("c:/windows/regedit.exe");
+ QTest::newRow("win-share") << QUrl(QString::fromLatin1("//Anarki/homes"))
+ << QString::fromLatin1("//anarki/homes");
+#else
+ QTest::newRow("unix-path") << QUrl(QString::fromLatin1("file:///tmp"))
+ << QString::fromLatin1("/tmp");
+#endif
+}
+
+void tst_QUrl::toString_PreferLocalFile()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, string);
+
+ QCOMPARE(url.toString(QUrl::PreferLocalFile), string);
+}
void tst_QUrl::toAndFromStringList_data()
{