diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-04 07:35:26 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-04-06 09:22:51 -0700 |
commit | 16a2839e23d42d4640ef028d62dc01322a0d2e5a (patch) | |
tree | b8b8ba6e7c9f2e91cc3ec230bb9420e3827f3c27 /test/util | |
parent | a261f7ff532584b3bbbe4ddef2d0ff96a1ee65a5 (diff) | |
download | qtlocation-mapboxgl-16a2839e23d42d4640ef028d62dc01322a0d2e5a.tar.gz |
[all] Make LatLng coordinates read-only
Diffstat (limited to 'test/util')
-rw-r--r-- | test/util/geo.test.cpp | 58 | ||||
-rw-r--r-- | test/util/projection.test.cpp | 8 |
2 files changed, 33 insertions, 33 deletions
diff --git a/test/util/geo.test.cpp b/test/util/geo.test.cpp index 95e75a0e1b..3f625f21fa 100644 --- a/test/util/geo.test.cpp +++ b/test/util/geo.test.cpp @@ -57,80 +57,80 @@ TEST(LatLngBounds, Empty) { TEST(LatLngBounds, Center) { auto result = LatLngBounds::hull({1, 2}, {3, 4}).center(); - ASSERT_DOUBLE_EQ(2, result.latitude); - ASSERT_DOUBLE_EQ(3, result.longitude); + ASSERT_DOUBLE_EQ(2, result.latitude()); + ASSERT_DOUBLE_EQ(3, result.longitude()); } TEST(LatLngBounds, Southwest) { auto result = LatLngBounds::hull({1, 2}, {3, 4}).southwest(); - ASSERT_DOUBLE_EQ(1, result.latitude); - ASSERT_DOUBLE_EQ(2, result.longitude); + ASSERT_DOUBLE_EQ(1, result.latitude()); + ASSERT_DOUBLE_EQ(2, result.longitude()); } TEST(LatLngBounds, Northeast) { auto result = LatLngBounds::hull({1, 2}, {3, 4}).northeast(); - ASSERT_DOUBLE_EQ(3, result.latitude); - ASSERT_DOUBLE_EQ(4, result.longitude); + ASSERT_DOUBLE_EQ(3, result.latitude()); + ASSERT_DOUBLE_EQ(4, result.longitude()); } TEST(LatLngBounds, Southeast) { auto result = LatLngBounds::hull({1, 2}, {3, 4}).southeast(); - ASSERT_DOUBLE_EQ(1, result.latitude); - ASSERT_DOUBLE_EQ(4, result.longitude); + ASSERT_DOUBLE_EQ(1, result.latitude()); + ASSERT_DOUBLE_EQ(4, result.longitude()); } TEST(LatLngBounds, Northwest) { auto result = LatLngBounds::hull({1, 2}, {3, 4}).northwest(); - ASSERT_DOUBLE_EQ(3, result.latitude); - ASSERT_DOUBLE_EQ(2, result.longitude); + ASSERT_DOUBLE_EQ(3, result.latitude()); + ASSERT_DOUBLE_EQ(2, result.longitude()); } TEST(LatLng, FromTileID) { for (int i = 0; i < 20; i++) { const LatLng ll{ CanonicalTileID(i, 0, 0) }; - ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, ll.longitude); - ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude); + ASSERT_DOUBLE_EQ(-util::LONGITUDE_MAX, ll.longitude()); + ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude()); } { const LatLng ll{ UnwrappedTileID(0, 1, 0) }; - ASSERT_DOUBLE_EQ(util::LONGITUDE_MAX, ll.longitude); - ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude); + ASSERT_DOUBLE_EQ(util::LONGITUDE_MAX, ll.longitude()); + ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude()); } { const LatLng ll{ UnwrappedTileID(0, -1, 0) }; - ASSERT_DOUBLE_EQ(-540, ll.longitude); - ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude); + ASSERT_DOUBLE_EQ(-540, ll.longitude()); + ASSERT_DOUBLE_EQ(util::LATITUDE_MAX, ll.latitude()); } } TEST(LatLng, Boundaries) { LatLng coordinate; - ASSERT_DOUBLE_EQ(0, coordinate.latitude); - ASSERT_DOUBLE_EQ(0, coordinate.longitude); + ASSERT_DOUBLE_EQ(0, coordinate.latitude()); + ASSERT_DOUBLE_EQ(0, coordinate.longitude()); - coordinate.longitude = -180.1; - ASSERT_DOUBLE_EQ(-180.1, coordinate.longitude); + coordinate = LatLng(0, -180.1); + ASSERT_DOUBLE_EQ(-180.1, coordinate.longitude()); coordinate.wrap(); - ASSERT_DOUBLE_EQ(179.90000000000001, coordinate.longitude); // 1E-14 + ASSERT_DOUBLE_EQ(179.90000000000001, coordinate.longitude()); // 1E-14 - coordinate.longitude = 180.9; + coordinate = LatLng(0, 180.9); coordinate.wrap(); - ASSERT_DOUBLE_EQ(-179.09999999999999, coordinate.longitude); + ASSERT_DOUBLE_EQ(-179.09999999999999, coordinate.longitude()); - coordinate.longitude = -360.5; + coordinate = LatLng(0, -360.5); coordinate.wrap(); - ASSERT_DOUBLE_EQ(-0.5, coordinate.longitude); + ASSERT_DOUBLE_EQ(-0.5, coordinate.longitude()); - coordinate.longitude = 360.5; + coordinate = LatLng(0, 360.5); coordinate.wrap(); - ASSERT_DOUBLE_EQ(0.5, coordinate.longitude); + ASSERT_DOUBLE_EQ(0.5, coordinate.longitude()); - coordinate.longitude = 360000.5; + coordinate = LatLng(0, 360000.5); coordinate.wrap(); - ASSERT_DOUBLE_EQ(0.5, coordinate.longitude); + ASSERT_DOUBLE_EQ(0.5, coordinate.longitude()); } TEST(LatLngBounds, FromTileID) { diff --git a/test/util/projection.test.cpp b/test/util/projection.test.cpp index 260d12edfe..b0fa0bd060 100644 --- a/test/util/projection.test.cpp +++ b/test/util/projection.test.cpp @@ -53,11 +53,11 @@ TEST(Projection, ProjectedMeters) { projectedMeters = ProjectedMeters { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest() }; latLng = Projection::latLngForProjectedMeters(projectedMeters); - EXPECT_EQ(latLng.latitude, -util::LATITUDE_MAX); - EXPECT_EQ(latLng.longitude, -util::LONGITUDE_MAX); + EXPECT_EQ(latLng.latitude(), -util::LATITUDE_MAX); + EXPECT_EQ(latLng.longitude(), -util::LONGITUDE_MAX); projectedMeters = ProjectedMeters { std::numeric_limits<double>::max(), std::numeric_limits<double>::max() }; latLng = Projection::latLngForProjectedMeters(projectedMeters); - EXPECT_EQ(latLng.latitude, util::LATITUDE_MAX); - EXPECT_EQ(latLng.longitude, util::LONGITUDE_MAX); + EXPECT_EQ(latLng.latitude(), util::LATITUDE_MAX); + EXPECT_EQ(latLng.longitude(), util::LONGITUDE_MAX); } |