Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Correct test comparisons
Previously QCOMPARE( QgsGeometry, QgsGeometry ) was actually only
testing for QCOMPARE( bool(QgsGeometry), bool(QgsGeometry) )...!

(cherry picked from commit 18d4059)
  • Loading branch information
nyalldawson committed Nov 6, 2018
1 parent 0b7416f commit 34eb99d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -16933,7 +16933,7 @@ void TestQgsGeometry::minimalEnclosingCircle()
QCOMPARE( radius, 0.0 );
QVERIFY( result.isNull() );

// caase 1
// case 1
geomTest = QgsGeometry::fromPointXY( QgsPointXY( 5, 5 ) );
result = geomTest.minimalEnclosingCircle( center, radius );
QCOMPARE( center, QgsPointXY( 5, 5 ) );
Expand All @@ -16943,47 +16943,44 @@ void TestQgsGeometry::minimalEnclosingCircle()

// case 2
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 3 8, 7 4 )" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 5, 6 ), 0.0001 );
QGSCOMPARENEAR( radius, sqrt( 2 ) * 2, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((7 4, 4.3 3.3, 2.3 5.3, 3 8, 5.7 8.7, 7.7 6.7, 7 4))" ) );

geomTest = QgsGeometry::fromWkt( QStringLiteral( "LINESTRING( 0 5, 2 2, 0 -5, -1 -1 )" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( radius, 5, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );

geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 2 2, 0 -5, -1 -1 )" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( radius, 5, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );

geomTest = QgsGeometry::fromWkt( QStringLiteral( "POLYGON(( 0 5, 2 2, 0 -5, -1 -1 ))" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( radius, 5, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );

geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT( 0 5, 0 -5, 0 0 )" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( radius, 5, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0 5, 4.3 2.5, 4.3 -2.5, -0 -5, -4.3 -2.5, -4.3 2.5, 0 5))" ) );

// case 3
geomTest = QgsGeometry::fromWkt( QStringLiteral( "MULTIPOINT((0 0), (5 5), (0 -5), (0 5), (-5 0))" ) );
result = geomTest.minimalEnclosingCircle( center, radius );
result = geomTest.minimalEnclosingCircle( center, radius, 6 );
QGSCOMPARENEARPOINT( center, QgsPointXY( 0.8333, 0.8333 ), 0.0001 );
QGSCOMPARENEAR( radius, 5.8926, 0.0001 );
resultTest.set( QgsCircle( QgsPoint( center ), radius ).toPolygon( 36 ) );
QCOMPARE( result.asWkt(), resultTest.asWkt() );
QCOMPARE( result.asWkt( 1 ), QStringLiteral( "Polygon ((0.8 6.7, 5.9 3.8, 5.9 -2.1, 0.8 -5.1, -4.3 -2.1, -4.3 3.8, 0.8 6.7))" ) );

}

Expand Down

0 comments on commit 34eb99d

Please sign in to comment.