[indexer] [generator] Fixed the leading zeros check in house numbers.

This commit is contained in:
Maxim Pimenov 2017-11-21 18:39:53 +03:00 committed by Vladimir Byko-Ianko
parent 690c7be128
commit 260f00c309
2 changed files with 17 additions and 1 deletions

View file

@ -212,4 +212,20 @@ UNIT_TEST(FeatureParams_Parsing)
params.AddAddress("165 \t\t Dolliver Street");
TEST_EQUAL(params.GetStreet(), "Dolliver Street", ());
}
{
FeatureParams params;
params.MakeZero();
TEST(params.AddHouseNumber("123"), ());
TEST_EQUAL(params.house.Get(), "123", ());
params.MakeZero();
TEST(params.AddHouseNumber("0000123"), ());
TEST_EQUAL(params.house.Get(), "123", ());
params.MakeZero();
TEST(params.AddHouseNumber("000000"), ());
TEST_EQUAL(params.house.Get(), "0", ());
}
}

View file

@ -305,7 +305,7 @@ bool FeatureParams::AddHouseNumber(string houseNumber)
// Remove leading zeroes from house numbers.
// It's important for debug checks of serialized-deserialized feature.
size_t i = 0;
while (i < houseNumber.size() && houseNumber[i] == '0')
while (i + 1 < houseNumber.size() && houseNumber[i] == '0')
++i;
houseNumber.erase(0, i);