File indexing completed on 2022-10-04 14:00:20

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2014 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
0004 //
0005 
0006 #include <QTest>
0007 
0008 #include "routing/RouteRequest.h"
0009 #include "GeoDataPlacemark.h"
0010 
0011 namespace Marble
0012 {
0013 
0014 class RouteRequestTest : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 private Q_SLOTS:
0019     void defaultConstructor();
0020     void reverse();
0021 };
0022 
0023 void RouteRequestTest::defaultConstructor()
0024 {
0025     const RouteRequest request;
0026 
0027     QCOMPARE( request.size(), 0 );
0028     QCOMPARE( request.source(), GeoDataCoordinates() );
0029     QCOMPARE( request.destination(), GeoDataCoordinates() );
0030     QCOMPARE( request.routingProfile(), RoutingProfile() );
0031 }
0032 
0033 void RouteRequestTest::reverse()
0034 {
0035     {
0036         RouteRequest request;
0037         request.reverse(); // should not crash
0038         QCOMPARE( request.size(), 0 );
0039     }
0040 
0041     {
0042         RouteRequest request;
0043         request.append( GeoDataCoordinates(), "A" );
0044         request.reverse();
0045         QCOMPARE( request.size(), 1 );
0046         QCOMPARE( request[0].name(), QString("A") );
0047     }
0048 
0049     {
0050         RouteRequest request;
0051         request.append( GeoDataCoordinates(), "A" );
0052         request.append( GeoDataCoordinates(), "B" );
0053         request.reverse();
0054         QCOMPARE( request.size(), 2 );
0055         QCOMPARE( request[0].name(), QString("B") );
0056         QCOMPARE( request[1].name(), QString("A") );
0057     }
0058 
0059     {
0060         RouteRequest request;
0061         request.append( GeoDataCoordinates(), "A" );
0062         request.append( GeoDataCoordinates(), "B" );
0063         request.append( GeoDataCoordinates(), "C" );
0064         request.reverse();
0065         QCOMPARE( request.size(), 3 );
0066         QCOMPARE( request[0].name(), QString("C") );
0067         QCOMPARE( request[1].name(), QString("B") );
0068         QCOMPARE( request[2].name(), QString("A") );
0069     }
0070 }
0071 
0072 }
0073 
0074 QTEST_MAIN( Marble::RouteRequestTest )
0075 
0076 #include "RouteRequestTest.moc"