From 899687f0efc79a6cc88a755f321ea08797cf6de5 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Tue, 31 May 2011 16:41:21 +0200 Subject: [PATCH] BUG: Multiple whitespace was condensed, CR/LF not turned to space. Missing quoting inside cleaninput() condensed multiple subsequent spaces into a single space, even when the user took pains to preserve whitespace by properly quoting the task in the shell. The 'tr' command completely removed CR and LF characters instead of replacing them with a single space. Add test cases for the whitespace handling to the add, append, prepend and replace actions. --- tests/t1000-addlist.sh | 33 +++++++++++++++++++++++++++++++++ tests/t1100-replace.sh | 8 ++++++++ tests/t1400-prepend.sh | 6 ++++++ tests/t1600-append.sh | 6 ++++++ todo.sh | 2 +- 5 files changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/t1000-addlist.sh b/tests/t1000-addlist.sh index 74cb037..83680c5 100755 --- a/tests/t1000-addlist.sh +++ b/tests/t1000-addlist.sh @@ -77,4 +77,37 @@ TODO: 5 added. TODO: 5 of 5 tasks shown EOF +# +# Advanced add +# + +cat /dev/null > todo.txt +test_todo_session 'add with spaces' <>> todo.sh add "notice the three spaces" +1 notice the three spaces +TODO: 1 added. + +>>> todo.sh add notice how the spaces get lost +2 notice how the spaces get lost +TODO: 2 added. + +>>> todo.sh list +2 notice how the spaces get lost +1 notice the three spaces +-- +TODO: 2 of 2 tasks shown +EOF + +cat /dev/null > todo.txt +test_todo_session 'add with CR' <>> todo.sh add "smell the Carriage Return" +1 smell the Carriage Return +TODO: 1 added. + +>>> todo.sh list +1 smell the Carriage Return +-- +TODO: 1 of 1 tasks shown +EOF + test_done diff --git a/tests/t1100-replace.sh b/tests/t1100-replace.sh index 370446f..068ab5c 100755 --- a/tests/t1100-replace.sh +++ b/tests/t1100-replace.sh @@ -89,6 +89,14 @@ TODO: Replaced task with: 1 thrash the hay & thrash the wheat EOF +echo 'jump on hay' > todo.txt +test_todo_session 'replace with spaces' <>> todo.sh replace 1 "notice the three spaces" +1 jump on hay +TODO: Replaced task with: +1 notice the three spaces +EOF + cat > todo.txt < todo.txt +test_todo_session 'prepend with spaces' <>> todo.sh prepend 1 "notice the three spaces and" +1 notice the three spaces and jump on hay +EOF + cat > todo.txt < todo.txt +test_todo_session 'append with spaces' <>> todo.sh append 1 "and notice the three spaces" +1 jump on hay and notice the three spaces +EOF + cat > todo.txt <