Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce qgsRound since std::round is available only in C++11 onwards #2367

Merged
merged 3 commits into from
Oct 13, 2015
Merged

Introduce qgsRound since std::round is available only in C++11 onwards #2367

merged 3 commits into from
Oct 13, 2015

Conversation

manisandro
Copy link
Member

No description provided.

manisandro referenced this pull request Oct 12, 2015
Replace GEOS C++ dependency with hand-rolled snap-to-grid implementation
@nyalldawson
Copy link
Collaborator

@manisandro any chance of adding some unit tests for this to testqgis.cpp?

@manisandro
Copy link
Member Author

Added some tests with fancy numbers.

QCOMPARE( qgsRound( 2718281828459.045 ), 2718281828459. );
QCOMPARE( qgsRound( -314159265358979.3 ), -314159265358979. );
QCOMPARE( qgsRound( -2718281828459.045 ), -2718281828459. );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a couple of simple "rounding halfway cases away from zero" tests? Just to make sure no one accidentally borks the implementation later on. e.g.

QCOMPARE( qgsRound( 1.5 ), 2. );
QCOMPARE( qgsRound( -1.5 ), -2. );

@manisandro
Copy link
Member Author

Added halfway test cases.

nyalldawson added a commit that referenced this pull request Oct 13, 2015
Introduce qgsRound since std::round is available only in C++11 onwards
@nyalldawson nyalldawson merged commit ff43a5d into qgis:master Oct 13, 2015
@nyalldawson
Copy link
Collaborator

Thanks!

@manisandro manisandro deleted the qgsround branch October 14, 2015 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants