summaryrefslogtreecommitdiffstats
path: root/library/cpp/geo/ut/util_ut.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2023-07-31 18:21:04 +0300
committervvvv <[email protected]>2023-07-31 18:21:04 +0300
commitdec41c40e51aa407edef81a3c566a5a15780fc49 (patch)
tree4f197b596b32f35eca368121f0dff913419da9af /library/cpp/geo/ut/util_ut.cpp
parent3ca8b54c96e09eb2b65be7f09675623438d559c7 (diff)
YQL-16239 Move purecalc to public
Diffstat (limited to 'library/cpp/geo/ut/util_ut.cpp')
-rw-r--r--library/cpp/geo/ut/util_ut.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/library/cpp/geo/ut/util_ut.cpp b/library/cpp/geo/ut/util_ut.cpp
new file mode 100644
index 00000000000..ebd86cfbd82
--- /dev/null
+++ b/library/cpp/geo/ut/util_ut.cpp
@@ -0,0 +1,36 @@
+#include <library/cpp/geo/util.h>
+
+#include <library/cpp/testing/unittest/registar.h>
+
+using namespace NGeo;
+
+Y_UNIT_TEST_SUITE(TGeoUtilTest) {
+ Y_UNIT_TEST(TestPointFromString) {
+ UNIT_ASSERT_EQUAL(PairFromString("27.56,53.90"), (std::pair<double, double>(27.56, 53.90)));
+ UNIT_ASSERT_EQUAL(PairFromString("27.56 53.90", " "), (std::pair<double, double>(27.56, 53.90)));
+ UNIT_ASSERT_EQUAL(PairFromString("27.56@@53.90", "@@"), (std::pair<double, double>(27.56, 53.90)));
+ UNIT_ASSERT_EXCEPTION(PairFromString("27.56@@53.90", "@"), TBadCastException);
+ UNIT_ASSERT_EXCEPTION(PairFromString(""), TBadCastException);
+ }
+
+ Y_UNIT_TEST(TestTryPointFromString) {
+ std::pair<double, double> point;
+
+ UNIT_ASSERT(TryPairFromString(point, "27.56,53.90"));
+ UNIT_ASSERT_EQUAL(point, (std::pair<double, double>(27.56, 53.90)));
+
+ UNIT_ASSERT(TryPairFromString(point, "27.56 53.90", " "));
+ UNIT_ASSERT_EQUAL(point, (std::pair<double, double>(27.56, 53.90)));
+
+ UNIT_ASSERT(TryPairFromString(point, "27.56@@53.90", "@@"));
+ UNIT_ASSERT_EQUAL(point, (std::pair<double, double>(27.56, 53.90)));
+
+ UNIT_ASSERT(!TryPairFromString(point, "27.56@@53.90", "@"));
+ UNIT_ASSERT(!TryPairFromString(point, ""));
+ }
+
+ Y_UNIT_TEST(TestVisibleMapBound) {
+ const double expectedLat = MercatorToLL(TMercatorPoint(0., LLToMercator(TGeoPoint(180., 0.)).X())).Lat();
+ UNIT_ASSERT_DOUBLES_EQUAL(VISIBLE_LATITUDE_BOUND, expectedLat, 1.e-14);
+ }
+}