2 # $Id: shunit2_test_failures.sh 286 2008-11-24 21:42:34Z kate.ward@forestent.com $
3 # vim:et:ft=sh:sts=2:sw=2
5 # Copyright 2008 Kate Ward. All Rights Reserved.
6 # Released under the LGPL (GNU Lesser General Public License)
8 # Author: kate.ward@forestent.com (Kate Ward)
10 # shUnit2 unit test for failure functions
12 # load common unit-test functions
13 . ./shunit2_test_helpers
15 #-----------------------------------------------------------------------------
21 ( fail >"${stdoutF}" 2>"${stderrF}" )
22 th_assertFalseWithOutput 'fail' $? "${stdoutF}" "${stderrF}"
24 ( fail "${MSG}" >"${stdoutF}" 2>"${stderrF}" )
25 th_assertFalseWithOutput 'fail with msg' $? "${stdoutF}" "${stderrF}"
27 ( fail arg1 >"${stdoutF}" 2>"${stderrF}" )
28 th_assertFalseWithOutput 'too many arguments' $? "${stdoutF}" "${stderrF}"
33 ( failNotEquals 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
34 th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
36 ( failNotEquals "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
37 th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
39 ( failNotEquals 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
40 th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
42 ( failNotEquals '' '' >"${stdoutF}" 2>"${stderrF}" )
43 th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
45 ( failNotEquals >"${stdoutF}" 2>"${stderrF}" )
46 th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
48 ( failNotEquals arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
49 th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
54 ( failSame 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
55 th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
57 ( failSame "${MSG}" 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
58 th_assertFalseWithOutput 'same with msg' $? "${stdoutF}" "${stderrF}"
60 ( failSame 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
61 th_assertFalseWithOutput 'not same' $? "${stdoutF}" "${stderrF}"
63 ( failSame '' '' >"${stdoutF}" 2>"${stderrF}" )
64 th_assertFalseWithOutput 'null values' $? "${stdoutF}" "${stderrF}"
66 ( failSame >"${stdoutF}" 2>"${stderrF}" )
67 th_assertFalseWithError 'too few arguments' $? "${stdoutF}" "${stderrF}"
69 ( failSame arg1 arg2 arg3 arg4 >"${stdoutF}" 2>"${stderrF}" )
70 th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
73 #-----------------------------------------------------------------------------
79 tmpDir="${__shunit_tmpDir}/output"
81 stdoutF="${tmpDir}/stdout"
82 stderrF="${tmpDir}/stderr"
84 MSG='This is a test message'
87 # load and run shUnit2
88 [ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0