diff options
Diffstat (limited to 'test/util/geo.test.cpp')
-rw-r--r-- | test/util/geo.test.cpp | 69 |
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()); |