diff options
author | kate.ward <kate.ward@forestent.com> | 2008-06-17 16:38:35 +0000 |
---|---|---|
committer | kate.ward <kate.ward@forestent.com> | 2008-06-17 16:38:35 +0000 |
commit | f51c61688f665b31f26c658cf389a9cd7843d4a9 (patch) | |
tree | 03db2704dfd65ad68896ecf95ab89fdea9dfeb25 /source/1.0/src/shflags_test_helpers | |
download | shflags-f51c61688f665b31f26c658cf389a9cd7843d4a9.tar.gz |
initial check-in
Diffstat (limited to 'source/1.0/src/shflags_test_helpers')
-rw-r--r-- | source/1.0/src/shflags_test_helpers | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/source/1.0/src/shflags_test_helpers b/source/1.0/src/shflags_test_helpers new file mode 100644 index 0000000..3a1e860 --- /dev/null +++ b/source/1.0/src/shflags_test_helpers @@ -0,0 +1,55 @@ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008 Kate Ward. All Rights Reserved. +# Released under the LGPL (GNU Lesser General Public License) +# +# Author: kate.ward@forestent.com (Kate Ward) +# +# shFlags unit test common functions + +__th_skipping=0 + +# path to shFlags library. can be overridden by setting SHFLAGS_INC +TH_SHFLAGS=${SHFLAGS_INC:-./shflags} + +# path to shUnit2 library. can be overridden by setting SHUNIT_INC +TH_SHUNIT=${SHUNIT_INC:-../lib/shunit2} + +TH_BOOL_VALID='true t 0 false f 1' +TH_BOOL_INVALID='123 123.0 blah' +TH_FLOAT_VALID='-1234.0 -1234 -1.0 -1 0.0 0 1.0 1 1234.0 1234' +TH_FLOAT_INVALID='true false invalid 1.2.3 -1.2.3 0. -.5' +TH_INT_VALID='-1234 -1 0 1 1234' +TH_INT_INVALID='-1.0 0.0 1.0 invalid' + +# +# test helper functions +# + +# message functions +th_trace() { echo "test:TRACE $@" >&2; } +th_debug() { echo "test:DEBUG $@" >&2; } +th_info() { echo "test:INFO $@" >&2; } +th_warn() { echo "test:WARN $@" >&2; } +th_error() { echo "test:ERROR $@" >&2; } +th_fatal() { echo "test:FATAL $@" >&2; } + +th_showOutput() +{ + _th_rtrn=$1 + _th_stdout=$2 + _th_stderr=$3 + + isSkipping + if [ $? -eq ${SHUNIT_FALSE} -a ${_th_rtrn} != ${FLAGS_TRUE} ]; then + cat "${_th_stdout}" "${_th_stderr}" >&2 + fi + + unset _th_rtrn _th_stdout _th_stderr +} + +assertErrorMsg() +{ + grep -- 'flags:ERROR' "${stderrF}" >/dev/null + assertTrue "FLAGS ${1:+\($1\) }failure did not result in an error message" $? +} |