mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-08 00:06:51 -05:00
Rework failing test for better debug output
This commit is contained in:
parent
5ba99505f9
commit
f7ae01c43b
@ -151,6 +151,7 @@ class TestQgsGeometry : public QObject
|
|||||||
|
|
||||||
void makeValid();
|
void makeValid();
|
||||||
|
|
||||||
|
void isSimple_data();
|
||||||
void isSimple();
|
void isSimple();
|
||||||
|
|
||||||
void reshapeGeometryLineMerge();
|
void reshapeGeometryLineMerge();
|
||||||
@ -17649,31 +17650,35 @@ void TestQgsGeometry::makeValid()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsGeometry::isSimple_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QString>( "wkt" );
|
||||||
|
QTest::addColumn<bool>( "simple" );
|
||||||
|
|
||||||
|
QTest::newRow( "linestring" ) << QStringLiteral( "LINESTRING(0 0, 1 0, 1 1)" ) << true;
|
||||||
|
QTest::newRow( "may be closed (linear ring)" ) << QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 0)" ) << true;
|
||||||
|
QTest::newRow( "self-intersection" ) << QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 -1)" ) << false;
|
||||||
|
QTest::newRow( "self-tangency" ) << QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0.5 0, 0 1)" ) << false;
|
||||||
|
QTest::newRow( "points are simple" ) << QStringLiteral( "POINT(1 1)" ) << true;
|
||||||
|
QTest::newRow( "polygons are always simple, even if they are invalid" ) << QStringLiteral( "POLYGON((0 0, 1 1, 1 1, 0 0))" ) << true;
|
||||||
|
QTest::newRow( "multipoint" ) << QStringLiteral( "MULTIPOINT((1 1), (2 2))" ) << true;
|
||||||
|
QTest::newRow( "must not contain the same point twice" ) << QStringLiteral( "MULTIPOINT((1 1), (1 1))" ) << false;
|
||||||
|
QTest::newRow( "multiline string simple" ) << QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 1, 1 1))" ) << true;
|
||||||
|
QTest::newRow( "may be touching at endpoints" ) << QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 0, 1 0))" ) << true;
|
||||||
|
QTest::newRow( "must not intersect each other" ) << QStringLiteral( "MULTILINESTRING((0 0, 1 1), (0 1, 1 0))" ) << false;
|
||||||
|
QTest::newRow( "multi-polygons are always simple" ) << QStringLiteral( "MULTIPOLYGON(((0 0, 1 1, 1 1, 0 0)),((0 0, 1 1, 1 1, 0 0)))" ) << true;
|
||||||
|
}
|
||||||
|
|
||||||
void TestQgsGeometry::isSimple()
|
void TestQgsGeometry::isSimple()
|
||||||
{
|
{
|
||||||
typedef QPair<QString, bool> InputWktAndExpectedResult;
|
QFETCH( QString, wkt );
|
||||||
QList<InputWktAndExpectedResult> geoms;
|
QFETCH( bool, simple );
|
||||||
geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1)" ), true );
|
|
||||||
geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 0)" ), true ); // may be closed (linear ring)
|
|
||||||
geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0 -1)" ), false ); // self-intersection
|
|
||||||
geoms << qMakePair( QStringLiteral( "LINESTRING(0 0, 1 0, 1 1, 0.5 0, 0 1)" ), false ); // self-tangency
|
|
||||||
geoms << qMakePair( QStringLiteral( "POINT(1 1)" ), true ); // points are simple
|
|
||||||
geoms << qMakePair( QStringLiteral( "POLYGON((0 0, 1 1, 1 1, 0 0))" ), true ); // polygons are always simple, even if they are invalid
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTIPOINT((1 1), (2 2))" ), true );
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTIPOINT((1 1), (1 1))" ), false ); // must not contain the same point twice
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 1, 1 1))" ), true );
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 0), (0 0, 1 0))" ), true ); // may be touching at endpoints
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTILINESTRING((0 0, 1 1), (0 1, 1 0))" ), false ); // must not intersect each other
|
|
||||||
geoms << qMakePair( QStringLiteral( "MULTIPOLYGON(((0 0, 1 1, 1 1, 0 0)),((0 0, 1 1, 1 1, 0 0)))" ), true ); // multi-polygons are always simple
|
|
||||||
|
|
||||||
Q_FOREACH ( const InputWktAndExpectedResult &pair, geoms )
|
QgsGeometry gInput = QgsGeometry::fromWkt( wkt );
|
||||||
{
|
QVERIFY( !gInput.isNull() );
|
||||||
QgsGeometry gInput = QgsGeometry::fromWkt( pair.first );
|
|
||||||
QVERIFY( !gInput.isNull() );
|
|
||||||
|
|
||||||
bool res = gInput.isSimple();
|
bool res = gInput.isSimple();
|
||||||
QCOMPARE( res, pair.second );
|
QCOMPARE( res, simple );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsGeometry::reshapeGeometryLineMerge()
|
void TestQgsGeometry::reshapeGeometryLineMerge()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user