Fixed PREFIX in Makefile, added several tests in tests/
This commit is contained in:
58
tests/test_clean_state.sh
Normal file
58
tests/test_clean_state.sh
Normal file
@@ -0,0 +1,58 @@
|
||||
source $(dirname ${BASH_SOURCE})/../cmdarg.sh
|
||||
|
||||
function shunittest_clean_state()
|
||||
{
|
||||
# Tests that cmdarg_purge ensures an empty config state
|
||||
function parse1()
|
||||
{
|
||||
cmdarg 'a:' 'a' 'some arg'
|
||||
cmdarg 'b' 'b' 'some arg'
|
||||
cmdarg_parse "$@"
|
||||
}
|
||||
|
||||
function parse2()
|
||||
{
|
||||
cmdarg_purge
|
||||
cmdarg_parse "$@"
|
||||
}
|
||||
|
||||
# This cleans the state from shunit
|
||||
cmdarg_purge
|
||||
parse1 -a 3 -b
|
||||
parse2
|
||||
if [[ "${cmdarg_cfg['a']}" == "" ]]; then
|
||||
return 0
|
||||
else
|
||||
cmdarg_dump
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function shunittest_clean_state_subshells()
|
||||
{
|
||||
# Ensures that, when subsequent cmdarg invocations occur in subshells,
|
||||
# that the initial state is empty even without having called cmdarg_purge
|
||||
|
||||
# This is just here to clean the state from shunit
|
||||
cmdarg_purge
|
||||
function parse1()
|
||||
{
|
||||
cmdarg 'a:' 'a' 'some arg'
|
||||
cmdarg 'b' 'b' 'some arg'
|
||||
cmdarg_parse "$@"
|
||||
}
|
||||
|
||||
function parse2()
|
||||
{
|
||||
cmdarg_parse "$@"
|
||||
}
|
||||
|
||||
(parse1 -a 3 -b)
|
||||
(parse2)
|
||||
if [[ "${cmdarg_cfg['a']}" == "" ]]; then
|
||||
return 0
|
||||
else
|
||||
cmdarg_dump
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user