Modify the whatnow tests to deal with different versions of readline;
[mmh] / test / format / test-myname
index 97a0539..d9dca2d 100755 (executable)
@@ -4,35 +4,52 @@
 # the Signature profile entry, and via SIGNATURE environment variable.
 #
 
+set -e
+
 if test -z "${MH_OBJ_DIR}"; then
-    srcdir=`dirname $0`/../..
-    MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
+    srcdir=`dirname "$0"`/../..
+    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
 fi
 
 . "$MH_OBJ_DIR/test/common.sh"
 
 setup_test
 
-unset SIGNATURE 
-
-runtest()
-{
-       testoutput=$(${MH_LIB_DIR}/ap -format "%(myname)" ignore)
+unset SIGNATURE
 
-       if [ x"$1" != x"${testoutput}" ]; then
-               echo "For $2, expected $1 but got ${testoutput}"
-               exit 1
-       fi
-}
-
-runtest "$(${MH_OBJ_DIR}/test/getfullname)" "GECOS field test"
+fullname=`${MH_OBJ_DIR}/test/getfullname`
+run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \
+         "$fullname" "GECOS field test"
 
 echo "Signature: Some Random Name 1" >> ${MH}
 
-runtest "Some Random Name 1" "MH Profile Signature test"
+run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \
+         "Some Random Name 1" "MH Profile Signature test"
 
 export SIGNATURE="Some Random Name 2"
 
-runtest "${SIGNATURE}" "SIGNATURE Environment test"
-
-exit 0
+run_test "${MH_LIB_DIR}/ap -format %(myname) ignore" \
+         "${SIGNATURE}" "SIGNATURE Environment test"
+
+#### Test escaping of display names.
+escape="${MH_OBJ_DIR}/test/getfullname"
+run_test "$escape "'user'           'user'              'no escape'
+run_test "$escape "'first.last'     '"first.last"'      'escape'
+run_test "$escape "'"first.last"'   '"first.last"'      'already escaped'
+run_test "$escape "'embedded"quote' '"embedded\"quote"' 'embedded quote'
+run_test "$escape "'"'              '"\""'              'special "'
+run_test "$escape "'('              '"("'               'special ('
+run_test "$escape "')'              '")"'               'special )'
+#### We stop at the first comma so this one gets eliminated:
+run_test "$escape "','              ''                  'special ,'
+run_test "$escape "'.'              '"."'               'special .'
+run_test "$escape "':'              '":"'               'special :'
+run_test "$escape "';'              '";"'               'special ;'
+run_test "$escape "'<'              '"<"'               'special <'
+run_test "$escape "'>'              '">"'               'special >'
+run_test "$escape "'@'              '"@"'               'special @'
+run_test "$escape "'['              '"["'               'special ['
+run_test "$escape "'\\'             '"\\"'              'special \\'
+run_test "$escape "']'              '"]"'               'special ]'
+
+exit $failed