mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-30 22:43:24 +02:00
Unit Tests - cal.t
- Fixed a broken fix (e7c8114dff
) for
the calendar command - previously if task could find no tasks with
due dates, no calendar was displayed, and an error message shown.
That broken fix was only on the 1.9.0 branch and never released.
The correct behavior is to show a line of months. This bug broke
15 unit tests.
- Fixed minor problem in unit tests where the output was not captured,
although this has no bearing on the results.
This commit is contained in:
parent
f3d31834ee
commit
5f353f800d
2 changed files with 12 additions and 17 deletions
|
@ -1489,19 +1489,19 @@ int handleReportCalendar (std::string &outs)
|
|||
int monthsToDisplay = 1;
|
||||
int mFrom = today.month ();
|
||||
int yFrom = today.year ();
|
||||
int mTo;
|
||||
int yTo;
|
||||
int mTo = mFrom;
|
||||
int yTo = yFrom;
|
||||
|
||||
// Determine what to do
|
||||
int numberOfArgs = context.args.size();
|
||||
|
||||
if (numberOfArgs == 1 ) {
|
||||
if (numberOfArgs == 1) {
|
||||
// task cal
|
||||
monthsToDisplay = monthsPerLine;
|
||||
mFrom = today.month();
|
||||
yFrom = today.year();
|
||||
}
|
||||
else if (numberOfArgs == 2 ) {
|
||||
else if (numberOfArgs == 2) {
|
||||
if (context.args[1] == "y") {
|
||||
// task cal y
|
||||
monthsToDisplay = 12;
|
||||
|
@ -1520,7 +1520,7 @@ int handleReportCalendar (std::string &outs)
|
|||
yFrom = atoi( context.args[1].data());
|
||||
}
|
||||
}
|
||||
else if (numberOfArgs == 3 ) {
|
||||
else if (numberOfArgs == 3) {
|
||||
if (context.args[2] == "y") {
|
||||
// task cal due y
|
||||
monthsToDisplay = 12;
|
||||
|
@ -1533,7 +1533,7 @@ int handleReportCalendar (std::string &outs)
|
|||
yFrom = atoi( context.args[2].data());
|
||||
}
|
||||
}
|
||||
else if (numberOfArgs == 4 ) {
|
||||
else if (numberOfArgs == 4) {
|
||||
// task cal 8 2010 y
|
||||
monthsToDisplay = 12;
|
||||
mFrom = atoi( context.args[1].data());
|
||||
|
@ -1560,11 +1560,6 @@ int handleReportCalendar (std::string &outs)
|
|||
yFrom = oldest.year();
|
||||
}
|
||||
|
||||
// If there are no tasks with due dates, then prevent showing a calendar from
|
||||
// the year 2037.
|
||||
if (countDueDates == 0)
|
||||
throw std::string ("There are no tasks that have due dates.");
|
||||
|
||||
mTo = mFrom + monthsToDisplay - 1;
|
||||
yTo = yFrom;
|
||||
if (mTo > 12) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2009, Paul Beckingham.
|
||||
## Copyright 2006 - 2009, Paul Beckingham, Federico Hernandez.
|
||||
## All rights reserved.
|
||||
##
|
||||
## Unit test cal.t originally writen by Federico Hernandez
|
||||
|
@ -42,11 +42,11 @@ if (open my $fh, '>', 'cal.rc')
|
|||
close $fh;
|
||||
ok (-r 'cal.rc', 'Created cal.rc');
|
||||
}
|
||||
|
||||
my @months = qw(Jan Fev Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
|
||||
my ($day, $nmon, $nyear) = (localtime)[3,4,5];
|
||||
my $nextmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon+1) % 12];
|
||||
my $month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon) % 12];
|
||||
my $prevmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon-1) % 12];
|
||||
my $nextmonth = $months[($nmon+1) % 12];
|
||||
my $month = $months[($nmon) % 12];
|
||||
my $prevmonth = $months[($nmon-1) % 12];
|
||||
my $nextyear = $nyear + 1901;
|
||||
my $year = $nyear + 1900;
|
||||
|
||||
|
@ -59,7 +59,7 @@ if ( $day <= 9)
|
|||
my $output = qx{../task rc:cal.rc rc._forcecolor:on cal};
|
||||
like ($output, qr/\[36m$day/, 'Current day is highlighted');
|
||||
like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed');
|
||||
qx{../task rc:cal.rc add zero};
|
||||
$output = qx{../task rc:cal.rc add zero};
|
||||
unlike ($output, qr/\[41m\d+/, 'No overdue tasks are present');
|
||||
unlike ($output, qr/\[43m\d+/, 'No due tasks are present');
|
||||
$output = qx{../task rc:cal.rc rc.weekstart:Sunday cal};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue