Files
comaps/generator/generator_tests/osm_element_helpers_tests.cpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

34 lines
1.2 KiB
C++

#include "testing/testing.hpp"
#include "generator/osm_element_helpers.hpp"
#include "geometry/point2d.hpp"
namespace
{
using namespace generator::osm_element;
OsmElement CreateOsmElement(std::string const & populationStr)
{
OsmElement element;
element.m_tags.emplace_back("population", populationStr);
return element;
}
UNIT_TEST(ParsePopulation)
{
TEST_EQUAL(GetPopulation(CreateOsmElement("123")), 123, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("123 123")), 123123, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("12,300")), 12300, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("000")), 0, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("123.321")), 123321, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("123 000 000 (Moscow Info)")), 123000000, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("123 000 000 (123)")), 123000000, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("")), 0, ());
TEST_EQUAL(GetPopulation(CreateOsmElement(" ")), 0, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("asd")), 0, ());
TEST_EQUAL(GetPopulation(CreateOsmElement("sfa843r")), 0, ());
TEST_EQUAL(GetPopulation(OsmElement()), 0, ());
}
} // namespace