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
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 27;
|
use Test::More tests => 47;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'confirm.rc')
|
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/Permanently delete task 7 'foo'\? \(y\/n\)/, 'confirmation - N works');
|
||||||
like ($output, qr/Task not deleted\./, '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.
|
# Test newlines.
|
||||||
$output = qx{cat response.txt | ../task rc:confirm.rc del 7};
|
$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');
|
like ($output, qr/(Permanently delete task 7 'foo'\? \(y\/n\)) \1 \1/, 'confirmation - \n re-prompt works');
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ int confirm3 (const std::string& question)
|
|||||||
std::vector <std::string> options;
|
std::vector <std::string> options;
|
||||||
options.push_back ("Yes");
|
options.push_back ("Yes");
|
||||||
options.push_back ("no");
|
options.push_back ("no");
|
||||||
options.push_back ("all");
|
options.push_back ("All");
|
||||||
|
|
||||||
std::string answer;
|
std::string answer;
|
||||||
std::vector <std::string> matches;
|
std::vector <std::string> matches;
|
||||||
@@ -105,7 +105,7 @@ int confirm3 (const std::string& question)
|
|||||||
while (matches.size () != 1);
|
while (matches.size () != 1);
|
||||||
|
|
||||||
if (matches[0] == "Yes") return 1;
|
if (matches[0] == "Yes") return 1;
|
||||||
else if (matches[0] == "all") return 2;
|
else if (matches[0] == "All") return 2;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ int confirm4 (const std::string& question)
|
|||||||
std::vector <std::string> options;
|
std::vector <std::string> options;
|
||||||
options.push_back ("Yes");
|
options.push_back ("Yes");
|
||||||
options.push_back ("no");
|
options.push_back ("no");
|
||||||
options.push_back ("all");
|
options.push_back ("All");
|
||||||
options.push_back ("quit");
|
options.push_back ("quit");
|
||||||
|
|
||||||
std::string answer;
|
std::string answer;
|
||||||
@@ -142,7 +142,7 @@ int confirm4 (const std::string& question)
|
|||||||
while (matches.size () != 1);
|
while (matches.size () != 1);
|
||||||
|
|
||||||
if (matches[0] == "Yes") return 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 if (matches[0] == "quit") return 3;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user