/video-contact-sheet/branches/1.13.2/tests/src/make_test.bash |
---|
0,0 → 1,30 |
#!/bin/bash |
# This file can be used to generate a test script |
# The actual tests are contained in tests.txt |
testsfile=$(dirname "$0")/tests.txt |
TESTNAME=$1 |
shift |
REQS=$@ |
echo '#!/bin/bash' |
for req in $REQS; do |
echo "source $req" |
done |
echo "source src/unittest.bash" |
echo 'while read line ; do' |
echo ' unittest $line' |
echo 'done <<< "$(sed "/^[[:space:]]*#/d" "'$testsfile'" | grep "^'${TESTNAME}' ")"' |
echo 'if [[ $RET -eq 0 ]]; then' |
echo ' echo -n "${G}All tests passed"' |
echo 'else' |
echo ' echo -n "${R}Some tests failed"' |
echo 'fi' |
echo 'echo $CLR' |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/video-contact-sheet/branches/1.13.2/tests/src/unittest.bash |
---|
0,0 → 1,47 |
# |
# $Id$ |
# Receives the raw input as found in tests.txt |
# |
TESTNUM=0 |
G=$(tput setaf 2 ; tput bold ) |
R=$(tput setaf 1 ; tput bold) |
CLR=$(tput sgr0) |
RET=0 |
function unittest { |
let 'TESTNUM++' |
a="$@" |
fn=$(cut -d' ' -f1 <<<"$a") |
if [[ $TESTNUM -eq 1 ]]; then |
type $fn |
fi |
args=$(cut -d' ' -f2- <<<"$a" | sed 's/:.*$//' | sed 's/ *$//') |
expected=$(cut -d' ' -f2- <<<"$a" | sed 's/.*://') |
echo "$fn($args) -> $expected" >&2 |
res=$($fn $args) |
ret=$? |
passed= |
if [[ $expected == '><' ]]; then # Expected to fail |
if [[ $ret != 0 ]]; then |
passed=1 |
else |
passed=0 |
fi |
elif [[ $res != $expected ]] && ( [[ $res ]] && ! fptest "$res" ~ "$expected" ) ; then |
passed=0 |
else |
passed=1 |
fi |
if [[ $passed -ne 1 ]]; then |
echo -n "${R}FAILED => $res != '$expected'" |
let 'RET++' |
else |
echo -n "${G}PASSED => $res ~= $expected" |
fi |
echo $CLR |
} |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/video-contact-sheet/branches/1.13.2/tests/src/tests.txt |
---|
0,0 → 1,41 |
# $Id$ |
# Format: |
# test input [input ...] : expected_result |
# >< as expected result means the operation will fail |
#################### |
#################### get_interval() tests |
#################### |
get_interval 1h : 3600 |
get_interval 1h1m : 3660 |
get_interval 1h1m1 : 3661 |
get_interval 1h1m1s : 3661 |
get_interval 100 : 100 |
# Leading 0's |
get_interval 010 : 10 |
get_interval 01h0m01m01s : 3661 |
# Case insensitive |
get_interval 1H1M1S1s : 3662 |
# Reverse order of mangnitudes |
get_interval 1s1m1h : 3661 |
get_interval 1.22 : 1.22 |
get_interval 1s.22 : 1.22 |
get_interval .11.11.11 : 0.33 |
get_interval 1s.11.11 : 1.22 |
# Rejected inputs |
get_interval s : >< |
get_interval .11s : >< |
get_interval 1ss : >< |
# Repeated units |
get_interval 1s1s1s1s : 4 |
get_interval 1m1m1m1m : 240 |
get_interval 1h1h1h1h : 14400 |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |