Index: cc/tiles/tile_manager_unittest.cc |
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc |
index 18013899a699594b4370b3fc9fffe323e81690c8..39b79c4dbb9efc6cda6358248350aba05cd33958 100644 |
--- a/cc/tiles/tile_manager_unittest.cc |
+++ b/cc/tiles/tile_manager_unittest.cc |
@@ -1960,5 +1960,38 @@ TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
false /* partial_raster_enabled */); |
} |
+#define PRECISION (15) |
+void TestScale(float lw, float lh, float s) { |
+ long slw = std::lround(lw * s); |
+ long slh = std::lround(lh * s); |
+ |
+ std::cout << "\nGiven Scale = " << std::setprecision(PRECISION) << s; |
+ std::cout << "\nLayer Size = " << lw << " x " << lh; |
+ std::cout << "\nScaled Layer Size = " << std::setprecision(PRECISION) |
+ << (lw * s) << " x " << std::setprecision(PRECISION) << (lh * s); |
+ std::cout << "\nRounded Scaled Layer Size = " << slw << " x " << slh; |
+ std::cout << "\nApproximated Scale [sx, sy] = [" |
+ << std::setprecision(PRECISION) << (slw / lw) << ", " |
+ << std::setprecision(PRECISION) << (slh / lh) << "] <===="; |
+ |
+ std::cout << "\n\n"; |
+} |
+ |
+TEST_F(TileManagerTest, ScaleTestSmallLayerSize) { |
+ // Almost equal scales. |
+ float scale1 = 7.33907556533813f; |
+ float scale2 = 7.33907508850098f; |
+ TestScale(501.f, 502.f, scale1); |
+ TestScale(501.f, 502.f, scale2); |
+} |
+ |
+TEST_F(TileManagerTest, ScaleTestVeryBigLayerSize) { |
+ // Almost equal scales. |
+ float scale1 = 7.33907556533813f; |
+ float scale2 = 7.33907508850098f; |
+ TestScale(5010000.f, 5020000.f, scale1); |
+ TestScale(5010000.f, 5020000.f, scale2); |
+} |
+ |
} // namespace |
} // namespace cc |