Reject wrong rule in opening_hours_parser.

This commit is contained in:
Sergey Magidovich 2016-06-06 21:58:28 +03:00 committed by Vladimir Byko-Ianko
parent 85b8b8ffa5
commit 1e9982157f
2 changed files with 7 additions and 11 deletions

View file

@ -373,7 +373,8 @@ public:
[bind(&Timespan::SetStart, _val, _1),
bind(&Timespan::SetPlus, _val, true)]
| time[bind(&Timespan::SetStart, _val, _1)]
// This rule is only used for collection_times tag wish is not in our interest.
// | time[bind(&Timespan::SetStart, _val, _1)]
;
main %= timespan % ',';

View file

@ -664,11 +664,6 @@ BOOST_AUTO_TEST_CASE(OpeningHours_RuleSequence)
BOOST_AUTO_TEST_CASE(OpeningHoursTimerange_TestParseUnparse)
{
{
auto const rule = "06:00";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TTimespans>(rule);
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
{
auto const rule = "06:00+";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TTimespans>(rule);
@ -700,9 +695,9 @@ BOOST_AUTO_TEST_CASE(OpeningHoursTimerange_TestParseUnparse)
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
{
auto const rule = "dusk";
auto const rule = "dusk+";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TTimespans>(rule);
BOOST_CHECK_EQUAL(parsedUnparsed, "sunset");
BOOST_CHECK_EQUAL(parsedUnparsed, "sunset+");
}
{
auto const rule = "dawn+";
@ -715,7 +710,7 @@ BOOST_AUTO_TEST_CASE(OpeningHoursTimerange_TestParseUnparse)
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
{
auto const rule = "(sunset-12:12)";
auto const rule = "(sunset-12:12)+";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TTimespans>(rule);
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
@ -1005,7 +1000,7 @@ BOOST_AUTO_TEST_CASE(OpeningHoursRuleSequence_TestParseUnparse)
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
{
auto const rule = "06:00-02:00/21:03, 18:15";
auto const rule = "06:00-02:00/21:03, 18:15-sunset";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TRuleSequences>(rule);
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
@ -1048,7 +1043,7 @@ BOOST_AUTO_TEST_CASE(OpeningHoursRuleSequence_TestParseUnparse)
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}
{
auto const rule = "Su-Th (sunset-24:00); Fr-Sa (sunrise+12:12)";
auto const rule = "Su-Th sunrise-(sunset-24:00); Fr-Sa (sunrise+12:12)-sunset";
auto const parsedUnparsed = ParseAndUnparse<osmoh::TRuleSequences>(rule);
BOOST_CHECK_EQUAL(parsedUnparsed, rule);
}