From: David Levine Date: Sat, 18 Feb 2012 15:42:04 +0000 (-0600) Subject: Added mhpath test. Updated mhpath man page to reflect actual behavior for a message... X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=67473e912ec0a0849a70cb61d9368c75dae614ee;p=mmh Added mhpath test. Updated mhpath man page to reflect actual behavior for a message number greater than that of the highest existing message in a folder. --- diff --git a/Makefile.am b/Makefile.am index dc63866..7358c78 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,11 +46,13 @@ TESTS = test/bad-input/test-header test/folder/test-create \ test/format/test-mymbox \ test/inc/test-deb359167 test/inc/test-eom-align \ test/manpages/test-manpages test/mhbuild/test-forw \ + test/mhpath/test-mhpath \ test/mhshow/test-cte-binary test/mhshow/test-qp \ test/mhshow/test-subpart test/new/test-basic test/pick/test-stderr \ test/repl/test-if-str test/scan/test-scan \ test/whatnow/test-attach-detach test/whatnow/test-cd \ - test/whatnow/test-ls test/cleanup + test/whatnow/test-ls \ + test/cleanup ## The "cleanup" test should always be last. check_SCRIPTS = test/common.sh check_PROGRAMS = test/getfullname diff --git a/man/mhpath.man b/man/mhpath.man index e04c4a3..4ad442c 100644 --- a/man/mhpath.man +++ b/man/mhpath.man @@ -48,9 +48,14 @@ message, if the folder contains messages. .IP 3) 4 An empty folder is not in itself an error. .PP -Message numbers greater than the highest existing message in a folder -as part of a range designation are replaced with the next free message -number. +A message number less than that of the smallest existing message in a +folder is treated as if the message already exists. A message number +greater than that of the highest existing message in a folder causes +an \*(lqout of range\*(rq error message to be displayed. +.PP +As part of a range designation that contains messages that do exist, +message numbers less than the smallest, or greater than the highest, +existing message in a folder are ignored. .PP Examples: The current folder foo contains messages 3 5 6. Cur is 4. @@ -66,7 +71,7 @@ Cur is 4. /r/phyl/Mail/foo/6 % mhpath 2001 -/r/phyl/Mail/foo/7 +mhpath: message 2001 out of range 1-6 % mhpath 1\-2001 /r/phyl/Mail/foo/3 @@ -81,13 +86,13 @@ Cur is 4. /r/phyl/Mail/foo/7 % mhpath last\-new -bad message list \*(lqlast\-new\*(rq. +mhpath: bad message list last\-new % mhpath cur /r/phyl/Mail/foo/4 % mhpath 1\-2 -no messages in range \*(lq1\-2\*(rq. +mhpath: no messages in range 1\-2 % mhpath first:2 /r/phyl/Mail/foo/3 diff --git a/test/mhpath/test-mhpath b/test/mhpath/test-mhpath new file mode 100755 index 0000000..2f88eb0 --- /dev/null +++ b/test/mhpath/test-mhpath @@ -0,0 +1,139 @@ +#!/bin/sh +###################################################### +# +# Test mhpath +# +###################################################### + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname $0`/../.. + MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR +fi + +. "$MH_OBJ_DIR/test/common.sh" + +setup_test + +expected=$MH_TEST_DIR/$$.expected +actual=$MH_TEST_DIR/$$.actual + + +# check -help +cat > $expected < $actual 2>&1 +check $expected $actual + +# check -version +if ! mhpath -v | grep '^mhpath --' > /dev/null; then + echo "$0: mhpath -v generated unexpected output" 1>&2 + failed=`expr ${failed:-0} + 1` +fi + +# check + +check_string "mhpath +" "$MH_TEST_DIR/Mail" + +# check with no options +folder -fast +inbox > /dev/null +check_string "mhpath" "$MH_TEST_DIR/Mail/inbox" + +# check +inbox +check_string "mhpath +inbox" "$MH_TEST_DIR/Mail/inbox" + +# check all +cat > $expected < $actual 2>&1 +check $expected $actual + +# check message number greater than highest +check_string "mhpath 11" "mhpath: message 11 out of range 1-10" +check_string "mhpath 10 11" "mhpath: message 11 out of range 1-10" + +# check range with message number greater than highest +cat > $expected < $actual 2>&1 +check $expected $actual + +# check new +check_string "mhpath new" "$MH_TEST_DIR/Mail/inbox/11" + +# check multiple msgs, including new +cat > $expected < $actual 2>&1 +check $expected $actual + +# check invalid message list using names +check_string "mhpath last-new" "mhpath: bad message list last-new" + +# check cur +folder +inbox 5 > /dev/null +check_string "mhpath cur" "$MH_TEST_DIR/Mail/inbox/5" + +# check prev +check_string "mhpath prev" "$MH_TEST_DIR/Mail/inbox/4" + +# check next +check_string "mhpath next" "$MH_TEST_DIR/Mail/inbox/6" + +# check invalid message list using numbers +rmm 1-2 +check_string "mhpath 1-2" "mhpath: no messages in range 1-2" + +# check ignoring of out-of-range message numbers in ranges +check_string "mhpath 1-3" "$MH_TEST_DIR/Mail/inbox/3" +check_string "mhpath first-3" "$MH_TEST_DIR/Mail/inbox/3" +check_string "mhpath 10-11" "$MH_TEST_DIR/Mail/inbox/10" +check_string "mhpath last-11" "$MH_TEST_DIR/Mail/inbox/10" + +# check reference to existing messages +cat > $expected < $actual 2>&1 +check $expected $actual + +# check reference to non-existant messages +cat > $expected < $actual 2>&1 +check $expected $actual + + +exit $failed