From bb04a58bdc9d54ba1d8e8dabcf04695f28dd1d39 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 13 May 2011 23:55:01 -0400 Subject: [PATCH] Unit Tests - Corrected use of rc.fontunderline with the new Views. - Added new sample todo.sh import data, thanks to Daniel Wilcox. - Added rc.defaultwidth to various tests. - Modified tests to accomodate new next report. - Corrected regex in rc.override.t. --- src/columns/Column.cpp | 3 ++- test/fontunderline.t | 2 +- test/import.todo.t | 54 ++++++++++++++++++++++++++++++++---------- test/list.all.tags.t | 3 ++- test/next.t | 4 ++-- test/rc.override.t | 4 ++-- 6 files changed, 51 insertions(+), 19 deletions(-) diff --git a/src/columns/Column.cpp b/src/columns/Column.cpp index d5aed1005..126bbb2d5 100644 --- a/src/columns/Column.cpp +++ b/src/columns/Column.cpp @@ -158,7 +158,8 @@ void Column::renderHeader ( Color c = color; // Now underline the header, or add a dashed line. - if (context.config.getBoolean ("fontunderline")) + if (context.color () && + context.config.getBoolean ("fontunderline")) { c.blend (Color (Color::nocolor, Color::nocolor, true, false, false)); lines.push_back (c.colorize (leftJustify (header, width))); diff --git a/test/fontunderline.t b/test/fontunderline.t index efb147035..9494f99d1 100755 --- a/test/fontunderline.t +++ b/test/fontunderline.t @@ -39,7 +39,7 @@ if (open my $fh, '>', 'font.rc') } # Test the fontunderline config variable. The following truth table defines -# the different results which are to be tested. +# the different results which are to be confirmed. # # color _forcecolor fontunderline result # ----- ----------- ------------- --------- diff --git a/test/import.todo.t b/test/import.todo.t index 2841705cd..1f56a9c46 100755 --- a/test/import.todo.t +++ b/test/import.todo.t @@ -28,12 +28,13 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 30; # Create the rc file. if (open my $fh, '>', 'import.rc') { - print $fh "data.location=.\n"; + print $fh "data.location=.\n", + "dateformat=YYYY-M-D\n"; close $fh; ok (-r 'import.rc', 'Created import.rc'); } @@ -41,23 +42,52 @@ if (open my $fh, '>', 'import.rc') # Create import file. if (open my $fh, '>', 'import.txt') { - print $fh "x 2009-03-25 Walk the dog +project \@context\n", - "This is a test +project \@context\n", - "(A) A prioritized task\n", - "\n"; + print $fh "(A) Prioritized todo\n", + "(B) 2011-05-09 Prioritized with entry date\n", + "2011-05-09 Not prioritized with entry date\n", + "(C) +Project \@Context Priority with Project and context t:2011-05-11 < due date\n", + "(D) 2011-05-09 +Project +OtherProject \@Context \@OtherContext Two Projects and Context with date\n", + "x 2011-05-11 2011-05-09 +Project +OtherProject \@Context with date and completion date\n"; close $fh; ok (-r 'import.txt', 'Created sample import data'); } my $output = qx{../src/task rc:import.rc import import.txt}; -like ($output, qr/Imported 3 tasks successfully, with 0 errors./, 'no errors'); +like ($output, qr/Imported 6 tasks successfully, with 0 errors./, 'no errors'); -$output = qx{../src/task rc:import.rc list}; -like ($output, qr/1.+project.+This is a test/, 't1'); -like ($output, qr/2.+H.+A prioritized task/, 't2'); +$output = qx{../src/task rc:import.rc info 1}; +like ($output, qr/^Priority.+H.*$/m, 'priority (A) -> pri:H'); +like ($output, qr/^Description.+Prioritized todo.*$/m, '... -> desc:...'); -$output = qx{../src/task rc:import.rc completed}; -like ($output, qr/3\/25\/2009.+Walk the dog/, 't3'); +$output = qx{../src/task rc:import.rc info 2}; +like ($output, qr/^Priority.+M.*$/m, 'priority (B) -> pri:M'); +like ($output, qr/^Description.+Prioritized with entry Date.*$/m, '... -> desc:...'); + +$output = qx{../src/task rc:import.rc info 3}; +like ($output, qr/^Project.+Project.*$/m, '+Project -> pro:Project'); +like ($output, qr/^Description.+Not prioritized with entry Date.*$/m, '... -> desc:...'); + +$output = qx{../src/task rc:import.rc info 4}; +like ($output, qr/^Priority.+L.*$/m, 'priority (C) -> pri:L'); +like ($output, qr/^Project.+Project.*$/m, '+Project -> pro:Project'); +like ($output, qr/^Description.+Priority with Project and context.*$/m, '... -> desc:...'); +like ($output, qr/^Tags.+\@Context.*$/m, '@Context -> +@Context'); +like ($output, qr/^Due.+2011-05-11.*$/m, 't:2011-05-11 -> due:2011-05-11'); + +$output = qx{../src/task rc:import.rc info 5}; +unlike ($output, qr/^Priority/m, 'priority (D) -> pri:'); +like ($output, qr/^Project.+Project.*$/m, '+Project -> pro:Project'); +like ($output, qr/^Description.+Two Projects and Context with date.*$/m, '... -> desc:...'); +like ($output, qr/^Tags.+\@Context.*$/m, '@Context -> +@Context'); +like ($output, qr/^Entry.+2011-05-09.*$/m, '2011-05-09 -> entry:2011-05-09'); + +$output = qx{../src/task rc:import.rc info 6}; +like ($output, qr/^Description.+With date and completion date.*$/m, '... -> desc:...'); +like ($output, qr/^Description.+With date and completion date.*$/m, '... -> desc:...'); +like ($output, qr/^Tags.+\@Context.*$/m, '@Context -> +@Context'); +like ($output, qr/^Entry.+2011-05-09.*$/m, '2011-05-09 -> entry:2011-05-09'); +like ($output, qr/^End.+2011-05-11.*$/m, '2011-05-11 -> end:2011-05-11'); +like ($output, qr/^Status.+Completed.*$/m, 'x -> status:Completed'); # Cleanup. unlink 'import.txt'; diff --git a/test/list.all.tags.t b/test/list.all.tags.t index 8effafbe3..17b291d86 100755 --- a/test/list.all.tags.t +++ b/test/list.all.tags.t @@ -33,7 +33,8 @@ use Test::More tests => 11; # Create the rc file. if (open my $fh, '>', 'tags.rc') { - print $fh "data.location=.\n"; + print $fh "data.location=.\n", + "defaultwidth=100\n"; close $fh; ok (-r 'tags.rc', 'Created tags.rc'); } diff --git a/test/next.t b/test/next.t index 2a51c5afd..c6d70e37f 100755 --- a/test/next.t +++ b/test/next.t @@ -47,8 +47,8 @@ qx{../src/task rc:next.rc add project:B priority:H BH}; qx{../src/task rc:next.rc add project:B Bnone}; my $output = qx{../src/task rc:next.rc next}; -like ($output, qr/\s1\sA\s+H\s+(?:-|\d secs?)\sAH\n/, 'AH shown'); -like ($output, qr/\s3\sB\s+H\s+(?:-|\d secs?)\sBH\n/, 'BH shown'); +like ($output, qr/AH/, 'AH shown'); +like ($output, qr/BH/, 'BH shown'); # Cleanup. unlink 'pending.data'; diff --git a/test/rc.override.t b/test/rc.override.t index a0b640f22..f7b2c7198 100755 --- a/test/rc.override.t +++ b/test/rc.override.t @@ -40,10 +40,10 @@ if (open my $fh, '>', 'rc.rc') } my $output = qx{../src/task rc:rc.rc show}; -like ($output, qr/\sfoo\s+bar/, 'unmodified'); +like ($output, qr/^.*foo.+bar.*$/m, 'unmodified'); $output = qx{../src/task rc:rc.rc rc.foo:baz show}; -like ($output, qr/\sfoo\s+baz/, 'overridden'); +like ($output, qr/^.*foo.*baz.*$/m, 'overridden'); unlink 'rc.rc'; ok (!-r 'rc.rc', 'Removed rc.rc');