Add test case with valid junk.

Use eps to explicitly match empty string and not consume input
This commit is contained in:
Daniel Patterson 2017-08-31 17:49:06 -07:00
parent 40b5045a0a
commit acb7916996
2 changed files with 4 additions and 3 deletions

View File

@ -402,8 +402,8 @@ Feature: Weight tests
And the speed file
"""
1,2,100,
1,3,5,
3,4,5,
1,3,5,,junk
3,4,5,,
4,2,5,
"""
And the contract extra arguments "--segment-speed-file {speeds_file}"

View File

@ -33,10 +33,11 @@ namespace csv
{
SegmentLookupTable readSegmentValues(const std::vector<std::string> &paths)
{
static const auto value_if_blank = std::numeric_limits<double>::quiet_NaN();
CSVFilesParser<Segment, SpeedSource> parser(
1,
qi::ulong_long >> ',' >> qi::ulong_long,
qi::uint_ >> -(',' >> (qi::double_ | qi::attr(std::numeric_limits<double>::quiet_NaN()))));
qi::uint_ >> -(',' >> (qi::double_ | qi::attr(value_if_blank))));
// Check consistency of keys in the result lookup table
auto result = parser(paths);