File indexing completed on 2024-02-18 03:56:48

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #include <QTest>
0009 #include <kio/global.h>
0010 
0011 class KIOUpUrlTest : public QObject
0012 {
0013     Q_OBJECT
0014 private Q_SLOTS:
0015     void upUrl_data();
0016     void upUrl();
0017 };
0018 
0019 void KIOUpUrlTest::upUrl_data()
0020 {
0021     QTest::addColumn<QString>("url");
0022     QTest::addColumn<QString>("upUrl");
0023 
0024     QTest::newRow("empty") << ""
0025                            << "";
0026     QTest::newRow("ref") << "file:/home/dfaure/my#myref"
0027                          << "file:///home/dfaure/";
0028     QTest::newRow("qt2") << "file:/opt/kde2/qt2/doc/html/showimg-main-cpp.html#QObject::connect"
0029                          << "file:///opt/kde2/qt2/doc/html/";
0030     QTest::newRow("query") << "http://www.kde.org/cgi/test.cgi?hello:My Value"
0031                            << "http://www.kde.org/cgi/test.cgi";
0032     QTest::newRow("ftp1") << "ftp://user%40host.com@ftp.host.com/var/www/"
0033                           << "ftp://user%40host.com@ftp.host.com/var/";
0034     QTest::newRow("ftp2") << "ftp://user%40host.com@ftp.host.com/var/"
0035                           << "ftp://user%40host.com@ftp.host.com/";
0036     QTest::newRow("ftp3") << "ftp://user%40host.com@ftp.host.com/"
0037                           << "ftp://user%40host.com@ftp.host.com/"; // unchanged
0038     QTest::newRow("relative") << "tmp"
0039                               << ""; // Going up from a relative url is not supported (#170695)
0040 }
0041 
0042 void KIOUpUrlTest::upUrl()
0043 {
0044     QFETCH(QString, url);
0045     QFETCH(QString, upUrl);
0046 
0047     QCOMPARE(KIO::upUrl(QUrl(url)).toString(), upUrl);
0048 }
0049 
0050 QTEST_MAIN(KIOUpUrlTest)
0051 
0052 #include "upurltest.moc"