File: GeoUriParserTest.cpp

package info (click to toggle)
marble 4%3A25.08.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 159,996 kB
  • sloc: cpp: 191,890; xml: 39,908; ansic: 7,204; python: 2,190; sh: 1,187; makefile: 235; perl: 218; ruby: 97; java: 66
file content (78 lines) | stat: -rw-r--r-- 2,707 bytes parent folder | download | duplicates (2)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// SPDX-FileCopyrightText: 2014 Levente Kurusa <levex@linux.com>
//

#include "GeoUriParser.h"
#include "TestUtils.h"
#include <QString>

namespace Marble
{

class GeoUriParserTest : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void testGeoUri_data();
    void testGeoUri();
};

void GeoUriParserTest::testGeoUri_data()
{
    QTest::addColumn<QString>("uri");
    QTest::addColumn<bool>("valid");
    QTest::addColumn<double>("lat");
    QTest::addColumn<double>("lon");
    QTest::addColumn<double>("alt");

    // geo: URI tests
    addRow() << "geo:-25.0064,153.359,250" << true << -25.0064 << 153.359 << 250.00;
    addRow() << "geo:-25.0064153.359250" << false << 0.00 << 0.00 << 0.00;
    addRow() << "geo-25.0064,153.359,250" << false << 0.00 << 0.00 << 0.00;
    addRow() << "geo:25.0064,-153.359,250" << true << 25.0064 << -153.359 << 250.00;
    addRow() << "25.0064,-153.359,250" << false << 0.00 << 0.00 << 0.00;
    addRow() << "geo:25.0064,-153.359" << true << 25.0064 << -153.359 << 00.00;
    addRow() << "geo:37.786971,-122.399677;u=35" << true << 37.786971 << -122.399677 << 0.00;
    addRow() << "geo:37.786971,-122.399677;crs=Moon-2011" << true << 37.786971 << -122.399677 << 0.00;
    addRow() << "geo:37.786971,-122.399677;crs=Moon-2011,u=25" << true << 37.786971 << -122.399677 << 0.00;

    // worldwind: URI tests
    addRow() << "worldwind://goto/world=Earth&lat=-43.54642&lon=172.69&alt=25883&bank=242&tilt=1&dir=2&layer=Hello" << true << -43.54642 << 172.69 << 25883.0;
    addRow() << "worldwind://goto/world=Earth&lat=-43.54642&lon=172.69" << true << -43.54642 << 172.69 << 0.0;
    addRow() << "worldwind://lat=-43.54642&lon=172.69&alt=25883" << false << 0.0 << 0.0 << 0.0;
    addRow() << "worldwind://goto/world=Earth&alt=25883" << true << 0.0 << 0.0 << 25883.0;
    addRow() << "goto/world=Earth&lat=-43.54642&lon=172.69&alt=25883" << false << 0.0 << 0.0 << 0.0;
    addRow() << "world=Earth&lat=-43.54642&lon=172.69&alt=25883&bank=242&tilt=1&dir=2&layer=Hello" << false << 0.0 << 0.0 << 0.0;
}

void GeoUriParserTest::testGeoUri()
{
    QFETCH(QString, uri);
    QFETCH(bool, valid);
    QFETCH(double, lat);
    QFETCH(double, lon);
    QFETCH(double, alt);

    GeoUriParser parser(uri);
    bool ret = parser.parse();

    GeoDataCoordinates coords = parser.coordinates();

    qreal cLat = 0.0, cLon = 0.0, cAlt = 0.0;
    coords.geoCoordinates(cLon, cLat, cAlt, GeoDataCoordinates::Degree);

    QCOMPARE(ret, valid);
    if (ret == valid) {
        QCOMPARE(cLat, lat);
        QCOMPARE(cLon, lon);
        QCOMPARE(cAlt, alt);
    }
}

}

QTEST_MAIN(Marble::GeoUriParserTest)

#include "GeoUriParserTest.moc"