Capital parser test and fix.

This commit is contained in:
Lev Dragunov 2016-02-03 16:02:25 +03:00 committed by Sergey Yershov
parent ecb8d9705d
commit 16ee27b0a2
2 changed files with 16 additions and 3 deletions

View file

@ -3,9 +3,10 @@
#include "generator/tag_admixer.hpp"
#include "std/map.hpp"
#include "std/set.hpp"
#include "std/sstream.hpp"
UNIT_TEST(ParserTests)
UNIT_TEST(WaysParserTests)
{
map<uint64_t, string> ways;
WaysParserHelper parser(ways);
@ -19,3 +20,15 @@ UNIT_TEST(ParserTests)
TEST_EQUAL(ways[294584441], string("world_level"), ());
TEST(ways.find(140247101) == ways.end(), ());
}
UNIT_TEST(CapitalsParserTests)
{
set<uint64_t> capitals;
CapitalsParserHelper parser(capitals);
istringstream stream("-21.1343401;-175.201808;1082208696;t\n-16.6934156;-179.87995;242715809;f\n19.0534159;169.919199;448768937;t");
parser.ParseStream(stream);
TEST(capitals.find(1082208696) != capitals.end(), ());
TEST(capitals.find(242715809) != capitals.end(), ());
TEST(capitals.find(448768937) != capitals.end(), ());
TEST(capitals.find(140247101) == capitals.end(), ());
}

View file

@ -64,7 +64,7 @@ public:
auto endPos = oneLine.find(";", pos + 1);
if (endPos == string::npos)
endPos = oneLine.length() - 1;
if (strings::to_uint64(oneLine.substr(pos + 1, endPos - pos), nodeId))
if (strings::to_uint64(oneLine.substr(pos + 1, endPos - pos - 1), nodeId))
m_capitals.insert(nodeId);
}
}
@ -72,7 +72,7 @@ public:
}
private:
set<uint64_t> m_capitals;
set<uint64_t> & m_capitals;
};
class TagAdmixer