Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti authored and nyalldawson committed Dec 6, 2020
1 parent fe80965 commit 16493ca
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/src/core/testqgsgeometryutils.cpp
Expand Up @@ -82,6 +82,7 @@ class TestQgsGeometryUtils: public QObject
void testWeightedPointInTriangle();
void testPointContinuesArc();
void testBisector();
void testAngleBisector();
};


Expand Down Expand Up @@ -1512,5 +1513,29 @@ void TestQgsGeometryUtils::testBisector()
// collinear
QVERIFY( !QgsGeometryUtils::bisector( 5, 5, 0, 0, 1, 1, x, y ) );
}

void TestQgsGeometryUtils::testAngleBisector()
{
double x, y, angle;
QVERIFY( QgsGeometryUtils::angleBisector( 0, 0, 0, 5, 0, 0, 5, 0, x, y, angle ) );
QGSCOMPARENEAR( x, 0.0, 10e-3 );
QGSCOMPARENEAR( y, 0.0, 10e-3 );
QGSCOMPARENEAR( angle, 45.0, 10e-3 );

QVERIFY( QgsGeometryUtils::angleBisector( 0, 0, 5, 0, 2.5, 0, 7.5, 5, x, y, angle ) );
QGSCOMPARENEAR( x, 2.5, 10e-3 );
QGSCOMPARENEAR( y, 0.0, 10e-3 );
QGSCOMPARENEAR( angle, 67.5, 10e-3 );

QVERIFY( QgsGeometryUtils::angleBisector( 0, 0, 5, 0, 15, -5, 7.5, 5, x, y, angle ) );
QGSCOMPARENEAR( x, 11.25, 10e-3 );
QGSCOMPARENEAR( y, 0.0, 10e-3 );
QGSCOMPARENEAR( angle, 26.565, 10e-3 );

// collinear
QVERIFY( !QgsGeometryUtils::angleBisector( 0, 0, 5, 0, 5, 5, 10, 5, x, y, angle ) );
QVERIFY( !QgsGeometryUtils::angleBisector( 0, 0, 5, 0, 6, 0, 10, 0, x, y, angle ) );
}

QGSTEST_MAIN( TestQgsGeometryUtils )
#include "testqgsgeometryutils.moc"

0 comments on commit 16493ca

Please sign in to comment.