diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-30 12:45:28 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-31 16:53:07 +0200 |
commit | 7b3e24d74a8e32049dd03fceea49e82a2f73f1d4 (patch) | |
tree | c0f8e4395978ffe939fad0d570300b19a41199cc /test | |
parent | 384f1a1960c9a21039642afe9bd1df58a93fddfc (diff) | |
download | qtlocation-mapboxgl-7b3e24d74a8e32049dd03fceea49e82a2f73f1d4.tar.gz |
[core] Cleanup TransformState::getIntegerZoom
Diffstat (limited to 'test')
-rw-r--r-- | test/map/transform.test.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp index 5c720d3f78..0cd92bfc2f 100644 --- a/test/map/transform.test.cpp +++ b/test/map/transform.test.cpp @@ -103,6 +103,29 @@ TEST(Transform, InvalidBearing) { ASSERT_DOUBLE_EQ(2, transform.getAngle()); } +TEST(Transform, IntegerZoom) { + Transform transform; + + auto checkIntegerZoom = [&transform](uint8_t zoomInt, double zoom) { + double scale = transform.getState().zoomScale(zoom); + transform.setScale(scale); + ASSERT_DOUBLE_EQ(transform.getScale(), scale); + ASSERT_NEAR(transform.getZoom(), zoom, 0.0001); + ASSERT_EQ(transform.getState().getIntegerZoom(), zoomInt); + ASSERT_NEAR(transform.getState().getZoomFraction(), zoom - zoomInt, 0.0001); + }; + + for (uint8_t zoomInt = 0; zoomInt < 20; ++zoomInt) { + for (uint32_t percent = 0; percent < 100; ++percent) { + double zoom = zoomInt + (0.01 * percent); + checkIntegerZoom(zoomInt, zoom); + } + } + + // Special case zoom 20. + checkIntegerZoom(20, 20.0); +} + TEST(Transform, PerspectiveProjection) { LatLng loc; |