mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Duration
- Allowed durations to be specified numerically as seconds, in string form. This flexibility allows the removal of special-case handling that stores recurrence periods in raw form ('monthly'), reducing code size. As a consequence this means that recurrence may now be rendered according to Duration::formatCompact, which is desirable. - Added supporting unit tests.
This commit is contained in:
parent
9a126ce717
commit
1714601ce4
2 changed files with 18 additions and 2 deletions
|
@ -48,7 +48,7 @@ int convertDuration (const std::string& input)
|
|||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (629);
|
||||
UnitTest t (631);
|
||||
|
||||
Duration d;
|
||||
|
||||
|
@ -506,6 +506,8 @@ int main (int argc, char** argv)
|
|||
d = Duration (364*86400), t.is (d.formatCompact (), "11mo", "364*86400 -> 11mo");
|
||||
d = Duration (365*86400), t.is (d.formatCompact (), "1.0y", "365*86400 -> 1.0y");
|
||||
|
||||
d = Duration ("86400"), t.is (d.formatCompact (), "1d", "string '86400' -> 1d");
|
||||
|
||||
t.ok (d.valid ("daily"), "valid duration daily");
|
||||
t.ok (d.valid ("day"), "valid duration day");
|
||||
t.ok (d.valid ("weekly"), "valid duration weekly");
|
||||
|
@ -630,6 +632,8 @@ int main (int argc, char** argv)
|
|||
|
||||
t.ok (d.valid ("-"), "valid duration -");
|
||||
|
||||
t.ok (d.valid ("86400"), "valid duration '86400'");
|
||||
|
||||
t.notok (d.valid ("woof"), "valid duration woof = fail");
|
||||
|
||||
t.is (convertDuration ("daily"), 1, "valid duration daily");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue