File: upurltest.cpp

package info (click to toggle)
kio 5.116.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,496 kB
  • sloc: cpp: 123,468; xml: 528; ansic: 466; ruby: 60; sh: 21; makefile: 13
file content (52 lines) | stat: -rw-r--r-- 1,716 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
    This file is part of the KDE libraries
    SPDX-FileCopyrightText: 2013 David Faure <faure@kde.org>

    SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#include <QTest>
#include <kio/global.h>

class KIOUpUrlTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void upUrl_data();
    void upUrl();
};

void KIOUpUrlTest::upUrl_data()
{
    QTest::addColumn<QString>("url");
    QTest::addColumn<QString>("upUrl");

    QTest::newRow("empty") << ""
                           << "";
    QTest::newRow("ref") << "file:/home/dfaure/my#myref"
                         << "file:///home/dfaure/";
    QTest::newRow("qt2") << "file:/opt/kde2/qt2/doc/html/showimg-main-cpp.html#QObject::connect"
                         << "file:///opt/kde2/qt2/doc/html/";
    QTest::newRow("query") << "http://www.kde.org/cgi/test.cgi?hello:My Value"
                           << "http://www.kde.org/cgi/test.cgi";
    QTest::newRow("ftp1") << "ftp://user%40host.com@ftp.host.com/var/www/"
                          << "ftp://user%40host.com@ftp.host.com/var/";
    QTest::newRow("ftp2") << "ftp://user%40host.com@ftp.host.com/var/"
                          << "ftp://user%40host.com@ftp.host.com/";
    QTest::newRow("ftp3") << "ftp://user%40host.com@ftp.host.com/"
                          << "ftp://user%40host.com@ftp.host.com/"; // unchanged
    QTest::newRow("relative") << "tmp"
                              << ""; // Going up from a relative url is not supported (#170695)
}

void KIOUpUrlTest::upUrl()
{
    QFETCH(QString, url);
    QFETCH(QString, upUrl);

    QCOMPARE(KIO::upUrl(QUrl(url)).toString(), upUrl);
}

QTEST_MAIN(KIOUpUrlTest)

#include "upurltest.moc"