Skip to content
Permalink
Browse files

Update for QCOMPARE sensitivity to numeric types

  • Loading branch information
nyalldawson committed Nov 4, 2020
1 parent e64537a commit d44660011121a9039960a6677c04ac9f1d04bf2c
@@ -119,7 +119,7 @@ void QgsPointCloud3DSymbolHandler::processNode( QgsPointCloudIndex *pc, const In

const char *ptr = block->data();
int count = block->pointCount();
int recordSize = attributes.pointRecordSize();
const std::size_t recordSize = attributes.pointRecordSize();

const QgsVector3D scale = pc->scale();
const QgsVector3D offset = pc->offset();
@@ -96,17 +96,17 @@ class CORE_EXPORT QgsPointCloudAttributeCollection
const QgsPointCloudAttribute *find( const QString &attributeName, int &offset ) const;

//! Returns total size of record
int pointRecordSize() const { return mSize; }
std::size_t pointRecordSize() const { return mSize; }

private:
int mSize = 0;
std::size_t mSize = 0;
QVector<QgsPointCloudAttribute> mAttributes;

struct CachedAttributeData
{
int index;
int offset;
CachedAttributeData( int index, int offset )
std::size_t offset;
CachedAttributeData( int index, std::size_t offset )
: index( index )
, offset( offset )
{}
@@ -179,7 +179,7 @@ void QgsPointCloudLayerRenderer::drawData( QPainter *painter, const QgsPointClou
const char *ptr = data->data();
int count = data->pointCount();
const QgsPointCloudAttributeCollection request = data->attributes();
int recordSize = request.pointRecordSize();
const std::size_t recordSize = request.pointRecordSize();

for ( int i = 0; i < count; ++i )
{
@@ -121,8 +121,8 @@ bool _serialize( char *data, size_t outputPosition, QgsPointCloudAttribute::Data

QgsPointCloudBlock *_decompressBinary( const QByteArray &dataUncompressed, const QgsPointCloudAttributeCollection &attributes, const QgsPointCloudAttributeCollection &requestedAttributes )
{
const int pointRecordSize = attributes.pointRecordSize( );
const int requestedPointRecordSize = requestedAttributes.pointRecordSize();
const std::size_t pointRecordSize = attributes.pointRecordSize( );
const std::size_t requestedPointRecordSize = requestedAttributes.pointRecordSize();
const int count = dataUncompressed.size() / pointRecordSize;
QByteArray data;
data.resize( requestedPointRecordSize * count );
@@ -77,22 +77,22 @@ void TestQgsPointCloudAttribute::testAttribute()
QgsPointCloudAttribute attribute( QStringLiteral( "name" ), QgsPointCloudAttribute::DataType::Float );
QCOMPARE( attribute.name(), QStringLiteral( "name" ) );
QCOMPARE( attribute.type(), QgsPointCloudAttribute::DataType::Float );
QCOMPARE( attribute.size(), 4 );
QCOMPARE( attribute.size(), static_cast< std::size_t >( 4 ) );
}

void TestQgsPointCloudAttribute::testCollection()
{
// test collections
QgsPointCloudAttributeCollection collection;
QVERIFY( collection.attributes().empty() );
QCOMPARE( collection.pointRecordSize(), 0 );
QCOMPARE( collection.pointRecordSize(), static_cast< std::size_t >( 0 ) );
int offset = 0;
QVERIFY( !collection.find( QStringLiteral( "test" ), offset ) );

collection.push_back( QgsPointCloudAttribute( QStringLiteral( "at1" ), QgsPointCloudAttribute::DataType::Float ) );
QCOMPARE( collection.attributes().size(), 1 );
QCOMPARE( collection.attributes().at( 0 ).name(), QStringLiteral( "at1" ) );
QCOMPARE( collection.pointRecordSize(), 4 );
QCOMPARE( collection.pointRecordSize(), static_cast< std::size_t >( 4 ) );
QVERIFY( !collection.find( QStringLiteral( "test" ), offset ) );
QCOMPARE( collection.find( QStringLiteral( "at1" ), offset )->name(), QStringLiteral( "at1" ) );
QCOMPARE( offset, 0 );
@@ -101,7 +101,7 @@ void TestQgsPointCloudAttribute::testCollection()
QCOMPARE( collection.attributes().size(), 2 );
QCOMPARE( collection.attributes().at( 0 ).name(), QStringLiteral( "at1" ) );
QCOMPARE( collection.attributes().at( 1 ).name(), QStringLiteral( "at2" ) );
QCOMPARE( collection.pointRecordSize(), 6 );
QCOMPARE( collection.pointRecordSize(), static_cast< std::size_t >( 6 ) );
QVERIFY( !collection.find( QStringLiteral( "test" ), offset ) );
QCOMPARE( collection.find( QStringLiteral( "at1" ), offset )->name(), QStringLiteral( "at1" ) );
QCOMPARE( offset, 0 );
@@ -113,7 +113,7 @@ void TestQgsPointCloudAttribute::testCollection()
QCOMPARE( collection.attributes().at( 0 ).name(), QStringLiteral( "at1" ) );
QCOMPARE( collection.attributes().at( 1 ).name(), QStringLiteral( "at2" ) );
QCOMPARE( collection.attributes().at( 2 ).name(), QStringLiteral( "at3" ) );
QCOMPARE( collection.pointRecordSize(), 14 );
QCOMPARE( collection.pointRecordSize(), static_cast< std::size_t >( 14 ) );
QVERIFY( !collection.find( QStringLiteral( "test" ), offset ) );
QCOMPARE( collection.find( QStringLiteral( "at1" ), offset )->name(), QStringLiteral( "at1" ) );
QCOMPARE( offset, 0 );
@@ -131,7 +131,7 @@ void TestQgsPointCloudAttribute::testCollection()
QCOMPARE( collection2.attributes().at( 0 ).name(), QStringLiteral( "at1" ) );
QCOMPARE( collection2.attributes().at( 1 ).name(), QStringLiteral( "at2" ) );
QCOMPARE( collection2.attributes().at( 2 ).name(), QStringLiteral( "at3" ) );
QCOMPARE( collection2.pointRecordSize(), 14 );
QCOMPARE( collection2.pointRecordSize(), static_cast< std::size_t >( 14 ) );
QVERIFY( !collection2.find( QStringLiteral( "test" ), offset ) );
QCOMPARE( collection2.find( QStringLiteral( "at1" ), offset )->name(), QStringLiteral( "at1" ) );
QCOMPARE( offset, 0 );

0 comments on commit d446600

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