1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
4 //
5 
6 #include "GeoDataPoint.h"
7 #include "GeoDataLinearRing.h"
8 
9 #include <QObject>
10 #include <QTest>
11 
12 using namespace Marble;
13 
14 
15 class TestGeoDataGeometry : public QObject
16 {
17     Q_OBJECT
18 private Q_SLOTS:
19     void downcastPointTest_data();
20     void downcastPointTest();
21     void deleteAndDetachTest1();
22     void deleteAndDetachTest2();
23     void deleteAndDetachTest3();
24 };
25 
downcastPointTest_data()26 void TestGeoDataGeometry::downcastPointTest_data()
27 {
28     QTest::addColumn<GeoDataPoint>("point");
29 
30     GeoDataPoint point1;
31     point1.setCoordinates( GeoDataCoordinates(.5, .2, 100) );
32     QTest::newRow("First") << point1;
33 }
34 
downcastPointTest()35 void TestGeoDataGeometry::downcastPointTest()
36 {
37     QFETCH(GeoDataPoint, point);
38 
39     QVERIFY( ! point.coordinates().toString().isEmpty() );
40 
41     GeoDataCoordinates tmp( point.coordinates() );
42     GeoDataPoint newPoint( tmp );
43 
44     QCOMPARE( newPoint.coordinates().toString(), point.coordinates().toString() );
45 }
46 
47 /**
48  * Test passes if the program does not crash
49  */
deleteAndDetachTest1()50 void TestGeoDataGeometry::deleteAndDetachTest1()
51 {
52     GeoDataLineString line1;
53     line1 << GeoDataCoordinates();
54     line1.toRangeCorrected();
55     GeoDataLineString line2 = line1;
56     line2 << GeoDataCoordinates();
57 }
58 
59 /**
60  * Test passes if the program does not crash
61  */
deleteAndDetachTest2()62 void TestGeoDataGeometry::deleteAndDetachTest2()
63 {
64     GeoDataLineString line1;
65     line1 << GeoDataCoordinates();
66     GeoDataLineString line2 = line1;
67     line1.toRangeCorrected();
68     line2 << GeoDataCoordinates();
69 }
70 
71 /**
72  * Test passes if the program does not crash
73  */
deleteAndDetachTest3()74 void TestGeoDataGeometry::deleteAndDetachTest3()
75 {
76     GeoDataLineString line1;
77     line1 << GeoDataCoordinates();
78     GeoDataLineString line2 = line1;
79     line2.toRangeCorrected();
80     line2 << GeoDataCoordinates();
81 }
82 
83 QTEST_MAIN( TestGeoDataGeometry )
84 #include "TestGeoDataGeometry.moc"
85 
86