Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Koyaani authored and nyalldawson committed Oct 20, 2021
1 parent 00ae7b8 commit 8667785
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/src/core/geometry/testqgscircle.cpp
Expand Up @@ -220,11 +220,26 @@ void TestQgsCircle::from3tangentsMulti()

void TestQgsCircle::minimalCircleFrom3points()
{
// equivalent to from2Points
QgsCircle circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ), QgsPoint( 1, 2 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, -5 ), QgsPoint( 1, 2 ), QgsPoint( 0, 5 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 1, 2 ), QgsPoint( 0, 5 ), QgsPoint( 0, -5 ));

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

// equivalent to from3Points
circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 5, 0 ), QgsPoint( -5, 0 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
Expand Down Expand Up @@ -535,9 +550,14 @@ void TestQgsCircle::toString()
void TestQgsCircle::asGML()
{
// asGML3
QgsCircle exportCircle( QgsPoint( 1, 1 ), 3 );
QDomDocument doc( "gml" );
QString expectedGML3( QStringLiteral( "<Circle xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1 4 4 1 1 -2</posList></Circle>" ) );

QgsCircle exportCircle;
QString expectedGML3( QStringLiteral( "<Circle xmlns=\"gml\"/>" ) );
QGSCOMPAREGML( elemToString( exportCircle.asGml3( doc ) ), expectedGML3 );

exportCircle = QgsCircle( QgsPoint( 1, 1 ), 3 );
expectedGML3 = QString( QStringLiteral( "<Circle xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1 4 4 1 1 -2</posList></Circle>" ) );
QGSCOMPAREGML( elemToString( exportCircle.asGml3( doc ) ), expectedGML3 );

// asGML2
Expand Down

0 comments on commit 8667785

Please sign in to comment.