Skip to content

Commit

Permalink
Update for QCOMPARE sensitivity to numeric types
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 4, 2020
1 parent e64537a commit d446600
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/3d/qgspointcloudlayerchunkloader_p.cpp
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/core/pointcloud/qgspointcloudattribute.h
Expand Up @@ -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 )
{}
Expand Down
2 changes: 1 addition & 1 deletion src/core/pointcloud/qgspointcloudrenderer.cpp
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/providers/ept/qgseptdecoder.cpp
Expand Up @@ -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 );
Expand Down
12 changes: 6 additions & 6 deletions tests/src/core/testqgspointcloudattribute.cpp
Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down

0 comments on commit d446600

Please sign in to comment.