forked from organicmaps/organicmaps
prohibit leading zeros in floor count field
This commit is contained in:
parent
cd6395349a
commit
25e165062f
2 changed files with 4 additions and 0 deletions
|
@ -202,6 +202,9 @@ bool EditableMapObject::ValidateBuildingLevels(string const & buildingLevels)
|
|||
if (buildingLevels.size() > 18 /* max number of digits in uint_64 */)
|
||||
return false;
|
||||
|
||||
if ('0' == buildingLevels.front())
|
||||
return false;
|
||||
|
||||
uint64_t levels;
|
||||
return strings::to_uint64(buildingLevels, levels) && levels > 0 && levels <= kMaximumLevelsEditableByUsers;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ UNIT_TEST(EditableMapObject_ValidateBuildingLevels)
|
|||
TEST(EditableMapObject::ValidateBuildingLevels("17"), ());
|
||||
TEST(EditableMapObject::ValidateBuildingLevels("25"), ());
|
||||
TEST(!EditableMapObject::ValidateBuildingLevels("0"), ());
|
||||
TEST(!EditableMapObject::ValidateBuildingLevels("005"), ());
|
||||
TEST(!EditableMapObject::ValidateBuildingLevels("26"), ());
|
||||
TEST(!EditableMapObject::ValidateBuildingLevels("22a"), ());
|
||||
TEST(!EditableMapObject::ValidateBuildingLevels("a22"), ());
|
||||
|
|
Loading…
Add table
Reference in a new issue