Removed controversial lists support.

This commit is contained in:
Alex Zolotarev 2016-03-18 18:31:15 +03:00 committed by Sergey Yershov
parent d4e6ca053f
commit 257aacef51
2 changed files with 8 additions and 17 deletions

View file

@ -235,18 +235,8 @@ bool OSMDistanceToMeters(string const & osmRawValue, double & outMeters)
}
break;
// It's probably a list. Use maximum value (if possible) for a list.
case ';':
do
{
s = stop + 1;
double const newValue = strtod(s, &stop);
if (s == stop)
break;
if (isfinite(newValue))
outMeters = newValue;
} while (*stop && *stop == ';');
break;
// It's probably a list. We don't support them.
case ';': return false;
}
while (*stop && isspace(*stop))

View file

@ -120,11 +120,12 @@ UNIT_TEST(OSMDistanceToMetersString)
TEST_EQUAL(OSMDistanceToMetersString("8-15"), "15", ());
TEST_EQUAL(OSMDistanceToMetersString("8-15 ft"), "4.57", ());
TEST_EQUAL(OSMDistanceToMetersString("8-й километр"), "8", ());
TEST_EQUAL(OSMDistanceToMetersString("8;9;10"), "10", ());
TEST_EQUAL(OSMDistanceToMetersString("8;9;10 meters"), "10", ());
TEST_EQUAL(OSMDistanceToMetersString("8;9;10 km"), "10000", ());
TEST_EQUAL(OSMDistanceToMetersString("10;20!111"), "20", ());
TEST_EQUAL(OSMDistanceToMetersString("10;20\""), "20", ());
// Do not support lists for distance values.
TEST_EQUAL(OSMDistanceToMetersString("8;9;10"), "", ());
TEST_EQUAL(OSMDistanceToMetersString("8;9;10 meters"), "", ());
TEST_EQUAL(OSMDistanceToMetersString("8;9;10 km"), "", ());
TEST_EQUAL(OSMDistanceToMetersString("10;20!111"), "", ());
TEST_EQUAL(OSMDistanceToMetersString("10;20\""), "", ());
TEST_EQUAL(OSMDistanceToMetersString("-100.3"), "-100.3", ());
TEST_EQUAL(OSMDistanceToMetersString("99.0000000"), "99", ());
TEST_EQUAL(OSMDistanceToMetersString("8900.000023"), "8900", ());