From 51c357af2ef0e2466ad0307e25e1e71c3420b26f Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Tue, 20 Jul 2010 12:17:50 -0400 Subject: [PATCH] Unit Tests - Added unit tests for history.monthly and history.annual --- src/tests/history.annual.t | 83 +++++++++++++++++++++++++++++++++++++ src/tests/history.monthly.t | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100755 src/tests/history.annual.t create mode 100755 src/tests/history.monthly.t diff --git a/src/tests/history.annual.t b/src/tests/history.annual.t new file mode 100755 index 000000000..015fb7a38 --- /dev/null +++ b/src/tests/history.annual.t @@ -0,0 +1,83 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2010, 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, '>', 'time.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'time.rc', 'Created time.rc'); +} + +# Create some tasks that were started/finished in different months, then verify +# contents of the history report + +my @timeArray = localtime(time); +my $now = time (); +my $lastyear = $now - ($timeArray[7]+1) * 86_400; + +if (open my $fh, '>', 'pending.data') +{ + print $fh < 9; + +# Create the rc file. +if (open my $fh, '>', 'time.rc') +{ + print $fh "data.location=.\n"; + close $fh; + ok (-r 'time.rc', 'Created time.rc'); +} + +# Create some tasks that were started/finished in different months, then verify +# contents of the history report + +my @timeArray = localtime(time); +my $now = time (); +my $lastmonth = $now - $timeArray[3] * 86_400; + +if (open my $fh, '>', 'pending.data') +{ + print $fh <