Skip to content
Permalink
Browse files

Update rotate function expression tests

  • Loading branch information
nyalldawson committed Jan 2, 2020
1 parent 5bb6359 commit 0d4e4b9eb010b31962a1214a7b0826cdd9f9c8d3
Showing with 10 additions and 9 deletions.
  1. +10 −9 tests/src/core/testqgsexpression.cpp
@@ -1152,6 +1152,16 @@ class TestQgsExpression: public QObject
QTest::newRow( "flip_coordinates not geom" ) << "flip_coordinates('g')" << true << QVariant();
QTest::newRow( "flip_coordinates null" ) << "flip_coordinates(NULL)" << false << QVariant();
QTest::newRow( "flip_coordinates point" ) << "geom_to_wkt(flip_coordinates(geom_from_wkt('POINT(1 2)')))" << false << QVariant( "Point (2 1)" );
QTest::newRow( "rotate not geom" ) << "rotate('g', 90)" << true << QVariant();
QTest::newRow( "rotate null" ) << "rotate(NULL, 90)" << false << QVariant();
QTest::newRow( "rotate point" ) << "geom_to_wkt(rotate(geom_from_wkt('POINT( 20 10)'), 90, geom_from_wkt('POINT( 30 15)')))" << false << QVariant( "Point (25 25)" );
QTest::newRow( "rotate line centroid" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90))" << false << QVariant( "LineString (0 10, 0 0, 10 0)" );
QTest::newRow( "rotate line fixed point" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90, make_point(5, 2)))" << false << QVariant( "LineString (3 7, 3 -3, 13 -3)" );
QTest::newRow( "rotate line fixed point not geom" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90, 'a'))" << true << QVariant();
QTest::newRow( "rotate line fixed point not point" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90, geom_from_wkt('LineString(0 0, 10 0, 10 10)')))" << true << QVariant();
QTest::newRow( "rotate line fixed multi point" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90, geom_from_wkt('MULTIPOINT((-5 -3))')))" << false << QVariant( "LineString (-2 -8, -2 -18, 8 -18)" );
QTest::newRow( "rotate line fixed multi point multiple" ) << "geom_to_wkt(rotate(geom_from_wkt('LineString(0 0, 10 0, 10 10)'),90, geom_from_wkt('MULTIPOINT(-5 -3,1 2)')))" << true << QVariant();
QTest::newRow( "rotate polygon centroid" ) << "geom_to_wkt(rotate(geom_from_wkt('Polygon((0 0, 10 0, 10 10, 0 0))'),-90))" << false << QVariant( "Polygon ((10 0, 10 10, 0 10, 10 0))" );

// string functions
QTest::newRow( "format_number" ) << "format_number(1999.567,2)" << false << QVariant( "1,999.57" );
@@ -2947,15 +2957,6 @@ class TestQgsExpression: public QObject
QTest::newRow( "translate" ) << "translate( $geometry, -1, 2)" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "LINESTRING (-1 2, 9 12)" ) );
geom = QgsGeometry::fromPointXY( point );
QTest::newRow( "translate" ) << "translate( $geometry, 1, -2)" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "POINT(1 -2)" ) );

geom = QgsGeometry::fromPolygonXY( polygon );
QTest::newRow( "rotate" ) << "rotate( $geometry, 90, geomFromWKT( 'POINT(10 10)' ) )" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "Polygon ((0 20, 10 10, 0 10, 0 20))" ) );
geom = QgsGeometry::fromPolylineXY( line );
QTest::newRow( "rotate" ) << "rotate( $geometry, -90, geomFromWKT( 'POINT(5 5)' ) )" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "LineString (10 0, 0 10)'" ) );
geom = QgsGeometry::fromPointXY( point );
QTest::newRow( "rotate" ) << "rotate( $geometry, 180, geomFromWKT( 'POINT(-5 -3)' ) )" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "Point (-10 -6)" ) );
QTest::newRow( "rotate" ) << "rotate( $geometry, 180, geomFromWKT( 'MULTIPOINT((-5 -3))' ) )" << geom << false << true << QgsGeometry::fromWkt( QStringLiteral( "Point (-10 -6)" ) );
QTest::newRow( "rotate" ) << "rotate( $geometry, 180, geomFromWKT( 'MULTIPOINT((-5 -3, 7 7, 4 4))' ) )" << geom << true << true << QgsVariant();
}

void eval_geometry_method()

0 comments on commit 0d4e4b9

Please sign in to comment.
You can’t perform that action at this time.