From 64be6e1cf40b98c79ad6a851a82800bebd1a90ad Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 26 Aug 2011 02:13:32 -0400 Subject: [PATCH] Unit Tests - Added unit tests for bug 819, on behalf of Matt Kraai. - Created a new, single test for cleanup that replaces 6. It's makes for shorter unit tests, and adds less test count inflation. Over time, all tests should be modified in a similar way. This will probably cut the total number of unit tests in half, but that's not the important metric. --- test/bug.708.t | 26 ++++++++--------------- test/bug.804.t | 26 ++++++++--------------- test/bug.819.t | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 36 deletions(-) create mode 100755 test/bug.819.t diff --git a/test/bug.708.t b/test/bug.708.t index c981ee14f..873070e91 100755 --- a/test/bug.708.t +++ b/test/bug.708.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 6; # Create the rc file. if (open my $fh, '>', 'bug.rc') @@ -68,23 +68,13 @@ $output = qx{../src/task rc:bug.rc 7-9 del}; like ($output, qr/Project 'p1' is 75% complete \(1 of 4 tasks remaining\)\./ms, 'Project counts correct for a multiple delete'); # 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 'backlog.data'; -ok (!-r 'backlog.data', 'Removed backlog.data'); - -unlink 'synch.key'; -ok (!-r 'synch.key', 'Removed synch.key'); - -unlink 'bug.rc'; -ok (!-r 'bug.rc', 'Removed bug.rc'); +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch_key.data' && + ! -r 'bug.rc', 'Cleanup'); exit 0; diff --git a/test/bug.804.t b/test/bug.804.t index c13b1056a..22884ef05 100755 --- a/test/bug.804.t +++ b/test/bug.804.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 6; # Create the rc file. if (open my $fh, '>', 'bug.rc') @@ -57,23 +57,13 @@ like ($output, qr/vwxy$/ms, 'not hyphenated 1'); like ($output, qr/uvwx$/ms, 'not hyphenated 2'); # 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 'backlog.data'; -ok (!-r 'backlog.data', 'Removed backlog.data'); - -unlink 'synch.key'; -ok (!-r 'synch.key', 'Removed synch.key'); - -unlink 'bug.rc'; -ok (!-r 'bug.rc', 'Removed bug.rc'); +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch_key.data' && + ! -r 'bug.rc', 'Cleanup'); exit 0; diff --git a/test/bug.819.t b/test/bug.819.t new file mode 100755 index 000000000..55b04c0e8 --- /dev/null +++ b/test/bug.819.t @@ -0,0 +1,56 @@ +#! /usr/bin/perl +################################################################################ +## taskwarrior - a command line task list manager. +## +## Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +## 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 => 3; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Bug 819: When I run "task add foo\'s bar." the description of the new task is "foo 's bar .". +qx{../src/task rc:bug.rc add foo\\'s bar.}; +my $output = qx{../src/task rc:bug.rc ls}; +like ($output, qr/foo's bar\./, "foo's bar. --> preserved"); + +# Cleanup. +unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc); +ok (! -r 'pending.data' && + ! -r 'completed.data' && + ! -r 'undo.data' && + ! -r 'backlog.data' && + ! -r 'synch_key.data' && + ! -r 'bug.rc', 'Cleanup'); + +exit 0; +