mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Rules: Added support for the platform-dependent behavior of strtoimax
This commit is contained in:
parent
323c76181f
commit
7cc8618c80
2 changed files with 9 additions and 7 deletions
|
@ -159,7 +159,9 @@ int Rules::getInteger (const std::string& key, int defaultValue) const
|
|||
|
||||
// Invalid values are handled. ERANGE errors are simply capped by
|
||||
// strtoimax, which is desired behavior.
|
||||
if (value == 0 && errno == EINVAL)
|
||||
// Note that not all platforms behave alike, and the EINVAL is not
|
||||
// necessarily returned.
|
||||
if (value == 0 && (errno == EINVAL || found->second != "0"))
|
||||
throw format ("Invalid integer value for '{1}': '{2}'", key, found->second);
|
||||
|
||||
return value;
|
||||
|
|
12
test/chart.t
12
test/chart.t
|
@ -61,37 +61,37 @@ class TestChart(TestCase):
|
|||
"""Chart should report error on invalid value for 'reports.day.lines'"""
|
||||
code, out, err = self.t.runError("day rc.reports.day.lines=foobar")
|
||||
|
||||
self.assertIn("Invalid value for 'reports.day.lines': 'foobar'", err)
|
||||
self.assertIn("Invalid integer value for 'reports.day.lines': 'foobar'", err)
|
||||
|
||||
def test_chart_day_with_invalid_config_for_cell(self):
|
||||
"""Chart should report error on invalid value for 'reports.day.cell'"""
|
||||
code, out, err = self.t.runError("day rc.reports.day.cell=foobar")
|
||||
|
||||
self.assertIn("The value for 'reports.day.cell' must be at least 1.\n", err)
|
||||
self.assertIn("Invalid integer value for 'reports.day.cell': 'foobar'", err)
|
||||
|
||||
def test_chart_week_with_invalid_config_for_lines(self):
|
||||
"""Chart should report error on invalid value for 'reports.week.lines'"""
|
||||
code, out, err = self.t.runError("week rc.reports.week.lines=foobar")
|
||||
|
||||
self.assertIn("Invalid value for 'reports.week.lines': 'foobar'", err)
|
||||
self.assertIn("Invalid integer value for 'reports.week.lines': 'foobar'", err)
|
||||
|
||||
def test_chart_week_with_invalid_config_for_cell(self):
|
||||
"""Chart should report error on invalid value for 'reports.week.cell'"""
|
||||
code, out, err = self.t.runError("week rc.reports.week.cell=foobar")
|
||||
|
||||
self.assertIn("The value for 'reports.week.cell' must be at least 1.\n", err)
|
||||
self.assertIn("Invalid integer value for 'reports.week.cell': 'foobar'", err)
|
||||
|
||||
def test_chart_month_with_invalid_config_for_lines(self):
|
||||
"""Chart should report error on invalid value for 'reports.month.lines'"""
|
||||
code, out, err = self.t.runError("month rc.reports.month.lines=foobar")
|
||||
|
||||
self.assertIn("Invalid value for 'reports.month.lines': 'foobar'", err)
|
||||
self.assertIn("Invalid integer value for 'reports.month.lines': 'foobar'", err)
|
||||
|
||||
def test_chart_month_with_invalid_config_for_cell(self):
|
||||
"""Chart should report error on invalid value for 'reports.month.cell'"""
|
||||
code, out, err = self.t.runError("month rc.reports.month.cell=foobar")
|
||||
|
||||
self.assertIn("The value for 'reports.month.cell' must be at least 1.", err)
|
||||
self.assertIn("Invalid integer value for 'reports.month.cell': 'foobar'", err)
|
||||
|
||||
def test_chart_day_with_less_than_one_minute_interval_at_day_start(self):
|
||||
self.t("track 2016-01-15T00:00:00 - 2016-01-15T00:00:40 XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue