aboutsummaryrefslogtreecommitdiff
path: root/shunit2-2.0.3/src/test
diff options
context:
space:
mode:
authorPeter Carbonetto2017-07-18 12:56:21 -0500
committerPeter Carbonetto2017-07-18 12:56:21 -0500
commit66e2499abdeb663034721425ad6e8efb3340ad99 (patch)
tree488cd3c971985fcc66579539e2704bb2641aadc4 /shunit2-2.0.3/src/test
parent9c718e1730ffdc78a9154f227250799ab52f7dfa (diff)
downloadpangemma-66e2499abdeb663034721425ad6e8efb3340ad99.tar.gz
Added shunint2 v2.0.3 files.
Diffstat (limited to 'shunit2-2.0.3/src/test')
-rwxr-xr-xshunit2-2.0.3/src/test/run-test-suite116
-rw-r--r--shunit2-2.0.3/src/test/test-functions.inc84
-rwxr-xr-xshunit2-2.0.3/src/test/testAsserts242
-rwxr-xr-xshunit2-2.0.3/src/test/testFailures89
-rwxr-xr-xshunit2-2.0.3/src/test/testInternalFx23
-rwxr-xr-xshunit2-2.0.3/src/test/testSuiteFx23
6 files changed, 577 insertions, 0 deletions
diff --git a/shunit2-2.0.3/src/test/run-test-suite b/shunit2-2.0.3/src/test/run-test-suite
new file mode 100755
index 0000000..7791fa1
--- /dev/null
+++ b/shunit2-2.0.3/src/test/run-test-suite
@@ -0,0 +1,116 @@
+#! /bin/sh
+# $Id: run-test-suite 432 2007-01-05 14:58:37Z sfsetse $
+
+MY_NAME=`basename $0`
+MY_PATH=`dirname $0`
+
+SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh'
+for f in test[A-Z]*; do
+ [ -x "${f}" ] && TESTS="${TESTS:+${TESTS} }${f}"
+done
+
+# load common unit test functions
+. "${MY_PATH}/test-functions.inc"
+
+usage()
+{
+ echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]"
+}
+
+# process command line flags
+while getopts 'e:hs:t:' opt; do
+ case ${opt} in
+ e)
+ key=`expr "${OPTARG}" : '\([^=]*\)='`
+ val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
+ if [ -z "${key}" -o -z "${val}" ]; then
+ usage
+ exit 1
+ fi
+ eval "${key}='${val}'"
+ export ${key}
+ env="${env:+${env} }${key}"
+ ;;
+ h) usage; exit 0 ;;
+ s) shells=${OPTARG} ;;
+ t) tests=${OPTARG} ;;
+ *) usage; exit 1 ;;
+ esac
+done
+shift `expr ${OPTIND} - 1`
+
+# fill shells and/or tests
+shells=${shells:-${SHELLS}}
+tests=${tests:-${TESTS}}
+
+# error checking
+if [ -z "${tests}" ]; then
+ tf_error 'no tests found to run; exiting'
+ exit 1
+fi
+
+cat <<EOF
+#------------------------------------------------------------------------------
+# System data
+#
+
+# test run info
+shells="${shells}"
+tests="${tests}"
+EOF
+for key in ${env}; do
+ eval "echo \"${key}=\$${key}\""
+done
+echo
+
+# output system data
+echo "# system info"
+echo "$ date"
+date
+
+echo "$ uname -mprsv"
+uname -mprsv
+
+#
+# run tests
+#
+
+for shell in ${shells}; do
+ echo
+
+ # check for existence of shell
+ if [ ! -x ${shell} ]; then
+ tf_warn "unable to run tests with the ${shell} shell"
+ continue
+ fi
+
+ cat <<EOF
+
+#------------------------------------------------------------------------------
+# Running the test suite with ${shell}
+#
+EOF
+
+ case `basename ${shell}` in
+ bash) echo; ${shell} --version; ;;
+ dash) ;;
+ ksh)
+ version=`${shell} --version exit 2>&1`
+ exitVal=$?
+ if [ ${exitVal} -eq 2 ]; then
+ echo
+ echo "${version}"
+ fi
+ ;;
+ pdksh) ;;
+ zsh) ;;
+ esac
+
+ # execute the tests
+ for suite in ${tests}; do
+ suiteName=`expr "${suite}" : 'test\(.*\)'`
+ echo
+ echo "--- Executing the '${suiteName}' test suite ---" >&2
+ ( exec ${shell} ./${suite}; )
+ done
+done
diff --git a/shunit2-2.0.3/src/test/test-functions.inc b/shunit2-2.0.3/src/test/test-functions.inc
new file mode 100644
index 0000000..fe7b3e9
--- /dev/null
+++ b/shunit2-2.0.3/src/test/test-functions.inc
@@ -0,0 +1,84 @@
+# $Id: test-functions.inc 416 2007-01-04 00:50:14Z sfsetse $
+# vim:syntax=sh:sts=2
+
+#
+# constants
+#
+
+# configure debugging. set the DEBUG environment variable to any
+# non-empty value to enable debug output, or TRACE to enable trace
+# output.
+TRACE=${TRACE:+'tf_trace '}
+[ -n "${TRACE}" ] && DEBUG=1
+[ -z "${TRACE}" ] && TRACE=':'
+
+DEBUG=${DEBUG:+'tf_debug '}
+[ -z "${DEBUG}" ] && DEBUG=':'
+
+#
+# variables
+#
+
+tf_RANDOM=0
+
+#
+# functions
+#
+
+# message functions
+tf_trace() { echo "${MY_NAME}:TRACE $@" >&2; }
+tf_debug() { echo "${MY_NAME}:DEBUG $@" >&2; }
+tf_info() { echo "${MY_NAME}:INFO $@" >&2; }
+tf_warn() { echo "${MY_NAME}:WARN $@" >&2; }
+tf_error() { echo "${MY_NAME}:ERROR $@" >&2; }
+tf_fatal() { echo "${MY_NAME}:FATAL $@" >&2; }
+
+# generate a random number
+tf_generateRandom()
+{
+ tfgr_random=${tf_RANDOM}
+
+ while [ "${tfgr_random}" = "${tf_RANDOM}" ]; do
+ if [ -n "${RANDOM:-}" ]; then
+ # $RANDOM works
+ tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$
+ elif [ -r '/dev/urandom' ]; then
+ tfgr_random=`od -vAn -N4 -tu4 </dev/urandom |sed 's/^[^0-9]*//'`
+ else
+ tfgr_date=`date '+%H%M%S'`
+ tfgr_random=`expr ${tfgr_date} \* $$`
+ unset tfgr_date
+ fi
+ [ "${tfgr_random}" = "${tf_RANDOM}" ] && sleep 1
+ done
+
+ tf_RANDOM=${tfgr_random}
+ unset tfgr_random
+}
+
+# this section returns the data section from the specified section of a file. a
+# datasection is defined by a [header], one or more lines of data, and then a
+# blank line.
+tf_getDataSect()
+{
+ tf_sgrep "\\[$1\\]" "$2" |sed '1d'
+}
+
+# this function greps a section from a file. a section is defined as a group of
+# lines preceded and followed by blank lines.
+tf_sgrep()
+{
+ tf_pattern=$1
+ shift
+
+ sed -e '/./{H;$!d;}' -e "x;/${tf_pattern}/"'!d;' $@ |sed '1d'
+
+ unset tf_pattern
+}
+
+#
+# main
+#
+
+${TRACE} 'trace output enabled'
+${DEBUG} 'debug output enabled'
diff --git a/shunit2-2.0.3/src/test/testAsserts b/shunit2-2.0.3/src/test/testAsserts
new file mode 100755
index 0000000..12a3943
--- /dev/null
+++ b/shunit2-2.0.3/src/test/testAsserts
@@ -0,0 +1,242 @@
+#! /bin/sh
+# $Id$
+# vim: expandtab
+# author: Kate Ward <kate.ward@forestent.com>
+#
+# Self-testing unit tests for shUnit2 asserts
+#
+
+MSG='This is a test message'
+
+#-----------------------------------------------------------------------------
+# suite tests
+#
+
+commonEqualsSame()
+{
+ fn=$1
+
+ msg='same, with message'
+ rslt=`${fn} "${MSG}" 'x' 'x' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='same'
+ rslt=`${fn} 'x' 'x' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='not same'
+ rslt=`${fn} 'x' 'y' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='null values'
+ rslt=`${fn} '' '' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`${fn} 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+testAssertEquals()
+{
+ commonEqualsSame 'assertEquals'
+}
+
+testAssertSame()
+{
+ commonEqualsSame 'assertSame'
+}
+
+testAssertNotSame()
+{
+ msg='not same, with message'
+ rslt=`assertNotSame "${MSG}" 'x' 'y' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='not same'
+ rslt=`assertNotSame 'x' 'y' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='same'
+ rslt=`assertNotSame 'x' 'x' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='null values'
+ rslt=`assertNotSame '' '' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`assertNotSame 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+testAssertNull()
+{
+ msg='null, with message'
+ rslt=`assertNull "${MSG}" '' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='null'
+ rslt=`assertNull '' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='not null'
+ rslt=`assertNull 'x' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`assertNull 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+testAssertNotNull()
+{
+ msg='not null, with message'
+ rslt=`assertNotNull "${MSG}" 'x' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='not null'
+ rslt=`assertNotNull 'x' 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='null'
+ rslt=`assertNotNull '' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`assertNotNull 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+testAssertTrue()
+{
+ msg='true, with message'
+ rslt=`assertTrue "${MSG}" 0 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='true'
+ rslt=`assertTrue 0 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='true condition'
+ rslt=`assertTrue "[ 0 -eq 0 ]" 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='false'
+ rslt=`assertTrue 1 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='false condition'
+ rslt=`assertTrue "[ 0 -eq 1 ]" 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='null value'
+ rslt=`assertTrue '' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`assertTrue 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+testAssertFalse()
+{
+ msg='false, with message'
+ rslt=`assertFalse "${MSG}" 1 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='false'
+ rslt=`assertFalse 1 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='false condition'
+ rslt=`assertFalse "[ 0 -eq 1 ]" 2>&1`
+ rtrn=$?
+ assertSame "${msg}" '' "${rslt}"
+ assertTrue "${msg}; failure" ${rtrn}
+
+ msg='true'
+ rslt=`assertFalse 0 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='true condition'
+ rslt=`assertFalse "[ 0 -eq 0 ]" 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='null value'
+ rslt=`assertFalse '' 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+
+ msg='too few arguments'
+ rslt=`assertFalse 2>&1`
+ rtrn=$?
+ assertNotSame "${msg}" '' "${rslt}"
+ assertFalse "${msg}; failure" ${rtrn}
+}
+
+#-----------------------------------------------------------------------------
+# suite functions
+#
+
+# load and run shUnit2
+. ./shunit2
diff --git a/shunit2-2.0.3/src/test/testFailures b/shunit2-2.0.3/src/test/testFailures
new file mode 100755
index 0000000..9410510
--- /dev/null
+++ b/shunit2-2.0.3/src/test/testFailures
@@ -0,0 +1,89 @@
+#! /bin/sh
+# $Id$
+# vim: expandtab
+# author: Kate Ward <kate.ward@forestent.com>
+#
+# Self-testing unit tests for shUnit2 failures
+#
+
+MSG='This is a test message'
+
+#-----------------------------------------------------------------------------
+# suite tests
+#
+
+commonNotEqualsSame()
+{
+ fn=$1
+
+ msg='same, with message'
+ rslt=`${fn} "${MSG}" 'x' 'x' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='same'
+ rslt=`${fn} 'x' 'x' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='not same'
+ rslt=`${fn} 'x' 'y' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='null values'
+ rslt=`${fn} '' '' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='too few arguments'
+ rslt=`${fn} 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+}
+
+testFail()
+{
+ msg='with message'
+ rslt=`fail "${MSG}" 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='without message'
+ rslt=`fail 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+}
+
+testFailNotEquals()
+{
+ commonNotEqualsSame 'failNotEquals'
+}
+
+testFailSame()
+{
+ msg='same, with message'
+ rslt=`failSame "${MSG}" 'x' 'x' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='same'
+ rslt=`failSame 'x' 'x' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='not same'
+ rslt=`failSame 'x' 'y' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='null values'
+ rslt=`failSame '' '' 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+
+ msg='too few arguments'
+ rslt=`failSame 2>&1`
+ assertNotSame "${msg}" '' "${rslt}"
+}
+
+testFailNotSame()
+{
+ commonNotEqualsSame 'failNotSame'
+}
+
+#-----------------------------------------------------------------------------
+# suite functions
+#
+
+# load and run shUnit2
+. ./shunit2
diff --git a/shunit2-2.0.3/src/test/testInternalFx b/shunit2-2.0.3/src/test/testInternalFx
new file mode 100755
index 0000000..9409dc2
--- /dev/null
+++ b/shunit2-2.0.3/src/test/testInternalFx
@@ -0,0 +1,23 @@
+#! /bin/sh
+# $Id$
+# vim: expandtab
+# author: Kate Ward <kate.ward@forestent.com>
+#
+# Self-testing unit tests for shUnit2 internal functions
+#
+
+#-----------------------------------------------------------------------------
+# suite tests
+#
+
+testGenerateReport()
+{
+ :
+}
+
+#-----------------------------------------------------------------------------
+# suite functions
+#
+
+# load and run shUnit2
+. ./shunit2
diff --git a/shunit2-2.0.3/src/test/testSuiteFx b/shunit2-2.0.3/src/test/testSuiteFx
new file mode 100755
index 0000000..c0e6ab8
--- /dev/null
+++ b/shunit2-2.0.3/src/test/testSuiteFx
@@ -0,0 +1,23 @@
+#! /bin/sh
+# $Id$
+# vim: expandtab
+# author: Kate Ward <kate.ward@forestent.com>
+#
+# Self-testing unit tests for shUnit2 suite functions
+#
+
+#-----------------------------------------------------------------------------
+# suite tests
+#
+
+testAddTest()
+{
+ :
+}
+
+#-----------------------------------------------------------------------------
+# suite functions
+#
+
+# load and run shUnit2
+. ./shunit2