Skip to content

Commit ef90c0b

Browse files
committedJun 27, 2016
Add unit test for ticket #15116
1 parent 3e069c3 commit ef90c0b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
 

‎tests/src/core/testqgsgeometryutils.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class TestQgsGeometryUtils: public QObject
4444
void testAverageAngle_data();
4545
void testAverageAngle();
4646
void testDistanceToVertex();
47+
void testCircleCenterRadius_data();
48+
void testCircleCenterRadius();
4749
};
4850

4951

@@ -361,6 +363,41 @@ void TestQgsGeometryUtils::testDistanceToVertex()
361363
QCOMPARE( QgsGeometryUtils::distanceToVertex( point, QgsVertexId( 0, 0, 1 ) ), -1.0 );
362364
}
363365

366+
void TestQgsGeometryUtils::testCircleCenterRadius_data()
367+
{
368+
QTest::addColumn<double>( "x1" );
369+
QTest::addColumn<double>( "y1" );
370+
QTest::addColumn<double>( "x2" );
371+
QTest::addColumn<double>( "y2" );
372+
QTest::addColumn<double>( "x3" );
373+
QTest::addColumn<double>( "y3" );
374+
QTest::addColumn<double>( "expectedRadius" );
375+
QTest::addColumn<double>( "expectedCenterX" );
376+
QTest::addColumn<double>( "expectedCenterY" );
377+
378+
QTest::newRow( "circleCenterRadius1" ) << 1.0 << 1.0 << 5.0 << 7.0 << 1.0 << 1.0 << sqrt( 13.0 ) << 3.0 << 4.0;
379+
QTest::newRow( "circleCenterRadius1" ) << 0.0 << 2.0 << 2.0 << 2.0 << 0.0 << 2.0 << 1.0 << 1.0 << 2.0;
380+
}
381+
382+
void TestQgsGeometryUtils::testCircleCenterRadius()
383+
{
384+
QFETCH( double, x1 );
385+
QFETCH( double, y1 );
386+
QFETCH( double, x2 );
387+
QFETCH( double, y2 );
388+
QFETCH( double, x3 );
389+
QFETCH( double, y3 );
390+
QFETCH( double, expectedRadius );
391+
QFETCH( double, expectedCenterX );
392+
QFETCH( double, expectedCenterY );
393+
394+
double radius, centerX, centerY;
395+
QgsGeometryUtils::circleCenterRadius( QgsPointV2( x1, y1 ), QgsPointV2( x2, y2 ), QgsPointV2( x3, y3 ), radius, centerX, centerY );
396+
QVERIFY( qgsDoubleNear( expectedRadius, radius ) );
397+
QVERIFY( qgsDoubleNear( expectedCenterX, centerX ) );
398+
QVERIFY( qgsDoubleNear( expectedCenterY, centerY ) );
399+
}
400+
364401

365402
QTEST_MAIN( TestQgsGeometryUtils )
366403
#include "testqgsgeometryutils.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.