From fd250083492420769109b2d07790e8c695a2e2ed Mon Sep 17 00:00:00 2001 From: David Levine Date: Wed, 22 Feb 2012 22:23:05 -0600 Subject: [PATCH] Added test-flist and test-mark sequences tests. --- Makefile.am | 1 + test/sequences/test-flist | 79 ++++++++++++++++++++++++++++++++++++++++++ test/sequences/test-mark | 83 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100755 test/sequences/test-flist create mode 100755 test/sequences/test-mark diff --git a/Makefile.am b/Makefile.am index 3b6b84a..e86320e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -50,6 +50,7 @@ TESTS = test/bad-input/test-header test/folder/test-create \ 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/sequences/test-flist test/sequences/test-mark \ test/whatnow/test-attach-detach test/whatnow/test-cd \ test/whatnow/test-ls \ test/cleanup ## The "cleanup" test should always be last. diff --git a/test/sequences/test-flist b/test/sequences/test-flist new file mode 100755 index 0000000..b897037 --- /dev/null +++ b/test/sequences/test-flist @@ -0,0 +1,79 @@ +#!/bin/sh +###################################################### +# +# Test flist +# +###################################################### + +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 + +run_test 'mark 1 3 5 7 9 +inbox -sequence odd' '' +run_test 'mark -s odd -list' 'odd: 1 3 5 7 9' +run_test 'mark +inbox -sequence unseen all' '' +run_test 'mark +inbox -sequence unseen -list' 'unseen: 1-10' + +folder -create +other > /dev/null +for i in 2 5 7 12; do + cp -p "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/other/$i" +done +run_test 'mark +other -sequence unseen all' '' +run_test 'mark +other -sequence unseen -list' 'unseen: 2 5 7 12' + +# Make sure that inbox is current folder. +folder -f +inbox > /dev/null + +# Test flists. +run_test 'flists -seq odd' 'inbox+ has 5 in sequence odd; out of 10 +other has 0 in sequence odd; out of 4' + +run_test 'flists -seq unseen' \ + 'inbox+ has 10 in sequence unseen; out of 10 +other has 4 in sequence unseen; out of 4' + +# Test flist on individual folders, starting with the current folder. +run_test 'flist -sequence unseen' \ + 'inbox+ has 10 in sequence unseen; out of 10' +run_test 'flist +other -sequence unseen' \ + 'other+ has 4 in sequence unseen; out of 4' + +# Test multiple folders and sequences. +run_test 'flist +inbox +other -seq unseen -seq odd' \ + 'inbox has 10 in sequence unseen; out of 10 +inbox has 5 in sequence odd ; out of 10 +other+ has 4 in sequence unseen; out of 4 +other+ has 0 in sequence odd ; out of 4' + +# Test Flist-Order with -noalpha. +echo 'Flist-Order: o* i*' >> $MH_TEST_DIR/Mail/.mh_profile +run_test 'flists -seq unseen -seq odd -noalpha' \ + 'other+ has 4 in sequence unseen; out of 4 +other+ has 0 in sequence odd ; out of 4 +inbox has 10 in sequence unseen; out of 10 +inbox has 5 in sequence odd ; out of 10' + +# Test nonexistent folder. +run_test 'flist +nonexistent -seq unseen' '' + +# Test nonexistent sequence. +run_test 'flist +inbox -seq nonexistent' \ + 'inbox+ has 0 in sequence nonexistent; out of 10' + +# Test -fast. +folder -f +inbox > /dev/null +run_test 'flist -sequence unseen -fast' 'inbox' +run_test 'flist +other -sequence unseen -fast' 'other' + +# Test -fast and -alpha. +run_test 'flists -seq unseen -fast -alpha' 'inbox +other' + +exit $failed diff --git a/test/sequences/test-mark b/test/sequences/test-mark new file mode 100755 index 0000000..96a7e3d --- /dev/null +++ b/test/sequences/test-mark @@ -0,0 +1,83 @@ +#!/bin/sh +###################################################### +# +# Test mark +# +###################################################### + +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 + +# Test sequence creation. +run_test 'mark 1 3 5 7 +inbox -sequence odd' '' +run_test 'mark 2 4 6 8 10 +inbox -sequence even' '' +run_test 'mark +inbox -seq odd -seq even -list' \ + 'odd: 1 3 5 7 +even: 2 4 6 8 10' + +# Test add. +run_test 'mark 9 -sequence odd -add -nozero' '' +run_test 'mark -seq odd -list' 'odd: 1 3 5 7 9' + +# Test delete. +run_test 'mark 9 -sequence odd -delete' '' +run_test 'mark -seq odd -list' 'odd: 1 3 5 7' + +# Test that -nozero is default +run_test 'mark 9 -sequence odd -add' '' +run_test 'mark -seq odd -list' 'odd: 1 3 5 7 9' + +# Test -zero +run_test 'mark 10 -s even -add -zero' '' +run_test 'mark -s even -list' 'even: 10' + +# Test add prior to last message; +run_test 'mark 8 -s even -add' '' +run_test 'mark -s even -list' 'even: 8 10' + +# Test list. +run_test 'mark -s odd -list' 'odd: 1 3 5 7 9' + +# Try to mark message that doesn't exist. +run_test 'mark 12' "mark: message 12 doesn't exist" + +# Try to mark nonexistent folder. +run_test 'mark +nonexistent' \ + "mark: unable to change directory to `mhpath +`/nonexistent: \ +No such file or directory" + +# Test private sequence creation. +# Set current message for following tests. +folder +inbox 1 > /dev/null +run_test 'mark 1 -sequence privateseq -add -nopublic' '' +run_test 'mark -list' 'cur: 1 +odd: 1 3 5 7 9 +even: 8 10 +privateseq (private): 1' + +# Test add to private sequence. +run_test 'mark 2 -sequence privateseq -add -nopublic' '' +run_test 'mark -list' 'cur: 1 +odd: 1 3 5 7 9 +even: 8 10 +privateseq (private): 1-2' + +# Test private sequence list. +run_test 'mark -sequence privateseq -list' 'privateseq (private): 1-2' + +# Test private sequence list with -public, which is apparently ignored. +run_test 'mark -sequence privateseq -list -public' 'privateseq (private): 1-2' + +# Test mark on empty folder. +folder -create +other > /dev/null +run_test 'mark +other -sequence unseen all' 'mark: no messages in other' + +exit $failed -- 1.7.10.4