mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
parent
2ea3d7744d
commit
e8be21ad61
@ -91,6 +91,8 @@ class TestQgsGeometry : public QObject
|
||||
|
||||
void exportToGeoJSON();
|
||||
|
||||
void wkbInOut();
|
||||
|
||||
private:
|
||||
/** A helper method to do a render check to see if the geometry op is as expected */
|
||||
bool renderCheck( const QString& theTestName, const QString& theComment = "", int mismatchCount = 0 );
|
||||
@ -101,6 +103,24 @@ class TestQgsGeometry : public QObject
|
||||
/** A helper method to dump to qdebug the geometry of a polyline */
|
||||
void dumpPolyline( QgsPolyline &thePolyline );
|
||||
|
||||
// Release return with delete []
|
||||
unsigned char * hex2bytes( const char *hex, int *size )
|
||||
{
|
||||
QByteArray ba = QByteArray::fromHex( hex );
|
||||
unsigned char *out = new unsigned char[ba.size()];
|
||||
memcpy( out, ba.data(), ba.size() );
|
||||
*size = ba.size();
|
||||
return out;
|
||||
}
|
||||
|
||||
QString bytes2hex( const unsigned char *bytes, int size )
|
||||
{
|
||||
QByteArray ba(( const char * )bytes, size );
|
||||
QString out = ba.toHex();
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
QString elemToString( const QDomElement& elem ) const;
|
||||
|
||||
QgsPoint mPoint1;
|
||||
@ -3365,5 +3385,23 @@ QString TestQgsGeometry::elemToString( const QDomElement& elem ) const
|
||||
return s;
|
||||
}
|
||||
|
||||
void TestQgsGeometry::wkbInOut()
|
||||
{
|
||||
// Premature end of WKB
|
||||
// See http://hub.qgis.org/issues/14182
|
||||
const char *hexwkb = "0102000000EF0000000000000000000000000000000000000000000000000000000000000000000000";
|
||||
int size;
|
||||
unsigned char *wkb = hex2bytes( hexwkb, &size );
|
||||
QgsGeometry g14182;
|
||||
// NOTE: wkb onwership transferred to QgsGeometry
|
||||
g14182.fromWkb( wkb, size );
|
||||
//QList<QgsGeometry::Error> errors;
|
||||
//g14182.validateGeometry(errors);
|
||||
// Check with valgrind !
|
||||
QString wkt = g14182.exportToWkt();
|
||||
QCOMPARE( wkt, QString() );
|
||||
|
||||
}
|
||||
|
||||
QTEST_MAIN( TestQgsGeometry )
|
||||
#include "testqgsgeometry.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user