Merge branch 'master' into 1.9.0
due to release of 1.8.5 Conflicts: ChangeLog configure.ac doc/man/task-tutorial.5 doc/man/task.1 doc/man/taskrc.5 src/Config.cpp src/rules.cpp
This commit is contained in:
66
src/tests/bug.327.t
Executable file
66
src/tests/bug.327.t
Executable file
@@ -0,0 +1,66 @@
|
||||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2009, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 6;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bug.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"confirmation=no\n";
|
||||
close $fh;
|
||||
ok (-r 'bug.rc', 'Created bug.rc');
|
||||
}
|
||||
|
||||
# Setup: Add a recurring task then remove the due date.
|
||||
qx{../task rc:bug.rc add foo recur:yearly due:eoy};
|
||||
qx{../task rc:bug.rc li};
|
||||
qx{../task rc:bug.rc 2 due:};
|
||||
|
||||
# Result: Somehow the due date is incremented and wraps around to 12/31/1969,
|
||||
# then keeps going back to today.
|
||||
my $output = qx{../task rc:bug.rc li};
|
||||
like ($output, qr/^1 task$/ms, 'Should only be one task');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'completed.data';
|
||||
ok (!-r 'completed.data', 'Removed completed.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'bug.rc';
|
||||
ok (!-r 'bug.rc', 'Removed bug.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 14;
|
||||
use Test::More tests => 15;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bulk.rc')
|
||||
@@ -49,13 +49,13 @@ qx{../task rc:bulk.rc add t4 due:thursday};
|
||||
qx{../task rc:bulk.rc add t5 due:friday};
|
||||
qx{../task rc:bulk.rc add t6 due:saturday};
|
||||
|
||||
my $output = qx{yes|../task rc:bulk.rc pro:p1 pri:M 4 5 6};
|
||||
my $output = qx{echo "quit"|../task rc:bulk.rc pro:p1 pri:M 4 5 6};
|
||||
like ($output, qr/Modified 0 tasks/, '"quit" prevents any further modifications');
|
||||
|
||||
my $output = qx{echo "all"|../task rc:bulk.rc pro:p1 pri:M 4 5 6};
|
||||
unlike ($output, qr/Task 4 "t4"\n - No changes were made/, 'Task 4 modified');
|
||||
unlike ($output, qr/Task 5 "t5"\n - No changes were made/, 'Task 5 modified');
|
||||
unlike ($output, qr/Task 6 "t6"\n - No changes were made/, 'Task 6 modified');
|
||||
#diag ("---");
|
||||
#diag ($output);
|
||||
#diag ("---");
|
||||
|
||||
$output = qx{../task rc:bulk.rc info 4};
|
||||
like ($output, qr/Project\s+p1/, 'project applied to 4');
|
||||
|
||||
@@ -49,10 +49,10 @@ if (open my $fh, '>', 'response.txt')
|
||||
|
||||
qx{../task rc:confirm.rc add foo} for 1 .. 10;
|
||||
|
||||
# Test the various forms of "yes".
|
||||
my $output = qx{echo "yes" | ../task rc:confirm.rc del 1};
|
||||
like ($output, qr/Permanently delete task 1 'foo'\? \(y\/n\)/, 'confirmation - yes works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - yes works');
|
||||
# Test the various forms of "Yes".
|
||||
my $output = qx{echo "Yes" | ../task rc:confirm.rc del 1};
|
||||
like ($output, qr/Permanently delete task 1 'foo'\? \(y\/n\)/, 'confirmation - Yes works');
|
||||
unlike ($output, qr/Task not deleted\./, 'confirmation - Yes works');
|
||||
|
||||
$output = qx{echo "ye" | ../task rc:confirm.rc del 2};
|
||||
like ($output, qr/Permanently delete task 2 'foo'\? \(y\/n\)/, 'confirmation - ye works');
|
||||
|
||||
@@ -34,7 +34,7 @@ use Test::More tests => 17;
|
||||
if (open my $fh, '>', 'default.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"default.command=rc:default.rc list\n",
|
||||
"default.command=list\n",
|
||||
"default.project=PROJECT\n",
|
||||
"default.priority=M\n";
|
||||
close $fh;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 12;
|
||||
use Test::More tests => 15;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'dup.rc')
|
||||
@@ -55,6 +55,12 @@ like ($output, qr/Description\s+FOO/, 'duplicate modified description');
|
||||
like ($output, qr/Priority\s+H/, 'duplicate added priority');
|
||||
like ($output, qr/Tags\s+tag/, 'duplicate added tag');
|
||||
|
||||
# Test the output of the duplicate command - returning id of duplicated task
|
||||
$output = qx{../task rc:dup.rc duplicate 1};
|
||||
like ($output, qr/Duplicated\s+1\s+'foo'/, 'duplicate output task id and description');
|
||||
like ($output, qr/Duplicated\s+1\s+task/, 'duplicate output number of tasks duplicated');
|
||||
like ($output, qr/Created\s+task\s+4/, 'duplicate output of new task id');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
@@ -34,7 +34,7 @@ Context context;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (109);
|
||||
UnitTest t (117);
|
||||
|
||||
// void wrapText (std::vector <std::string>& lines, const std::string& text, const int width)
|
||||
std::string text = "This is a test of the line wrapping code.";
|
||||
@@ -104,12 +104,19 @@ int main (int argc, char** argv)
|
||||
t.is (items.size (), (size_t) 1, "split 'a' '-' -> 1 item");
|
||||
t.is (items[0], "a", "split 'a' '-' -> 'a'");
|
||||
|
||||
split (items, unsplit, '-');
|
||||
t.is (items.size (), (size_t) 1, "split 'a' '-' -> 1 item");
|
||||
t.is (items[0], "a", "split 'a' '-' -> 'a'");
|
||||
|
||||
unsplit = "-";
|
||||
split (items, unsplit, '-');
|
||||
t.is (items.size (), (size_t) 2, "split '-' '-' -> '' ''");
|
||||
t.is (items[0], "", "split '-' '-' -> [0] ''");
|
||||
t.is (items[1], "", "split '-' '-' -> [1] ''");
|
||||
|
||||
split_minimal (items, unsplit, '-');
|
||||
t.is (items.size (), (size_t) 1, "split '-' '-' -> '-'");
|
||||
|
||||
unsplit = "-a-bc-def";
|
||||
split (items, unsplit, '-');
|
||||
t.is (items.size (), (size_t) 4, "split '-a-bc-def' '-' -> '' 'a' 'bc' 'def'");
|
||||
@@ -118,11 +125,20 @@ int main (int argc, char** argv)
|
||||
t.is (items[2], "bc", "split '-a-bc-def' '-' -> [2] 'bc'");
|
||||
t.is (items[3], "def", "split '-a-bc-def' '-' -> [3] 'def'");
|
||||
|
||||
split_minimal (items, unsplit, '-');
|
||||
t.is (items.size (), (size_t) 3, "split '-a-bc-def' '-' -> 'a' 'bc' 'def'");
|
||||
t.is (items[0], "a", "split '-a-bc-def' '-' -> [1] 'a'");
|
||||
t.is (items[1], "bc", "split '-a-bc-def' '-' -> [2] 'bc'");
|
||||
t.is (items[2], "def", "split '-a-bc-def' '-' -> [3] 'def'");
|
||||
|
||||
// void split (std::vector<std::string>& results, const std::string& input, const std::string& delimiter)
|
||||
unsplit = "";
|
||||
split (items, unsplit, "--");
|
||||
t.is (items.size (), (size_t) 0, "split '' '--' -> 0 items");
|
||||
|
||||
split_minimal (items, unsplit, "--");
|
||||
t.is (items.size (), (size_t) 0, "split '' '--' -> 0");
|
||||
|
||||
unsplit = "a";
|
||||
split (items, unsplit, "--");
|
||||
t.is (items.size (), (size_t) 1, "split 'a' '--' -> 1 item");
|
||||
|
||||
@@ -38,6 +38,7 @@ int main (int argc, char** argv)
|
||||
|
||||
// TODO bool confirm (const std::string&);
|
||||
// TODO int confirm3 (const std::string&);
|
||||
// TODO int confirm4 (const std::string&);
|
||||
// TODO void delay (float);
|
||||
// TODO std::string formatSeconds (time_t);
|
||||
// TODO std::string formatSecondsCompact (time_t);
|
||||
@@ -83,15 +84,15 @@ int main (int argc, char** argv)
|
||||
Task rightAgain (right);
|
||||
|
||||
std::string output = taskDifferences (left, right);
|
||||
t.ok (taskDiff (left, right), "Detected changes");
|
||||
t.ok (output.find ("zero was changed from '0' to '00'") != std::string::npos, "Detected change zero:0 -> zero:00");
|
||||
t.ok (output.find ("one was deleted") != std::string::npos, "Detected deletion one:1 ->");
|
||||
t.ok (output.find ("two") == std::string::npos, "Detected no change two:2 -> two:2");
|
||||
t.ok (output.find ("three was set to '3'") != std::string::npos, "Detected addition -> three:3");
|
||||
t.ok (taskDiff (left, right), "Detected changes");
|
||||
t.ok (output.find ("zero will be changed from '0' to '00'") != std::string::npos, "Detected change zero:0 -> zero:00");
|
||||
t.ok (output.find ("one will be deleted") != std::string::npos, "Detected deletion one:1 ->");
|
||||
t.ok (output.find ("two") == std::string::npos, "Detected no change two:2 -> two:2");
|
||||
t.ok (output.find ("three will be set to '3'") != std::string::npos, "Detected addition -> three:3");
|
||||
|
||||
t.notok (taskDiff (right, rightAgain), "No changes detected");
|
||||
t.notok (taskDiff (right, rightAgain), "No changes detected");
|
||||
output = taskDifferences (right, rightAgain);
|
||||
t.ok (output.find ("No changes were made") != std::string::npos, "No changes detected");
|
||||
t.ok (output.find ("No changes will be made") != std::string::npos, "No changes detected");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user