summaryrefslogtreecommitdiff
path: root/test/util/geo.test.cpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-04-11 17:07:25 +0300
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-04-14 12:33:13 -0700
commit2f4d162debd7e4accfc0b20360058304dce40801 (patch)
tree276894e2ccfa67874dbe6ecf263330d6b35007ad /test/util/geo.test.cpp
parent8877452ec36d01a753221998f31b67700e595d54 (diff)
downloadqtlocation-mapboxgl-2f4d162debd7e4accfc0b20360058304dce40801.tar.gz
[core] Tighten geo.hpp ctors
Diffstat (limited to 'test/util/geo.test.cpp')
-rw-r--r--test/util/geo.test.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/util/geo.test.cpp b/test/util/geo.test.cpp
index 3f625f21fa..3dfa8e1cca 100644
--- a/test/util/geo.test.cpp
+++ b/test/util/geo.test.cpp
@@ -6,6 +6,75 @@
using namespace mbgl;
+TEST(LatLng, InvalidLatLng) {
+ try {
+ LatLng { NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "latitude must not be NaN");
+ }
+ try {
+ LatLng { 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "longitude must not be NaN");
+ }
+ try {
+ LatLng { 91.0 };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "latitude must be between -90 and 90");
+ }
+ try {
+ LatLng { 0, std::numeric_limits<double>::infinity() };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "longitude must not be infinite");
+ }
+}
+
+TEST(ProjectedMeters, InvalidProjectedMeters) {
+ try {
+ ProjectedMeters { NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "northing must not be NaN");
+ }
+ try {
+ ProjectedMeters { 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "easting must not be NaN");
+ }
+}
+
+TEST(EdgeInsets, InvalidEdgeInsets) {
+ try {
+ EdgeInsets { NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "top must not be NaN");
+ }
+ try {
+ EdgeInsets { 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "left must not be NaN");
+ }
+ try {
+ EdgeInsets { 0, 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "bottom must not be NaN");
+ }
+ try {
+ EdgeInsets { 0, 0, 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "right must not be NaN");
+ }
+}
+
TEST(LatLngBounds, World) {
auto result = LatLngBounds::world();
ASSERT_DOUBLE_EQ(-90, result.south());