Skip to content
Permalink
Browse files

Add unit tests

  • Loading branch information
i-s-o authored and nirvn committed Jan 9, 2020
1 parent 662ede5 commit 1b920ca997c85c23764acb46985d4d617b7bf0dd
Showing with 34 additions and 0 deletions.
  1. +34 −0 tests/src/app/testqgisappclipboard.cpp
@@ -331,6 +331,40 @@ void TestQgisAppClipboard::pasteWkt()
QCOMPARE( features.at( 2 ).attributes().at( 0 ).toString(), QStringLiteral( "2" ) );
QCOMPARE( features.at( 2 ).attributes().at( 1 ).toString(), QStringLiteral( "b2" ) );
QCOMPARE( features.at( 2 ).attributes().at( 2 ).toString(), QStringLiteral( "3" ) );

// when a set of features is built outside of QGIS, last one might be terminated by newline
// https://github.com/qgis/QGIS/issues/33617
mQgisApp->clipboard()->setText( QStringLiteral( "POINT (125 10)\nPOINT (111 30)\n" ) );
features = mQgisApp->clipboard()->copyOf();
QCOMPARE( features.length(), 2 );
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
featureGeom = features.at( 0 ).geometry();
point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
QCOMPARE( point->x(), 125.0 );
QCOMPARE( point->y(), 10.0 );
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() );
QCOMPARE( point->x(), 111.0 );
QCOMPARE( point->y(), 30.0 );

// on MS Windows, the <EOL> marker is CRLF
// https://github.com/qgis/QGIS/pull/33618#discussion_r363147854
mQgisApp->clipboard()->setText( QStringLiteral( "POINT (125 10)\r\nPOINT (111 30)\r\n" ) );
features = mQgisApp->clipboard()->copyOf();
QCOMPARE( features.length(), 2 );
QVERIFY( features.at( 0 ).hasGeometry() && !features.at( 0 ).geometry().isNull() );
QCOMPARE( features.at( 0 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
featureGeom = features.at( 0 ).geometry();
point = dynamic_cast< const QgsPoint * >( featureGeom.constGet() );
QCOMPARE( point->x(), 125.0 );
QCOMPARE( point->y(), 10.0 );
QVERIFY( features.at( 1 ).hasGeometry() && !features.at( 1 ).geometry().isNull() );
QCOMPARE( features.at( 1 ).geometry().constGet()->wkbType(), QgsWkbTypes::Point );
point = dynamic_cast< const QgsPoint * >( features.at( 1 ).geometry().constGet() );
QCOMPARE( point->x(), 111.0 );
QCOMPARE( point->y(), 30.0 );
}

void TestQgisAppClipboard::pasteGeoJson()

0 comments on commit 1b920ca

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