File indexing completed on 2024-04-21 03:50:41

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
0004 //
0005 
0006 #include "GeoDataPoint.h"
0007 #include "GeoDataLinearRing.h"
0008 
0009 #include <QObject>
0010 #include <QTest>
0011 
0012 using namespace Marble;
0013 
0014 
0015 class TestGeoDataGeometry : public QObject
0016 {
0017     Q_OBJECT
0018 private Q_SLOTS:
0019     void downcastPointTest_data();
0020     void downcastPointTest();
0021     void deleteAndDetachTest1();
0022     void deleteAndDetachTest2();
0023     void deleteAndDetachTest3();
0024 };
0025 
0026 void TestGeoDataGeometry::downcastPointTest_data()
0027 {
0028     QTest::addColumn<GeoDataPoint>("point");
0029 
0030     GeoDataPoint point1;
0031     point1.setCoordinates( GeoDataCoordinates(.5, .2, 100) );
0032     QTest::newRow("First") << point1;
0033 }
0034 
0035 void TestGeoDataGeometry::downcastPointTest()
0036 {
0037     QFETCH(GeoDataPoint, point);
0038 
0039     QVERIFY( ! point.coordinates().toString().isEmpty() );
0040 
0041     GeoDataCoordinates tmp( point.coordinates() );
0042     GeoDataPoint newPoint( tmp );
0043 
0044     QCOMPARE( newPoint.coordinates().toString(), point.coordinates().toString() );
0045 }
0046 
0047 /**
0048  * Test passes if the program does not crash
0049  */
0050 void TestGeoDataGeometry::deleteAndDetachTest1()
0051 {
0052     GeoDataLineString line1;
0053     line1 << GeoDataCoordinates();
0054     line1.toRangeCorrected();
0055     GeoDataLineString line2 = line1;
0056     line2 << GeoDataCoordinates();
0057 }
0058 
0059 /**
0060  * Test passes if the program does not crash
0061  */
0062 void TestGeoDataGeometry::deleteAndDetachTest2()
0063 {
0064     GeoDataLineString line1;
0065     line1 << GeoDataCoordinates();
0066     GeoDataLineString line2 = line1;
0067     line1.toRangeCorrected();
0068     line2 << GeoDataCoordinates();
0069 }
0070 
0071 /**
0072  * Test passes if the program does not crash
0073  */
0074 void TestGeoDataGeometry::deleteAndDetachTest3()
0075 {
0076     GeoDataLineString line1;
0077     line1 << GeoDataCoordinates();
0078     GeoDataLineString line2 = line1;
0079     line2.toRangeCorrected();
0080     line2 << GeoDataCoordinates();
0081 }
0082 
0083 QTEST_MAIN( TestGeoDataGeometry )
0084 #include "TestGeoDataGeometry.moc"
0085