From kde-commits Sun Oct 16 16:07:18 2016 From: Bernhard Beschow Date: Sun, 16 Oct 2016 16:07:18 +0000 To: kde-commits Subject: [marble] tests: compare against values, not strings Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=147663405126105 Git commit fe028258f0e57b3523cb5884bf280a49a497e86a by Bernhard Beschow. Committed on 16/10/2016 at 15:44. Pushed by beschow into branch 'master'. compare against values, not strings (cherry picked from commit 918fd3b7cf11d975c61a86ec22e7ecefb8f1f35a) M +61 -55 tests/TestGeoDataCopy.cpp http://commits.kde.org/marble/fe028258f0e57b3523cb5884bf280a49a497e86a diff --git a/tests/TestGeoDataCopy.cpp b/tests/TestGeoDataCopy.cpp index cb5e13f..629a73b 100644 --- a/tests/TestGeoDataCopy.cpp +++ b/tests/TestGeoDataCopy.cpp @@ -52,8 +52,6 @@ class TestGeoDataCopy : public QObject public: TestGeoDataCopy(); = - private: - void testCoordinate(GeoDataCoordinates coord, qreal alt, quint8 de= tail, QString coordtest ); private Q_SLOTS: void initTestCase(); // misc.: @@ -85,7 +83,6 @@ class TestGeoDataCopy : public QObject const GeoDataCoordinates coord1; const GeoDataCoordinates coord2; const GeoDataCoordinates coord3; - QStringList coordString; }; = TestGeoDataCopy::TestGeoDataCopy() : @@ -95,37 +92,20 @@ TestGeoDataCopy::TestGeoDataCopy() : { } = -void TestGeoDataCopy::testCoordinate( GeoDataCoordinates coord, qreal alt,= quint8 detail, QString coordtest ) -{ - QCOMPARE(coord.altitude(), alt); - QCOMPARE(coord.detail(), detail); - QCOMPARE(coord.toString(), coordtest); -} - void TestGeoDataCopy::initTestCase() { - QLocale::setDefault(QLocale::German); MarbleDirs::setMarbleDataPath( DATA_PATH ); MarbleDirs::setMarblePluginPath( PLUGIN_PATH ); - - coordString << QString::fromUtf8(" 13\u00B0 42' 38,5\"E, 51\u00B0 01'= 24,6\"N" ); - coordString << QString::fromUtf8(" 14\u00B0 42' 38,5\"E, 52\u00B0 01'= 24,6\"N" ); - coordString << QString::fromUtf8(" 15\u00B0 42' 38,5\"E, 53\u00B0 01'= 24,6\"N" ); - - testCoordinate(coord1, 123.4, 2, coordString[0]); - - testCoordinate(coord2, 133.4, 3, coordString[1]); - - testCoordinate(coord3, 143.4, 4, coordString[2]); } = void TestGeoDataCopy::copyCoordinates() { GeoDataCoordinates other =3D coord1; - = + // make sure that the coordinate contains the right values - testCoordinate(other, 123.4, 2, coordString[0]); - = + QCOMPARE(other, coord1); + QCOMPARE(other.detail(), coord1.detail()); + QVERIFY(coord1 =3D=3D other); } = @@ -137,17 +117,19 @@ void TestGeoDataCopy::copyPoint() point.setExtrude( true ); = // make sure that the coordinate contains the right values - testCoordinate(point.coordinates(), 123.4, 2, coordString[0]); + QCOMPARE(point.coordinates(), coord1); + QCOMPARE(point.coordinates().detail(), coord1.detail()); QCOMPARE(point.extrude(), true); = GeoDataPoint other =3D point; - = + // make sure that the coordinate contains the right values - testCoordinate(other.coordinates(), 123.4, 2, coordString[0]); + QCOMPARE(other.coordinates(), coord1); + QCOMPARE(other.coordinates().detail(), coord1.detail()); QCOMPARE(other.extrude(), true); - = + QVERIFY(point.coordinates() =3D=3D other.coordinates()); - = + point =3D GeoDataPoint( GeoDataCoordinates(13.7107, 51.0235, 123.4, Ge= oDataCoordinates::Degree, 17) ); point.setExtrude(false); QCOMPARE(other.coordinates().detail(), quint8(2)); @@ -160,7 +142,6 @@ void TestGeoDataCopy::copyLineString() { GeoDataLineString lineString; lineString.setTessellate(true); - = = lineString.append(coord1); lineString.append(coord2); @@ -170,8 +151,10 @@ void TestGeoDataCopy::copyLineString() GeoDataLineString other =3D lineString; QVERIFY(other.size() =3D=3D 3); = - testCoordinate(lineString.at(0), 123.4, 2, coordString[0]); - testCoordinate(other.at(2), 143.4, 4, coordString[2]); + QCOMPARE(lineString.at(0), coord1); + QCOMPARE(lineString.at(0).detail(), coord1.detail()); + QCOMPARE(other.at(2), coord3); + QCOMPARE(other.at(2).detail(), coord3.detail()); = QVERIFY(other.at(2) =3D=3D coord3); QVERIFY(other.tessellate()); @@ -192,8 +175,10 @@ void TestGeoDataCopy::copyLinearRing() GeoDataLinearRing other =3D linearRing; QVERIFY(other.size() =3D=3D 3); = - testCoordinate(linearRing.at(0), 123.4, 2, coordString[0]); - testCoordinate(other.at(2), 143.4, 4, coordString[2]); + QCOMPARE(linearRing.at(0), coord1); + QCOMPARE(linearRing.at(0).detail(), coord1.detail()); + QCOMPARE(other.at(2), coord3); + QCOMPARE(other.at(2).detail(), coord3.detail()); = QVERIFY(other.at(2) =3D=3D coord3); QVERIFY(other.tessellate()); @@ -350,19 +335,25 @@ void TestGeoDataCopy::copyDocument() QCOMPARE(document.size(), 3); QCOMPARE(other.size(), 3); = - testCoordinate(static_cast(other.child(0))->coordin= ate(), 143.4, 4, coordString[2]); - testCoordinate(static_cast(other.child(2))->coordin= ate(), 123.4, 2, coordString[0]); + QCOMPARE(static_cast(other.child(0))->coordinate(),= coord3); + QCOMPARE(static_cast(other.child(0))->coordinate().= detail(), coord3.detail()); + QCOMPARE(static_cast(other.child(2))->coordinate(),= coord1); + QCOMPARE(static_cast(other.child(2))->coordinate().= detail(), coord1.detail()); = GeoDataFolder *otherFolder =3D static_cast(other.child= (1)); - testCoordinate(static_cast(otherFolder->child(0))->= coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(otherFolder->child(1))->= coordinate(), 133.4, 3, coordString[1]); - testCoordinate(static_cast(otherFolder->child(2))->= coordinate(), 143.4, 4, coordString[2]); + QCOMPARE(static_cast(otherFolder->child(0))->coordi= nate(), coord1); + QCOMPARE(static_cast(otherFolder->child(0))->coordi= nate().detail(), coord1.detail()); + QCOMPARE(static_cast(otherFolder->child(1))->coordi= nate(), coord2); + QCOMPARE(static_cast(otherFolder->child(1))->coordi= nate().detail(), coord2.detail()); + QCOMPARE(static_cast(otherFolder->child(2))->coordi= nate(), coord3); + QCOMPARE(static_cast(otherFolder->child(2))->coordi= nate().detail(), coord3.detail()); = other.append(new GeoDataPlacemark(pl1)); = QCOMPARE(document.size(), 3); QCOMPARE(other.size(), 4); - testCoordinate(static_cast(other.child(3))->coordin= ate(), 123.4, 2, coordString[0]); + QCOMPARE(static_cast(other.child(3))->coordinate(),= coord1); + QCOMPARE(static_cast(other.child(3))->coordinate().= detail(), coord1.detail()); } = void TestGeoDataCopy::copyFolder() @@ -390,15 +381,19 @@ void TestGeoDataCopy::copyFolder() QCOMPARE(other.child(1)->parent(), &other); QEXPECT_FAIL("", "FIXME", Continue); QCOMPARE(other.child(2)->parent(), &other); - testCoordinate(static_cast(other.child(0))->coordin= ate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(other.child(1))->coordin= ate(), 133.4, 3, coordString[1]); - testCoordinate(static_cast(other.child(2))->coordin= ate(), 143.4, 4, coordString[2]); + QCOMPARE(static_cast(other.child(0))->coordinate(),= coord1); + QCOMPARE(static_cast(other.child(0))->coordinate().= detail(), coord1.detail()); + QCOMPARE(static_cast(other.child(1))->coordinate(),= coord2); + QCOMPARE(static_cast(other.child(1))->coordinate().= detail(), coord2.detail()); + QCOMPARE(static_cast(other.child(2))->coordinate(),= coord3); + QCOMPARE(static_cast(other.child(2))->coordinate().= detail(), coord3.detail()); = other.append(new GeoDataPlacemark(pl1)); = QCOMPARE(folder.size(), 3); QCOMPARE(other.size(), 4); - testCoordinate(static_cast(other.child(3))->coordin= ate(), 123.4, 2, coordString[0]); + QCOMPARE(static_cast(other.child(3))->coordinate(),= coord1); + QCOMPARE(static_cast(other.child(3))->coordinate().= detail(), coord1.detail()); } = void TestGeoDataCopy::copyPlacemark() @@ -407,7 +402,8 @@ void TestGeoDataCopy::copyPlacemark() point->setExtrude( true ); = // make sure that the coordinate contains the right values - testCoordinate(point->coordinates(), 123.4, 2, coordString[0]); + QCOMPARE(point->coordinates(), coord1); + QCOMPARE(point->coordinates().detail(), coord1.detail()); QCOMPARE(point->extrude(), true); = GeoDataFolder folder; @@ -419,8 +415,10 @@ void TestGeoDataCopy::copyPlacemark() placemark.setId("281012"); placemark.setParent(&folder); = - testCoordinate(placemark.coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(placemark.geometry())->coord= inates(), 123.4, 2, coordString[0]); + QCOMPARE(placemark.coordinate(), coord1); + QCOMPARE(placemark.coordinate().detail(), coord1.detail()); + QCOMPARE(static_cast(placemark.geometry())->coordinates= (), coord1); + QCOMPARE(static_cast(placemark.geometry())->coordinates= ().detail(), coord1.detail()); QCOMPARE(placemark.area(), 12345678.0); QCOMPARE(placemark.population(), (qint64)123456789); QCOMPARE(placemark.id(), QString("281012")); @@ -433,8 +431,10 @@ void TestGeoDataCopy::copyPlacemark() = QCOMPARE(other.id(), QString()); QCOMPARE(other.parent(), static_cast(0)); - testCoordinate(other.coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(other.geometry())->coord= inates(), 123.4, 2, coordString[0]); + QCOMPARE(other.coordinate(), coord1); + QCOMPARE(other.coordinate().detail(), coord1.detail()); + QCOMPARE(static_cast(other.geometry())->coordinates= (), coord1); + QCOMPARE(static_cast(other.geometry())->coordinates= ().detail(), coord1.detail()); QCOMPARE(other.area(), 12345678.0); QCOMPARE(other.population(), (qint64)123456789); QCOMPARE(other.name(), QString::fromLatin1("Patrick Spendrin")); @@ -442,8 +442,10 @@ void TestGeoDataCopy::copyPlacemark() = other.setPopulation(987654321); = - testCoordinate(other.coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(other.geometry())->coord= inates(), 123.4, 2, coordString[0]); + QCOMPARE(other.coordinate(), coord1); + QCOMPARE(other.coordinate().detail(), coord1.detail()); + QCOMPARE(static_cast(other.geometry())->coordinates= (), coord1); + QCOMPARE(static_cast(other.geometry())->coordinates= ().detail(), coord1.detail()); QCOMPARE(other.area(), 12345678.0); QCOMPARE(other.population(), (qint64)987654321); QCOMPARE(placemark.population(), (qint64)123456789); @@ -460,8 +462,10 @@ void TestGeoDataCopy::copyPlacemark() = QCOMPARE(other.id(), QString()); QCOMPARE(other.parent(), static_cast(0)); - testCoordinate(other.coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(other.geometry())->coord= inates(), 123.4, 2, coordString[0]); + QCOMPARE(other.coordinate(), coord1); + QCOMPARE(other.coordinate().detail(), coord1.detail()); + QCOMPARE(static_cast(other.geometry())->coordinates= (), coord1); + QCOMPARE(static_cast(other.geometry())->coordinates= ().detail(), coord1.detail()); QCOMPARE(other.area(), 12345678.0); QCOMPARE(other.population(), (qint64)123456789); QCOMPARE(other.name(), QString::fromLatin1("Patrick Spendrin")); @@ -469,8 +473,10 @@ void TestGeoDataCopy::copyPlacemark() = other.setPopulation(987654321); = - testCoordinate(other.coordinate(), 123.4, 2, coordString[0]); - testCoordinate(static_cast(other.geometry())->coord= inates(), 123.4, 2, coordString[0]); + QCOMPARE(other.coordinate(), coord1); + QCOMPARE(other.coordinate().detail(), coord1.detail()); + QCOMPARE(static_cast(other.geometry())->coordinates= (), coord1); + QCOMPARE(static_cast(other.geometry())->coordinates= ().detail(), coord1.detail()); QCOMPARE(other.area(), 12345678.0); QCOMPARE(other.population(), (qint64)987654321); QCOMPARE(placemark.population(), (qint64)123456789);