mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-01 11:20:19 +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 monthsToDisplay = 1;
|
||||||
int mFrom = today.month ();
|
int mFrom = today.month ();
|
||||||
int yFrom = today.year ();
|
int yFrom = today.year ();
|
||||||
int mTo;
|
int mTo = mFrom;
|
||||||
int yTo;
|
int yTo = yFrom;
|
||||||
|
|
||||||
// Determine what to do
|
// Determine what to do
|
||||||
int numberOfArgs = context.args.size();
|
int numberOfArgs = context.args.size();
|
||||||
|
|
||||||
if (numberOfArgs == 1 ) {
|
if (numberOfArgs == 1) {
|
||||||
// task cal
|
// task cal
|
||||||
monthsToDisplay = monthsPerLine;
|
monthsToDisplay = monthsPerLine;
|
||||||
mFrom = today.month();
|
mFrom = today.month();
|
||||||
yFrom = today.year();
|
yFrom = today.year();
|
||||||
}
|
}
|
||||||
else if (numberOfArgs == 2 ) {
|
else if (numberOfArgs == 2) {
|
||||||
if (context.args[1] == "y") {
|
if (context.args[1] == "y") {
|
||||||
// task cal y
|
// task cal y
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
|
@ -1520,7 +1520,7 @@ int handleReportCalendar (std::string &outs)
|
||||||
yFrom = atoi( context.args[1].data());
|
yFrom = atoi( context.args[1].data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (numberOfArgs == 3 ) {
|
else if (numberOfArgs == 3) {
|
||||||
if (context.args[2] == "y") {
|
if (context.args[2] == "y") {
|
||||||
// task cal due y
|
// task cal due y
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
|
@ -1533,7 +1533,7 @@ int handleReportCalendar (std::string &outs)
|
||||||
yFrom = atoi( context.args[2].data());
|
yFrom = atoi( context.args[2].data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (numberOfArgs == 4 ) {
|
else if (numberOfArgs == 4) {
|
||||||
// task cal 8 2010 y
|
// task cal 8 2010 y
|
||||||
monthsToDisplay = 12;
|
monthsToDisplay = 12;
|
||||||
mFrom = atoi( context.args[1].data());
|
mFrom = atoi( context.args[1].data());
|
||||||
|
@ -1560,11 +1560,6 @@ int handleReportCalendar (std::string &outs)
|
||||||
yFrom = oldest.year();
|
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;
|
mTo = mFrom + monthsToDisplay - 1;
|
||||||
yTo = yFrom;
|
yTo = yFrom;
|
||||||
if (mTo > 12) {
|
if (mTo > 12) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
## task - a command line task list manager.
|
## task - a command line task list manager.
|
||||||
##
|
##
|
||||||
## Copyright 2006 - 2009, Paul Beckingham.
|
## Copyright 2006 - 2009, Paul Beckingham, Federico Hernandez.
|
||||||
## All rights reserved.
|
## All rights reserved.
|
||||||
##
|
##
|
||||||
## Unit test cal.t originally writen by Federico Hernandez
|
## Unit test cal.t originally writen by Federico Hernandez
|
||||||
|
@ -42,11 +42,11 @@ if (open my $fh, '>', 'cal.rc')
|
||||||
close $fh;
|
close $fh;
|
||||||
ok (-r 'cal.rc', 'Created cal.rc');
|
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 ($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 $nextmonth = $months[($nmon+1) % 12];
|
||||||
my $month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon) % 12];
|
my $month = $months[($nmon) % 12];
|
||||||
my $prevmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon-1) % 12];
|
my $prevmonth = $months[($nmon-1) % 12];
|
||||||
my $nextyear = $nyear + 1901;
|
my $nextyear = $nyear + 1901;
|
||||||
my $year = $nyear + 1900;
|
my $year = $nyear + 1900;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ if ( $day <= 9)
|
||||||
my $output = qx{../task rc:cal.rc rc._forcecolor:on cal};
|
my $output = qx{../task rc:cal.rc rc._forcecolor:on cal};
|
||||||
like ($output, qr/\[36m$day/, 'Current day is highlighted');
|
like ($output, qr/\[36m$day/, 'Current day is highlighted');
|
||||||
like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed');
|
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/\[41m\d+/, 'No overdue tasks are present');
|
||||||
unlike ($output, qr/\[43m\d+/, 'No due tasks are present');
|
unlike ($output, qr/\[43m\d+/, 'No due tasks are present');
|
||||||
$output = qx{../task rc:cal.rc rc.weekstart:Sunday cal};
|
$output = qx{../task rc:cal.rc rc.weekstart:Sunday cal};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue