From b684ded84560c49d975a5165cbd6bf3f63250a56 Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Wed, 9 Dec 2009 01:11:14 +0100 Subject: [PATCH] Bug #347 - Confirmation dialog is lowercase for "all" - changed confirmation to be now "All" for multiple changes - added unit tests for all answers to multiple changes --- ChangeLog | 2 ++ src/tests/confirmation.t | 34 +++++++++++++++++++++++++++++++++- src/util.cpp | 8 ++++---- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6454e8626..4ac14efdf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ due dates, which are no longer relevant to a completed task (thanks to Cory Donnelly). + Fixed bug that was causing the 'completed' report to sort incorrectly. + + Fixed bug #347 which used only a lowercase "all" to confirm multiple changes + instead of an uppercase "All" like the "Yes" answer. ------ old releases ------------------------------ diff --git a/src/tests/confirmation.t b/src/tests/confirmation.t index 9ebf21921..6f45f4d44 100755 --- a/src/tests/confirmation.t +++ b/src/tests/confirmation.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 27; +use Test::More tests => 47; # Create the rc file. if (open my $fh, '>', 'confirm.rc') @@ -91,6 +91,38 @@ $output = qx{echo "N" | ../task rc:confirm.rc del 7}; like ($output, qr/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - N works'); like ($output, qr/Task not deleted\./, 'confirmation - N works'); +# Test Yes for multiple changes +$output = qx{echo -e "y\nY\nY\nY\nY" | ../task rc:confirm.rc 7-10 +bar}; +like ($output, qr/Proceed with change\? \(Yes\/no\/All\/quit\)/, 'multiple confirmations - Y works'); +like ($output, qr/Task 7 "foo"/, 'multiple confirmations - Y works'); +like ($output, qr/Task 8 "foo"/, 'multiple confirmations - Y works'); +like ($output, qr/Task 9 "foo"/, 'multiple confirmations - Y works'); +like ($output, qr/Task 10 "foo"/, 'multiple confirmations - Y works'); +like ($output, qr/Modified 4 tasks/, 'multiple confirmations - Y works'); + +# Test no for multiple changes +$output = qx{echo -e "N\nn\nn\nn\nn" | ../task rc:confirm.rc 7-10 -bar}; +like ($output, qr/Proceed with change\? \(Yes\/no\/All\/quit\)/, 'multiple confirmations - n works'); +like ($output, qr/Task 7 "foo"/, 'multiple confirmations - n works'); +like ($output, qr/Task 8 "foo"/, 'multiple confirmations - n works'); +like ($output, qr/Task 9 "foo"/, 'multiple confirmations - n works'); +like ($output, qr/Task 10 "foo"/, 'multiple confirmations - n works'); +like ($output, qr/Modified 0 tasks/, 'multiple confirmations - n works'); + +# Test All for multiple changes +$output = qx{echo -e "a\nA" | ../task rc:confirm.rc 7-10 -bar}; +like ($output, qr/Proceed with change\? \(Yes\/no\/All\/quit\)/, 'multiple confirmations - A works'); +like ($output, qr/Task 7 "foo"/, 'multiple confirmations - A works'); +unlike ($output, qr/Task 8 "foo"/, 'multiple confirmations - A works'); +like ($output, qr/Modified 4 tasks/, 'multiple confirmations - A works'); + +# Test quit for multiple changes +$output = qx{echo "q" | ../task rc:confirm.rc 7-10 +bar}; +like ($output, qr/Proceed with change\? \(Yes\/no\/All\/quit\)/, 'multiple confirmations - q works'); +like ($output, qr/Task 7 "foo"/, 'multiple confirmations - q works'); +unlike ($output, qr/Task 8 "foo"/, 'multiple confirmations - q works'); +like ($output, qr/Modified 0 tasks/, 'multiple confirmations - q works'); + # Test newlines. $output = qx{cat response.txt | ../task rc:confirm.rc del 7}; like ($output, qr/(Permanently delete task 7 'foo'\? \(y\/n\)) \1 \1/, 'confirmation - \n re-prompt works'); diff --git a/src/util.cpp b/src/util.cpp index 58bbd9236..8c79b3a8c 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -84,7 +84,7 @@ int confirm3 (const std::string& question) std::vector options; options.push_back ("Yes"); options.push_back ("no"); - options.push_back ("all"); + options.push_back ("All"); std::string answer; std::vector matches; @@ -105,7 +105,7 @@ int confirm3 (const std::string& question) while (matches.size () != 1); if (matches[0] == "Yes") return 1; - else if (matches[0] == "all") return 2; + else if (matches[0] == "All") return 2; else return 0; } @@ -119,7 +119,7 @@ int confirm4 (const std::string& question) std::vector options; options.push_back ("Yes"); options.push_back ("no"); - options.push_back ("all"); + options.push_back ("All"); options.push_back ("quit"); std::string answer; @@ -142,7 +142,7 @@ int confirm4 (const std::string& question) while (matches.size () != 1); if (matches[0] == "Yes") return 1; - else if (matches[0] == "all") return 2; + else if (matches[0] == "All") return 2; else if (matches[0] == "quit") return 3; else return 0; }