From d69d6585311b4e2703401196c3e91a437aa73f55 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 3 Mar 2009 17:15:40 -0500 Subject: [PATCH] Unit Tests - tag - Added unit tests to test the +tag and -tag task modification feature. --- src/tests/tag.t | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 src/tests/tag.t diff --git a/src/tests/tag.t b/src/tests/tag.t new file mode 100755 index 000000000..ceeb24dea --- /dev/null +++ b/src/tests/tag.t @@ -0,0 +1,74 @@ +#! /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 => 9; + +# Create the rc file. +if (open my $fh, '>', 'tag.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'tag.rc', 'Created tag.rc'); +} + +# Add task with tags. +my $output = qx{../task rc:tag.rc add +1 This +2 is a test +3; ../task rc:tag.rc info 1}; +#like ($output, qr/^Tags\s+1 2 3$/ms, 'tags found'); +like ($output, qr/^Tags\s+1 2 3\n/m, 'tags found'); + +# Remove tags. +$output = qx{../task rc:tag.rc 1 -3 -2 -1; ../task rc:tag.rc info 1}; +unlike ($output, qr/^Tags/m, '-3 -2 -1 tag removed'); + +# Add tags. +$output = qx{../task rc:tag.rc 1 +4 +5 +6; ../task rc:tag.rc info 1}; +like ($output, qr/^Tags\s+4 5 6\n/m, 'tags found'); + +# Remove tags. +$output = qx{../task rc:tag.rc 1 -4 -5 -6; ../task rc:tag.rc info 1}; +unlike ($output, qr/^Tags/m, '-4 -5 -6 tag removed'); + +# Add and remove tags. +$output = qx{../task rc:tag.rc 1 +duplicate -duplicate; ../task rc:tag.rc info 1}; +unlike ($output, qr/^Tags/m, '+duplicate -duplicate NOP'); + +# Remove missing tag. +$output = qx{../task rc:tag.rc 1 -missing; ../task rc:tag.rc info 1}; +unlike ($output, qr/^Tags/m, '-missing NOP'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pendind.data', 'Removed pending.data'); + +unlink 'tag.rc'; +ok (!-r 'tag.rc', 'Removed tag.rc'); + +exit 0; +